Код Ревью

Сравни свои решения

    (define (make-semaphore n)
  (define count n)

  (define (test-and-set!)
    (if (> count 0)
        (begin
          (set! count (- count 1))
          #f)
        #t))

  (define (release!)
    (if (< count n)
        (set! count (+ count 1))
        #t))

  (define (semaphore m)
    (cond
      [(eq? m 'acquire)
       (when (test-and-set!)
         (semaphore 'acquire))]
      [(eq? m 'release) (release!)]
      [(eq? m 'count) count]
      [else (error "Wrong message")]))

  semaphore)