*BSD News Article 53052


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!simtel!news.sprintlink.net!cs.utexas.edu!geraldo.cc.utexas.edu!brazile
From: brazile@math.utexas.edu (Jason Brazile)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: test&set? Semaphores?
Date: 19 Oct 1995 21:48:19 GMT
Organization: Department of Mathematics, University of Texas at Austin
Lines: 21
Message-ID: <466h33$elf@geraldo.cc.utexas.edu>
References: <460ivi$3j9@netnews.upenn.edu>
NNTP-Posting-Host: max.ma.utexas.edu

In article <460ivi$3j9@netnews.upenn.edu>,
Darrel Herbst <dherbst@gradient.cis.upenn.edu> wrote:
> What implementations are most commonly used for test&set on FreeBSD?

Someone already responded on how you can get a SYSTEM V style semaphore.
Using this and other SYSTEM V IPC is often overkill.

As far as I know, FreeBSD is still Intel x86 only so it is OK for me to
advise you to use the "xchg" instruction to write your own C-callable
test_and_set() in about 6 lines of assembly. I would also advise that
you look at shared memory via mmap() MAP_SHARED as opposed to SYSTEM V
shared memory - if you can live with its requirement on the ancestry
of your processes.

Richard Steven's "Advanced Programming in the UNIX Environment" is
a good book.

---
Jason Brazile 					brazile@math.utexas.edu
"People say I'm apathetic but I don't care" 	University of Texas