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

By running continuation first, all children are spawned and pushed into the work queue (or stack) of thread 0. By running child first, after we spawn foo(0), the for loop from 1 through N will be pushed onto the work queue. Similarly, after we spawn foo(1), the for loop from 2 through N will be pushed onto the work queue. There will always be just one big piece of item in the work queue of thread 0. If we consider stealing when foo need a long time to process, the other threads will go grab the for loop all together instead of the individual child.

arkhan

By stealing the child, the new thread will not need to duplicate the original thread's stack and registers in order to continue. Instead, it will set up a new stack, which would need to be done anyway.

ufxela

what if you had code like ``` bar(){

} foo(){

}

Please log in to leave a comment.