Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 11 Nov 1996 10:56:51 +0600
From:      Tim Pierce <twpierce@bio-3.bsd.uchicago.edu>
To:        scrappy@ki.net
Cc:        hackers@FreeBSD.ORG
Subject:   Re: semaphores/shared memory
Message-ID:  <9611111656.AA13857@bio-5.bsd.uchicago.edu>
In-Reply-To: <Pine.NEB.3.95.961111054151.10127G-100000@quagmire.ki.net> (scrappy@ki.net)

next in thread | previous in thread | raw e-mail | index | archive | help
"Marc G. Fournier" <scrappy@ki.net> wrote:

> I wrote:
>
> > No, sorry, even this shouldn't be necessary.  Have the server
> > create the semaphore and increment its value to 1.  Then have each
> > client wait until the semaphore becomes 0.  When the data has been
> > written to shared memory, have the server decrement the semaphore
> > to zero, which will unblock all of the clients.
> 
> 	Okay, now bearing in mind that I'm looking at the examples as
> presented in "Unix Network Programming" by W. Richard Stevens...how
> do n clients signal back to the server that its finished with the data
> and can send up the next set of data?

Now the model is reversed: the clients possess a resource that the
server needs to wait for.  Have the server wait on the semaphore
until its value becomes equal to `n' (where n is the number of
clients).  Each client, when it finishes using the shared memory,
increments the semaphore; when they are all done, the semaphore's
value will equal `n' and the server will unblock.  This looks
straightforward from my reading of Stevens.




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?9611111656.AA13857>