Messages in this thread | | | Date | Thu, 19 Apr 2001 14:24:09 -0400 (EDT) | From | Alexander Viro <> | Subject | Re: light weight user level semaphores |
| |
On Thu, 19 Apr 2001, Linus Torvalds wrote:
> > > On Thu, 19 Apr 2001, Alexander Viro wrote: > > > > Ehh... Non-lazy variant is just read() and write() as down_failed() and > > up_wakeup() Lazy... How about > > Looks good to me. Anybody want to try this out and test some benchmarks?
Ugh. It doesn't look good for me. s/MAX_INT/MAX_INT>>1/ or we will get into trouble on anything that goes into spin_and_lose. Window is pretty narrow (notice that lost_it is OK - we only need to worry about somebody coming in after winner drives Lock from 1 to 0 and before it gets it from 0 to MAX_INT), but we can get into serious trouble if schedule() will hit that window.
MAX_INT/2 should be enough to deal with that, AFAICS.
However, I would _really_ like to get that code reviewed from the memory access ordering POV. Warning: right now I'm half-asleep, so the thing can very well be completely bogus in that area. Extra eyes would be certainly welcome.
Al
PS: ->Lock should be set to 1 when we initialize semaphore. Destroying semaphore should do if (sem->Lock > 1) { close(sem->writer); close(sem->reader); }
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |