Using continuations, we also can recreate various concurrency primitives in simulation time. As an example, we construct the Channel primitive from Hoare's Communicating Sequential Processes (CSP) language [9]. Other primitives, such as threads, locks, semaphores, barriers, monitors, FIFOs, etc., can readily be built either atop Channels, or directly within the kernel.
As shown in Figure 14, the CSP channel blocks on the first receive (or send) call and stores the continuation. When the matching send (or receive) arrives, then the data item is transferred and control returns to both callers. A JiST channel is created via the createChannel system call. It supports both the CSP semantics, as well as non-blocking sends and receives.