
310 Introduction to Concurrency in Programming Languages
C.2 Cilk model
Cilk is based on a concept known as work stealing. Given a set of processors,
the Cilk runtime maintains a queue of threads assigned to each processor
that have been created that are waiting to execute. As work units (threads)
are completed on each processor, the next unit in the processor’s queue is
executed. When the queue that is associated with a processor is exhausted, the
Cilk runtime will prevent the processor from sitting idle by stealing pending
jobs from other processors that still have non-empty queues. The choice of
processor to steal work from is random.
Threads that ...