code: 9ferno

ref: 44ce0097b612a1fefd754065bdf8d9d2e5ef60c8
dir: /appl/lib/lock.b/

View raw version
implement Lock;

include "sys.m";
	sys:	Sys;
include "lock.m";

Semaphore.obtain(l: self ref Semaphore)
{
	l.c <-= 0;
}

Semaphore.release(l: self ref Semaphore)
{
	<-l.c;
}

Semaphore.new(): ref Semaphore
{
	l := ref Semaphore;
	l.c = chan[1] of int;
	return l;
}

init()
{
}