Previous | Next --- Slide 39 of 64
Back to Lecture Thumbnails
RomanArena

So the work queue is first in, last out?

paracon

@RomanArena, I am not sure you can call the work queue first in, last out. It will depend on whether the work put of Thread 0's work queue was stolen by other threads.

blah329

@RomanArena If we assume that no stealing occurs, then yes, it seems like that the work queue operates as a LIFO data structure. So in this example, the execution order would definitely be different than if the cilk_spawn had been removed. Had it been removed, then we would've observed foo(0) ... foo(N - 1). However since that is not the case, and the queue operates as a LIFO data structure, the sequence of function calls that is observed here if actually foo(N-1) ... foo(0).