>>258
exactly. ちなみに、共有リソースはこんな感じで。

open Event
type 'a mvar = { takeCh : 'a channel; putCh : 'a channel; ackCh : bool channel }
exception Put

let mVar () =
let takeCh = new_channel () and putCh = new_channel () and ackCh = new_channel () in
let rec empty () =
let x = sync (receive putCh) in
sync (send ackCh true);
full x
and full x =
select [
wrap (send takeCh x) empty;
wrap (receive putCh) (fun _ -> sync (send ackCh false); full x)
]
in
ignore(Thread.create empty ());
{ takeCh = takeCh; putCh = putCh; ackCh = ackCh }

let take { takeCh = takeCh } = receive takeCh

let put { putCh = putCh; ackCh = ackCh } x =
sync (send putCh x);
if sync (receive ackCh) then ()
else raise Put