[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-kernel
Subject:    Re: [Patch] shm bug introduced with pagecache in 2.3.11
From:       "Benjamin C.R. LaHaise" <blah () kvack ! org>
Date:       1999-11-21 1:12:35
[Download RAW message or body]

On Sat, 20 Nov 1999, Manfred Spraul wrote:

> I give it up:
> I've attached 2 more ideas, but one of them is a bit slow, and the other
> one requires cmpxchg (ie only 486 and above).

Interesting.  Here's what I'm doing (it's subtle, but cute and efficient 
-- 1 instruction and an untaken branch for both readers and writers):

count is initially set to a BIAS (I'm using 0x01000000).  Readers
decrement count by 1 and see a positive value if successful.  Writers
decrement by the BIAS and see a result of zero when acquired. 

This makes the recovery case a bit more challenging, but easily solved
with a second value used to decide who is the next writer (and thus
responsible for maintaining the bias while waiting).

		-ben


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic