Previous: , Up: Multitasker   [Contents][Index]


6.26.2 Cilk

Cilk is an extension to C-like languages, and centers around the functions spawn and sync. cilk.fs extends Forth in such a way, using workers and queues to implement this.

cilk-sync ( ) cilk “cilk-sync”

wait for all spawned tasks to complete

spawn ( xt –  ) cilk “spawn”

wait for a worker to become free, and spawn xt there

spawn1 ( n xt –  ) cilk “spawn1”

wait for a worker to become free, and spawn xt there, with one argument

spawn2 ( n1 n2 xt –  ) cilk “spawn2”

wait for a worker to become free, and spawn xt there, with two arguments

spawn-closure ( xt –  ) cilk “spawn-closure”

for passing a heap closure: execute and free it. This allows to pass all sorts of arguments to code. Usage [{: vars :}h code ;] spawn-closure ;

cilk-init ( ) cilk “cilk-init”

Start the workers if not already done

cilk-bye ( ) cilk “cilk-bye”

kill all workers