On Wednesday 07 March 2007 19:44, Stavros Passas wrote: > Tzahi Fadida wrote: > > Hi, > > I am reading ldd3 and i am trying to understand how a circular buffer > > without locking works. > > If there is one writer and multiple readers. The writer has a pointer to > > head. the readers each have a pointer of their own to tail. Assumming the > > head can't circle on the tail in time, everything is peachy. > > However, in ldd3 the readers are sharing the tail pointer, how can this > > be alright? (See the code in ldd3->interrupt handling->Implementing a > > handler) At the very least you should somehow atomically grab the tail > > into a local var and also atomically increase the tail position all in > > one go so you won't get a race condition. > > Hello Tzahi, > this code is just a sample of who interrupt handlers works, > it doesn't guarantee anything about concurrency. Ok, 10x. However, just to make sure. If all the readers have their own tail then there is no problem right? If they want to share the tail, they have to use locking right? Moreover, i was wondering if when i code the following: count = head - tail. Can i say for sure that the head itself will not be corrupted while calculating? i.e. if it was 0xffffffff and it is being concurrently changed to 0xeeeeeeee i won't get a head variable in the calculation that contains 0xeeeeffff? If it does that i don't know if it is even safe with one writer and one reader... -- Regards, Tzahi. -- Tzahi Fadida Blog: http://tzahi.blogsite.org | Home Site: http://tzahi.webhop.info WARNING TO SPAMMERS: see at http://members.lycos.co.uk/my2nis/spamwarning.html -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx Please read the FAQ at http://kernelnewbies.org/FAQ