Date: Mon, 25 Sep 2000 03:18:12 +0000 (GMT) From: Terry Lambert <tlambert@primenet.com> To: arch@FreeBSD.ORG Subject: Re: Mutexes and semaphores Message-ID: <200009250318.UAA04938@usr05.primenet.com> In-Reply-To: <200009241833.LAA00463@vashon.polstra.com> from "John Polstra" at Sep 24, 2000 11:33:23 AM
next in thread | previous in thread | raw e-mail | index | archive | help
> There are plenty of reasonable situations where you have a block of > code (say, a function) and a certain mutex needs to be locked while > it executes. The function might be called from several different > places. Maybe all of the call sites already hold the mutex, and > maybe they don't. Maybe it is hard to say for sure. Maybe new calls > will be added in the future which will add further uncertainty. With > recursive mutexes you can make the code robust by locking the mutex > inside the called function. This robustness is certain and it is > independent of what is going on in the rest of the system. This is evil. You are using a mutex to protect code, when you should be using it to protect data. If you want to protect code, you should use a semaphore, instead. Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200009250318.UAA04938>