Re: msleep() on recursivly locked mutexes
- From: Robert Watson <rwatson@xxxxxxxxxxx>
- Date: Sat, 28 Apr 2007 10:52:16 +0100 (BST)
On Thu, 26 Apr 2007, Julian Elischer wrote:
Further the idea that holding a mutex "except for when we sleep" is a generally bright idea is also a bit odd to me.. If you hold a mutex and release it during sleep you probably should invalidate all assumptions you made during the period before you slept as whatever you were protecting has possibly been raped while you slept. I have seen too many instances where people just called msleep and dropped the mutex they held, picked it up again on wakeup, and then blithely continued on without checking what happened while they were asleep.
And interesting observation here is that FreeBSD 4.x and earlier were actually rife with exactly this sort of race condition, exercised only when under kernel memory pressure because sleeping occurred only then. The explicit locking model we use now makes these races larger due increased concurrency (preemption, parallelism, etc), but also makes our assertion model stronger.
Robert N M Watson
Computer Laboratory
University of Cambridge
_______________________________________________
freebsd-hackers@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@xxxxxxxxxxx"
- References:
- msleep() on recursivly locked mutexes
- From: Hans Petter Selasky
- Re: msleep() on recursivly locked mutexes
- From: Julian Elischer
- msleep() on recursivly locked mutexes
- Prev by Date: Re: Re: msleep() on recursivly locked mutexes
- Next by Date: Re: msleep() on recursivly locked mutexes
- Previous by thread: Re: msleep() on recursivly locked mutexes
- Next by thread: Re: msleep() on recursivly locked mutexes
- Index(es):
Relevant Pages
- Re: How do I ensure only one version of my executable is running
... simultaneously started, check for the mutex, see it's not there, and ... your
mutex solution does not have a race condition. ... But the shared data segment solution
can also be coded that way. ... find the window for Instance 1. ... (microsoft.public.vc.mfc) - Re: thread::mutex lock problem, a bug?
... there is again an race condition there. ... So in your Thread2 and Thread3,
locking of the mutex can be ... cond variable w/o locking the mutex before. ...
(comp.lang.tcl) - Re: Select system call
... the same descriptor and the same operation? ... didn't it could lead a race
condition? ... i think you need a semaphore or a mutex. ... (comp.unix.programmer)