From owner-freebsd-hackers Tue Jan 5 15:49:08 1999 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id PAA03659 for freebsd-hackers-outgoing; Tue, 5 Jan 1999 15:49:08 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from ns.mt.sri.com (sri-gw.MT.net [206.127.105.141]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id PAA03652 for ; Tue, 5 Jan 1999 15:49:05 -0800 (PST) (envelope-from nate@mt.sri.com) Received: from mt.sri.com (rocky.mt.sri.com [206.127.76.100]) by ns.mt.sri.com (8.8.8/8.8.8) with SMTP id QAA18673; Tue, 5 Jan 1999 16:48:21 -0700 (MST) (envelope-from nate@rocky.mt.sri.com) Received: by mt.sri.com (SMI-8.6/SMI-SVR4) id QAA10896; Tue, 5 Jan 1999 16:48:20 -0700 Date: Tue, 5 Jan 1999 16:48:20 -0700 Message-Id: <199901052348.QAA10896@mt.sri.com> From: Nate Williams MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: Wes Peters Cc: Nate Williams , Terry Lambert , narvi@haldjas.folklore.ee, bright@hotjobs.com, hackers@FreeBSD.ORG Subject: Re: question about re-entrancy. In-Reply-To: <3692A39C.889BF032@softweyr.com> References: <199901052008.NAA09332@mt.sri.com> <199901052245.PAA24981@usr02.primenet.com> <199901052249.PAA10421@mt.sri.com> <3692A39C.889BF032@softweyr.com> X-Mailer: VM 6.34 under 19.16 "Lille" XEmacs Lucid Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > > > > > The third way (about which Terry did talk) is to have locks around > > > > > critical sections. > > > > > > > > That *is* what an 'object lock' in RTEMS is. > > > > > > No. An object lock is associated with an object. A critical section > > > lock is associated with a section of code. > > > > An object lock can be associated with a lock that does nothing but > > associate itself with a critical section. > > This type of object is generally known as a "semaphore." Right, I mentioned this in an early article. > > *sheesh* This ain't rocket science. > > No, and the problems Terry brings up are real, but only because designers > have made them real. One of the biggest problems with object-locking > systems is the serial acquisition of locks. Say for instance I want to > transfer some data from one device to another, and I don't want to add > the overhead of buffering it in memory. I acquire the read-lock on the > first device, then acquire the write-lock on the second. Once both locks > have been acquired, I can transfer the data and release the locks. Can you say potential 'deadlock'? I knew you could. :) > The problem with this model, which is commonly used, is that I hold the > read-lock on the first device while waiting to acquire the write-lock > on the second, or vice versa. A parallel waiting system, in which another > potential reader of the first device can "take away" my lock if I'm still > pending for another resource, alleviates this problem. You have to avoid > priority problems when doing this, but inherited priorities are a pretty > well understood solution to this problem. Right. So how else do you solve the problem of 'protecting' critical sections? I don't see how else to protect them other than using 'object locks' (however you want to call them). If you have multiple shared resources, you still need to get access to them. One of the more common ways I've seen this done is through a 'resource manager' inside of the kernel which guarantees that you 'lock down' the resources in exactly the same order. Unfortunately, this tends to be a bottleneck on highly parallel systems. ;( Nate To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message