[plt-scheme] semaphore-value
I already built a semaphore struct-type containing a mzscheme's semaphore and a
counter together with a separate semaphore for protection of the counter
increments and decrements. The code is complicated because a dead lock is easily
produced and I am not yet sure I did prevent all possibilities of dead locks. I
do see how semaphore-wait can be used to obtain the a guess of the current value
of the counter, but I don't want procedure semaphore-counter to decrement the
counter down to zero, for this may unnnecessarily block other threads.
Furthermore this seems a lot of work for something that can be done in a few
processor cycles at the bottom level of MzScheme. The counter is already around
somewhere. Why should I have to duplicate it? ::::))))
Thanks, Jos Koot
----- Original Message -----
From: "Chongkai Zhu" <czhu at cs.utah.edu>
To: "Jos Koot" <jos.koot at telefonica.net>
Cc: "PLT-list" <plt-scheme at list.cs.brown.edu>
Sent: Wednesday, July 25, 2007 4:47 PM
Subject: Re: [plt-scheme] semaphore-value
> You can build your own on top of `semaphore-try-wait?'.
>
> Chongkai
>
> Jos Koot wrote:
>> Hi
>> A question: Is there a reason for not providing a procedure like
>> (semaphore-count sema) --> current value of the semaphore counter? It seems
>> rather easy to implement, but I rather like not to poke in MzScheme's C code
>> (sema.c). Of course the returned value may be outdated by the time it is
>> returned, but that's no problem.
>> Greetings, Jos Koot.
>
>