From owner-freebsd-hackers Sun Nov 10 19:39:12 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id TAA08944 for hackers-outgoing; Sun, 10 Nov 1996 19:39:12 -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 TAA08939 for ; Sun, 10 Nov 1996 19:39:06 -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 VAA17488; Sun, 10 Nov 1996 21:38:59 -0600 (CST) Received: by bio-5.bsd.uchicago.edu (5.0/SMI-SVR4) id AA13774; Sun, 10 Nov 1996 21:38:53 +0600 Date: Sun, 10 Nov 1996 21:38:53 +0600 Message-Id: <9611110338.AA13774@bio-5.bsd.uchicago.edu> To: scrappy@ki.net Cc: hackers@FreeBSD.ORG In-Reply-To: <9611100512.AA13579@bio-5.bsd.uchicago.edu> (message from Tim Pierce on Sat, 9 Nov 1996 23:12:27 +0600) Subject: Re: semaphores/shared memory From: Tim Pierce Sender: owner-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk I wrote: > > essentially, I want the server to write a line of data to > > shared memory, then signal all the clients at once that the data is > > there, so that they all pick up the data... > > It sounds like this ought to be easy if you simply have each > client wait on the semaphore, and then have the server increment > the semaphore by a suitably high number (e.g. MAXINT) in order to > ensure that they all are freed at once. 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.