Date: Thu, 17 Jul 2003 23:24:27 -0400 From: Mike Makonnen <mtm@identd.net> To: John Baldwin <jhb@FreeBSD.org> Cc: cvs-all@FreeBSD.org Subject: Re: cvs commit: src/sys/kern kern_umtx.c src/sys/sys proc.h Message-ID: <20030718032426.GA6689@kokeb.ambesa.net> In-Reply-To: <XFMail.20030717130258.jhb@FreeBSD.org> References: <20030717145707.GA2205@kokeb.ambesa.net> <XFMail.20030717130258.jhb@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Jul 17, 2003 at 01:02:58PM -0400, John Baldwin wrote: > > > Initially I was going to do it this way. But there were a couple of > > things that concerned me so I thought it would be safer to implement > > it the way I did. One of them is that it opens up a race between a > > thread that is trying to acquire the umtx for the first time, and the > > thread that the unlocker just woke up. I suppose we could introduce > > a UMTX_RESERVED or something (UMTX_UNOWNED is already used) that no > > one except a thread that just woke up could lock. Is that what you > > are suggesting? > > There is no race there. If both threads want the lock, one will > suceed and the other will block on it and have to mark the lock as > contested. This is how that works with the kernel mutexes. This > does mean that you need to loop in the umtx_lock() function in the > kernel and that you need to allow for the fact that you may be > trying to acquire an uncontested, unowned mutex. Ahh ok, the current code is fine then (it takes care of the looping, etc). I was under the impression that locks were a first-come first-served deal. Otherwise, there's the unlikely-but-not-zero possibility of thread starvation. But, this may be a misconception on my part. In anycase, I'll take your suggestion and move the unseting into the unlock code. I may end up having to revise everything when I fix mutex priorities, but I'll cross that bridge when I get to it. Cheers. -- Mike Makonnen | GPG-KEY: http://www.identd.net/~mtm/mtm.asc mtm@identd.net | D228 1A6F C64E 120A A1C9 A3AA DAE1 E2AF DBCC 68B9 mtm@FreeBSD.Org| FreeBSD - Unleash the Daemon!
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030718032426.GA6689>