Code Review
Compare your solutions
#| BEGIN (Write your solution here) |#
(define (make-semaphore n)
(let ((count n)
(count-mutex (make-mutex)))
(define (the-semaphore m)
(cond ((eq? m 'acquire)
(count-mutex 'acquire)
(if (> count 0)
(begin
(set! count (- count 1))
(count-mutex 'release))
(begin
(count-mutex 'release)
(the-semaphore 'acquire))))
((eq? m 'release)
(count-mutex 'acquire)
(if (= count n)
(count-mutex 'release)
(begin
(set! count (+ count 1))
(count-mutex 'release))))
((eq? m 'count)
count)))
the-semaphore))
#| END |#