From owner-freebsd-hackers Fri Jan 31 12:33:39 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id MAA10593 for hackers-outgoing; Fri, 31 Jan 1997 12:33:39 -0800 (PST) Received: from sendero.i-connect.net ([206.190.144.100]) by freefall.freebsd.org (8.8.5/8.8.5) with ESMTP id MAA10575 for ; Fri, 31 Jan 1997 12:33:34 -0800 (PST) Received: (from shimon@localhost) by sendero.i-connect.net (8.8.5/8.8.4) id NAA15046; Fri, 31 Jan 1997 13:32:17 -0800 (PST) Message-ID: X-Mailer: XFMail 1.1-alpha [p0] on FreeBSD Content-Type: text/plain; charset=iso-8859-8 Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: Date: Fri, 31 Jan 1997 13:27:44 -0800 (PST) Organization: iConnect Corp. From: Simon Shapiro To: "Ron G. Minnich" Subject: Re: Re(2): Using rfork() / threads Cc: freebsd-hackers@FreeBSD.ORG, Andrew.Gordon@net-tel.co.uk Sender: owner-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk So where is this fantastic code? Simon Hi Ron G. Minnich; On 31-Jan-97 you wrote: > well, i have another thing that was (ah well) offered to freebsd called > fastlock(). Fastlock was two things: > 1) test and set, which ran at memory bandwidth > 2) a system call to be called only if the lock failed, > which ran at system call speeds. > > Fastlock is called with a pointer to shared data. In the general case > locks do not collide. So the cost of fastlock is the cost of a tset. In > the case of collision, the high-order bit was set (tset(mem, 0x80000000) > and the fastlock system call was called. The process waiting on the lock then > slept. > > The owner of the lock can do one of two things when it frees the lock: > 1) if no collide (mem&0x80000000 == 0), just clear the lock > 2) otherwise, clear the lock and call a system call which wakes up the first > sleeper on the lock. > > End result: very very fast locks, quite a bit faster than anything else. > > ron > > Ron Minnich |"Failure is not an option" -- Gene Kranz > rminnich@sarnoff.com | -- except, of course, on Microsoft products > (609)-734-3120 | > ftp://ftp.sarnoff.com/pub/mnfs/www/docs/cluster.html > >