[comp.arch] Semaphores without Test&Set instruction

david@indetech.com (David Kuder) (02/28/90)

Some while ago there was some discussion in this news group
about implementing semaphores on machines that did not have
an atomic test and set instruction.  I read the discussion
with some interest but since I had no need for the
algorithm it went into the bit-bucket.

Now I suddenly find myself going from "zero" to "many" on
the "zero, one, many" counting scale.  So rather than
extract a work around from a single vendor I thought I'd
seek out the general solution.  A quick scan of the
references that I have at hand didn't scare up the
algorithm.  Finally, the request:  what is a reference that
gives the algorithm or what does the psuedo code for the
algorithm look like?  E-mail answers and I'll summarize.

Thanks in advance,
-- 
David A. Kuder                                               Now what coach?
415 438-2003  david@indetech.com  {uunet,sun,sharkey,pacbell}!indetech!david

lm@snafu.Sun.COM (Larry McVoy) (03/01/90)

In article <1990Feb28.014717.16596@indetech.com> david@indetech.com (David Kuder) writes:
>Some while ago there was some discussion in this news group
>about implementing semaphores on machines that did not have
>an atomic test and set instruction.  I read the discussion
>with some interest but since I had no need for the
>algorithm it went into the bit-bucket.

I missed the discussion, so maybe this has been pointed out already:
be careful of using an algorithm that depends on the order of memory
stores (like Dekker's).  Current and future machines have this nasty
habit of reordering the stores w/o your knowledge.  They typically
provide some way for you to say "flush everything before letting the 
next store go out" but they don't (can't) detect when you need this
and do it for you.
---
What I say is my opinion.  I am not paid to speak for Sun, I'm paid to hack.
    Besides, I frequently read news when I'm drjhgunghc, err, um, drunk.
Larry McVoy, Sun Microsystems     (415) 336-7627       ...!sun!lm or lm@sun.com