[plt-scheme] thread-suspend/thread-resume versus semaphores

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Mon Aug 22 21:18:46 EDT 2005

At Tue, 23 Aug 2005 00:33:48 +0200, Jens Axel Søgaard wrote:
> An alternative would be to introduce a semaphore, and let
> the critical regions raise/lower the semaphore and only allow
> the will-executor to run when the semaphore is down.
> 
> 
> My question is now, whether the thread-suspend/thread-resume approach
> is just as efficient as a semaphore solution would be?

I recommend using a semaphore. It will be efficient and reliable.

Suspending the thread won't do anything in this case, as far as I can
tell. A critical section might be entered after `root-unreg' runs and
before `root-id' runs; suspending the thread prevents starting a new
will, but not interrupting this particular will. Meanwhile, I imagine
that `root-unreg' and `root-id' are already individually atomic, since
they're primitive.

Using a semaphore ensures that a critical region runs only between
complete wills.

Matthew



Posted on the users mailing list.