Mabaloo Forum
Welcome, Guest
Please Login or Register.    Lost Password?
The Reader Writer Problem (0 viewing) 
Go to bottom Post Reply Favoured: 0
TOPIC: The Reader Writer Problem
#18
deepesh (User)
Fresh Boarder
Posts: 6
graphgraph
User Offline Click here to see the profile of this user
The Reader Writer Problem 8 Months, 4 Weeks ago Karma: 0  







The readers-writers problem is one of the very well known problems in concurrency theory. It was first introduced by Courtois et.al. in 1971 and requires the synchronization of processes trying to read and write a shared resource. Several readers are allowed to access the resource simultaneously, but a writer must be given exclusive access to that resource.

A data _object_ is to be shared among several concurrent processes. Some of these processes may want to only to read the content of the shared _object_, whereas others may want to update the shared _object_. We distinguish between these two types of processes by referring to those processes that are interested in only reading as readers, and to the rest as writers. Obviously, if two readers access the shared data _object_ simultaneously, no adverse effects will result.

The readers-writers problem has several variations, all involving priorities.

The simplest one, referred to as the first readers-writers problem, requires that no reader will be kept waiting unless a writer has already obtained permission to use the shared _object_.

The second readers-writers problem requires that, once a writer is ready, that writer performs its write as soon as possible.

The First
At a given time, there is only one writer and any number of readers. When a writer is writing, the readers can not enter into the resource or _object_. The readers need to wait until the writer finishes to write on the resource or _object_. Once a reader succeed in reading the resource or _object_, subsequent readers can enter into the critical section (in this case, say, resource or _object_) without waiting for the precedent reader finish to read. On the other hand, a writer who arrives later than the reader who is reading currently is required to wait the last reader finish to read. Only when the last reader finish reading, the writer can enter into the critical section and is able to write on the resource or _object_. This is also called readers-preference.

This solution is suboptimal, because it is possible that a reader R1 might be reading when a writer W be waiting to write, and then a reader R2 request access. It would allow R2 to jump in immediately, ahead of W; if that happened often enough, W would starve.

The Second
It is the same as the first reader writer problem except for the constraint that no writer, once added to the queue, shall be kept waiting longer than absolutely necessary. This is also called writers-preference.

This solution also leads to starvation for the readers, since when a writer W is writing it won’t allow any readers to read and if another writer W¬2 requests to write after a reader say R1 then it would enter the queue before R1. Thus leading to the starvation of readers.

 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
      Topics Author Date
    emo
The Reader Writer Problem
deepesh 2008/03/07 23:34
    thread link
thread linkthread link Re:The Reader Writer Problem
deepesh 2008/03/07 23:37
Go to top Post Reply
Powered by FireBoardget the latest posts directly to your desktop



User Login


Links


Privacy Notice | Advertising Info | Feedback | Contact Us | Partners

The information and views presented above are by the author. Mabaloo.com does not take any gurantee of accuracy.
The views expressed above are that of the author and in no way related to mabaloo.com
Highlite It
© 2007 @ mabaloo.com.