Hi, The read-write spinlocks are for the purpose of increasing concurrency by keeping many reader in critical sections at a time. But the writer takes exclusive lock and its lock is granted only when neither reader nor writer exist in the critical region. This only may leads to starvation of writer in case where reader may always grab a lock and writer is pending just because always there is reader in critical section. Prasanna --- Gaurav Dhiman <gaurav4lkg@xxxxxxxxx> wrote: > Hi, > > I read the document related to spinlocks in > Documentation directory of > kernel sources. Actually that doc is the reply from > Linus to someone's > query on mailing list. > After reading that, I have a question related to > read-write spinlocks: > > - As said in that document (Lesson 2 in that > document), if we use > read-write spinlocks, many readers can be in > critical section at same > time, but only one writer can be there in critical > section. Does this > mean, a situation like where one writer and many > readers can be in > critical section at same time, if yes, wont this > lead to a problamatic > situation as follows. Lets say we have a read-write > spinlock on linked > list and there are many reader traversing it and one > writer updating > it. If one reader is on a particular node and at the > same time that > node is deleted by the writer running on another CPU > and it frees the > node memory, wont the reader reading that node on > other CPU put the > system to crash ? > I think if we allows the writer to be in critical > section, no one else > (not even readers) should be allowed there in > critical section, > because writer may effect what the reader are > reading and a situation > like above (if I am correct) can lead to crashes. > > Please correct me whereever I am wrong. > > -gd > > -- > Kernelnewbies: Help each other learn about the Linux > kernel. > Archive: > http://mail.nl.linux.org/kernelnewbies/ > FAQ: http://kernelnewbies.org/faq/ > > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/