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
SEGMENTATION HARDWARE An execution to map two-dimensional user-defined addresses into one-dimensional physical addresses. This mapping is affected by means of segment table. Ev

What are batch systems? Batch systems are quite appropriate for implementing large jobs that need little interaction. The user can submit jobs and return later for the results.

Q. More than one disk drive is able to be attached to a SCSI bus. Especially a fast wide SCSI-II bus can be connected to at most 15 disk drives. Remember that this bus has a bandw

Placement algorithms :calculate where in available real-memory to execute a program. Common functions are next-fit, first-fit, and best-fit. Replacement algorithms :are

What are the advantages and disadvantages of multithreading?  Advantages : Since by multithreading multiple executions are carried out in the same process environment t

What is the Translation Lookaside Buffer (TLB) In a cached system, the base addresses of the last few referenced pages is maintained in registers known as the TLB that aids in

Sir i want formulas in Memory management starting from paging till the demang paging in a easy manner for solving problems in competitive exams

An operating system act as an intermediary between user of a computer and computer hardware. The objective of an operating system is to provide an environment in that a user can ex

Question: a) The following questions refers to Windows XP networking: i) Briefly, explain how a host joins a network using DHCP? ii) Which IP address could be assigned to a

When we download a movie from the Internet, we don't care about, say, packet sizes. However, even ifwe are not aware of howlow-level details of networks are implemented, our data i