1 / 2

.globl Adder .type Adder, @function Adder: pushq %rbp

////////////////////////////////////////////////////////////////////////// // Adder - code executed by one of the threads ////////////////////////////////////////////////////////////////////////// void *Adder(void *arg) { int i; for (i = 0; i < LoopCount; i++) {

onella
Download Presentation

.globl Adder .type Adder, @function Adder: pushq %rbp

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Adder - code executed by one of the threads ////////////////////////////////////////////////////////////////////////// void *Adder(void *arg) { int i; for (i = 0; i < LoopCount; i++) { GlobalVariable++; } // End of for } // End of Adder .globl Adder .type Adder, @function Adder: pushq %rbp movq %rsp, %rbp movq %rdi, -8(%rbp) movl $0, -12(%rbp) .L10: movl -12(%rbp), %eax cmpl LoopCount(%rip), %eax jl .L13 jmp .L11 .L13: incl GlobalVariable(%rip) leaq -12(%rbp), %rax incl (%rax) jmp .L10 .L11: leave ret .gcc ThreadsRunAmock.c -S So why does ThreadsRunAmock.c give such strange behavior on a multiprocessor??

  2. Intel Architecture Software Developer's Manual, Volume 2: Instruction Set Reference Manual This instruction is NOT atomic!!

More Related