From owner-freebsd-hackers Mon Nov 11 08:57:01 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id IAA25542 for hackers-outgoing; Mon, 11 Nov 1996 08:57:01 -0800 (PST) Received: from delphi.bsd.uchicago.edu (delphi.bsd.uchicago.edu [128.135.5.5]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id IAA25537 for ; Mon, 11 Nov 1996 08:56:59 -0800 (PST) Received: from bio-5.bsd.uchicago.edu (bio-5.bsd.uchicago.edu [128.135.75.14]) by delphi.bsd.uchicago.edu (8.7.6/8.7.3/BSD-4.0) with SMTP id KAA07022; Mon, 11 Nov 1996 10:56:57 -0600 (CST) Received: by bio-5.bsd.uchicago.edu (5.0/SMI-SVR4) id AA13857; Mon, 11 Nov 1996 10:56:51 +0600 Date: Mon, 11 Nov 1996 10:56:51 +0600 Message-Id: <9611111656.AA13857@bio-5.bsd.uchicago.edu> To: scrappy@ki.net Cc: hackers@FreeBSD.ORG In-Reply-To: (scrappy@ki.net) Subject: Re: semaphores/shared memory From: Tim Pierce Sender: owner-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk "Marc G. Fournier" 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.