









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!










Choosing the next thread to run
Thread 1 print “start thread 1 ” yield() print “end thread 1 ” Thread 2 print “start thread 2 ” yield() print “end thread 2 ” Yield print “start yield (thread %d)” switch to next thread (swapcontext) print “end yield (current thread %d)
Parent() { thread_create print “parent work” print “parent cont” } Child() { print “child work” } Parent() { thread_create print “parent work” thread_yield print “parent cont” } Child() { print “child work” }
Join: wait for another thread to finish Parent() { thread_create lock print “parent works” unlock join print “parent cont” } Child() { lock print “child works” unlock }