From 37da2899f40661e3e9631e497da8dc59b971cbd0 Mon Sep 17 00:00:00 2001 From: "Charles.Forsyth" Date: Fri, 22 Dec 2006 17:07:39 +0000 Subject: 20060303a --- appl/lib/lock.b | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 appl/lib/lock.b (limited to 'appl/lib/lock.b') diff --git a/appl/lib/lock.b b/appl/lib/lock.b new file mode 100644 index 00000000..8b51e4f9 --- /dev/null +++ b/appl/lib/lock.b @@ -0,0 +1,26 @@ +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() +{ +} -- cgit v1.2.3