Read-write locks, Operating System

Consider a large web-based database. In some sense, Google is sort of like this. There might be many users who want to read from the database, but only a few users who are allowed to write to the database. If we use standard locks to control access to the database, the application will be much slower than it could be with a more clever type of lock.

Suppose we have one object that is shared among several threads. Suppose also that each thread is either a reader or a writer. Readers only read data but never modify it, while writers read and modify data. If we know which threads are reading and which ones are writing, what can we do to increase concurrency?

First, we have to prevent two writers from writing at the same time. In addition, a reader cannot read while a writer is writing. There is no problem, however in allowing lots of readers to read at the same time. Read-write locks achieve this, and can greatly improve performance for this sort of application.

Note that the lock is the same for both readers andwriters (called 'rw' in the slides), but the readers use an rlock() on the lock and writers use a wlock() on the same lock. Writers requesting a wlock() will have to wait until all readers and writers have released the lock. Readers requesting a rlock() can acquire it even if other readers are holding the lock. Readers however will still have to wait until any writer holding the lock releases the lock.

Posted Date: 3/12/2013 5:28:34 AM | Location : United States







Related Discussions:- Read-write locks, Assignment Help, Ask Question on Read-write locks, Get Answer, Expert's Help, Read-write locks Discussions

Write discussion on Read-write locks
Your posts are moderated
Related Questions
Explain the concept of Reentrancy? It is a useful, memory-saving method for multiprogrammed timesharing systems. A Reentrant Procedure is one in which many users can share a si

The primary financial objective of corporation is usually taken to be the maximization of shareholder wealth. Discuss:- i. Ways in which the shareholder of a company can encour

What are the different types of semaphore? Principally the semaphore is able to be classified into two on the basis of their values a)      Counting semaphore: In counting s


What are the various process scheduling concepts? a) Scheduling queues with diagram b) Queuing diagram c) Schedulers d) Context switch with diagram

What is a file? A named collection of related data explained by the creator, recorded on secondary storage.

Q. Consider a calculating environment where a process is given the privilege of accessing object only n times. Suggest a scheme for implementing this policy. Answer: Add an i

Q. Compare the utilization of networking sockets with the use of shared memory as a mechanism for communicating data between processes on a single computer. What are the merits of

Explain Components of conflict phase of dispatch latency The conflict phase of dispatch latency has two components 1. Preemption of any process running in the kernel. 2.

Define Enforcing Modularity for C Additionally, in C it is sometimes necessary to create modularity of design. C++  is very natural model for component based application design