From owner-freebsd-hackers Mon Feb 3 15:55:37 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id PAA28770 for hackers-outgoing; Mon, 3 Feb 1997 15:55:37 -0800 (PST) Received: from parkplace.cet.co.jp (parkplace.cet.co.jp [202.32.64.1]) by freefall.freebsd.org (8.8.5/8.8.5) with ESMTP id PAA28763 for ; Mon, 3 Feb 1997 15:55:29 -0800 (PST) Received: from localhost (michaelh@localhost) by parkplace.cet.co.jp (8.8.5/CET-v2.1) with SMTP id XAA13730 for ; Mon, 3 Feb 1997 23:55:23 GMT Date: Tue, 4 Feb 1997 08:55:23 +0900 (JST) From: Michael Hancock To: freebsd-hackers@FreeBSD.ORG Subject: mset, mclear, msleep, mwakeup (was Re: Using rfork() / threads) In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk On Mon, 3 Feb 1997, Ron G. Minnich wrote: > On Sat, 1 Feb 1997, Michael Hancock wrote: > > The Vahalia book mentions shared memory locks for 4.4BSD that worked > > essentially the same way. They were named mset, mwait, or something like > > that. > > yeah, but recall that I did this stuff 9/94. mset etc. were not around > then, and appear to still not be. > > > Fastlock sounds cool, but shared memory locks are supposed to be fast. > It's a bit more complex than shared memory locks. The problem is making > shared memory locks between heavyweight processes that are efficient and > in particular never do a system call unless needed. > > > I prefer the mxxx conventions to categorize it with the > > mmap calls. > > works for me. > This is how Vahalia describes it. On the newsgroups John Dyson said he remembers seeing a document in 4.4Lite somewhere describing it. Can you work with these interfaces? Maybe you can submit them to John for review or colloborate with him on rewriting it. mset() and mclear() must be user level functions on architectures that have atomic test-and-set. You don't do a system call unless necessary. value = mset(sem, wait); sem is a pointer to a semaphore value wait is a boolean that is set to true if you want to block value is zero if the semaphore has been acquired mclear(sem); If you want to block and unblock use the following: msleep(sem); mwakeup(sem); Wakes up at least one process blocked on this semaphore or does nothing if there are no blocked semaphores. Regards, Mike Hancock