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
Question: (a) Write down short notes on the different versions of Windows server 2003 mentioned below: 1. Windows Server 2003, Web Edition 2. Windows Server 2003, Stand

Why is it not possible to enforce memory protection at compile time?   Every process should be protected against unwanted interference by other process, whether intentional or

What is an acyclic graph? A tree that has been corrupted by links to other branches, but does not have any cyclic paths in it.

People arrive at a barber shop at the rate of one every 4.5 minutes. If the shop is full (it can hold five people altogether), 30% of the potential customers leave and come back i

The following information is available for three MPS (Master Product Scheduling) items: Product A                            An 80 unit order is to be started in Week 3.

Q. Timers could be utilized to compute the current time. Provide a little description of how this could be accomplished. Answer: A program could utilize the following ap

Interrupts The hardware mechanism that enables a device to inform the CPU is called an interrupt. The basic interrupt mechanism works as follows. The CPU hardware has a wire kn

Write in brief on UNIX file structure. UNIX considers every file to be a sequence of 8-bit bytes no interpretation of these bits is made by the operating system. This system pr

I am not getting what you have tried to describe here. Can you elaborate more about this, i will be thankful to you. Vinay

? FREE ASSOCIATION ASSIGNMENTS of multiprograming