What is the problem of readers-writers?

The problem of "Readers' problem" is the dilemma of programming created when more readers and writers need access to the same source. If they are allowed to access at once, there may be problems such as rewriting, incomplete information and other problems. Therefore, programmers can limit access to checking which processing fibers see the source and when with respect to the needs of the system and users. There are several ways to solve the problem of readers-writers. One of the most common solutions includes the use of traffic lights to indicate status and condition control.

In one point, any number of readers could safely access the source because they did not change the content. Once the writer enters the equation, the situation becomes more complicated. If the thread writes while reading other threads, readers may not get the right information. They could only receive a part of the change, or could see outdated information and think they were accurate.

The problem could also create more than one writer. WITHOu time changes of the same content could rewrite it and create other errors. As part of the readers' problem, programmers must decide whether readers or writers have a priority and how to manage access. Readers or writers could be assigned a priority, or the system could assign access on the basis of the first arrival, first serve. This third solution can prevent long waiting, but could come up with its own problems.

In a solution where readers have a priority, it assumes that every reader asking for access should be allowed first when access is available. This means that all writers who want access to the source might need to wait. On the contrary, the system can assume that since writers must make changes that could influence readers, they should be preferred in the readers' problem. When the reader is finished with the source, the writer could withto crush to make a change. This applies not only to user actions, such as attempting to store a document, but to internal processes inside a computer that keep the system in operation.

Another option allows readers of the readers to balance the needs of both sides, allowing each approach to processing the fiber on arrival. This prevents writers from making changes that suppress or confuse each other without leaving readers to wait, or forcing the writer to hold while the readers will end. Such priorities can be built into the software program or control access to the memory on the computer. Users can be able to make changes if they are convenient with programming and the system allows this.

IN OTHER LANGUAGES

Was this article helpful? Thanks for the feedback Thanks for the feedback

How can we help? How can we help?