From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27416 invoked by uid 1002); 22 Jul 2003 18:31:04 -0000 Mailing-List: contact gentoo-dev-help@gentoo.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@gentoo.org Received: (qmail 12037 invoked from network); 22 Jul 2003 18:31:04 -0000 From: Paul de Vrieze To: gentoo-dev@gentoo.org Date: Tue, 22 Jul 2003 20:30:57 +0200 User-Agent: KMail/1.5.2 References: In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg=pgp-sha1; boundary="Boundary-02=_lLYH/ydeUFAhg0d"; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200307222031.01286.pauldv@gentoo.org> X-Spam-Status: No, hits=-5.7 required=5.0 X-Spam-Level: X-Virus-Scanned: by amavisd-milter (http://amavis.org/) Subject: Re: [gentoo-dev] What is the fastest mechanism for ipc communication under the gentoo-sources kernel X-Archives-Salt: aae31cfa-0ae6-4fe4-bb01-41645d533cb4 X-Archives-Hash: 2bd173cafb325ceb1e03a51638da3250 --Boundary-02=_lLYH/ydeUFAhg0d Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Description: signed data Content-Disposition: inline On Tuesday 22 July 2003 19:07, Jeff Adams wrote: > Hello, > > I have a producer process that makes updates to shared memory. I need to > notify consumer processes (potentially multiple) as quickly as possible. > > What I am looking for is a fast "wake-up" mechanism and a synchronization > mechanism so that events are not lost. > > I'm currently using semaphores as the wake up mechanism. Question is this > the fastest way to do this without going into a tight loop (waste of > processor cycles)? > > I'd also have the issue of clients showing up asynchronously. If I just > use semaphores counts based on the number of clients I run the risk of > missing a client. Also if the clients process events too slowly then the > producer will keep incrementing the semaphore beyond the client count.=20 > Then if one client is faster than the others it may get awakened multiple > times for the same event. > > Any suggestions? > You could use pipes as IPC. In that case you push a byte in the pipe at the= =20 moment you want the clients to wake up. This should make them me scheduled = as=20 soon as possible (in case they are locked waiting for the pipe). Another wa= y=20 could be to use signals. But if you give each process a semaphore that shou= ld=20 also work. The only question is whether it is a problem if one process has = a=20 slightly higher chance to be first than the other processes. Normally it=20 isn't. Paul =2D-=20 Paul de Vrieze Researcher Mail: pauldv@cs.kun.nl Homepage: http://www.devrieze.net --Boundary-02=_lLYH/ydeUFAhg0d Content-Type: application/pgp-signature Content-Description: signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2 (GNU/Linux) iD8DBQA/HYLlbKx5DBjWFdsRAhPTAJsEsPWMELHpy7rU6ZNSOo4XG4eqyACguMh4 fK7LbovQ4elSHVltVPV91uY= =byXc -----END PGP SIGNATURE----- --Boundary-02=_lLYH/ydeUFAhg0d--