SlideShare a Scribd company logo
1 of 4
OPERATING
SYSTEM
October 10
2012
PROJECT REPORT : READER/WRITER SOLUTION
Submitted to
Sir Raazi
Made by
Shahzeb Pirzada
Bariq Qadri
2 | P a g e
Introduction:
The .NET Framework provides several threading locking primitives. The Reader Writer Solution
is one of them.
The Reader Writer Solution class is used to synchronize access to a resource. At any given time,
it allows concurrent read access to multiple (essentially unlimited) threads, or it allows write
access for a single thread. In situations where a resource is read frequently but updated
infrequently, a Reader Writer Solution will provide much better throughput than the exclusive
Monitor lock.
Namespace: System.Threading
This namespace provides all the class methods and properties required for implementation of
the Reader Writer Solution class.
Assembly:mscorlib (in mscorlib.dll)
Constructors:
ReaderWriterLock: The constructor used to initialize a new instance of the Reader Writer
Solution class.
Properties:
 Reader Lock Held: This property gets a value that point to whether the current thread
holds a reader lock.
 Writer Lock Held: This property gets a value that points to whether the current thread
holds the writer lock.
 Writer Sequence Num: Gets the current sequence number.
Method
 Acquire Reader Lock (Int32): Acquires a reader lock, using an Int32 value for the time-
out.
 Acquire Writer Lock (Int32): Acquires the writer lock, using an Int32 value for the time-
out.
 Release Lock: Releases the lock, regardless of the number of times the thread acquired
the lock.
 Release Reader Lock: Decrements the lock count.
 Release Writer Lock: Decrements the lock count on the writer lock.
3 | P a g e
 Upgrade to Writer Lock (Int32): Upgrades a reader lock to the writer lock, using an
Int32 value for the time-out.
 Restore Lock: Restores the lock status of the thread to what it was before calling
Release Lock.
The problem with ReaderWriterLock is with its implementation. Several experts have slammed
this technique and found that outside of limited scenarios, it is actually far slower than the
Monitor. Enter method used to get an exclusive lock. ReaderWriterLock gives higher priority to
reader threads then writers. This makes sense if you have many readers and only a few writers.
So a lot of readers are able to read the resource while the writer has to wait longer to get the
lock. But what If you have equal or more writers. The process of favoring readers make writer
threads queue up and take a very long time to complete.
ReaderWriterLock intelligently handles recursive lock requests from the same thread. That is, if
the thread calls Acquire Reader Lock recursively (i.e., it already holds a reader lock), the lock is
granted immediately and the lock count is increased. The thread must still call Release Reader
Lock as many times as it called Acquire Reader Lock. Or, it can call Release Lock to reduce the
lock count to zero immediately. Be careful with Release Lock, though. If you subsequently call
Release Writer Lock or Release Reader Lock, the runtime will throw an exception.
A thread can hold a reader lock or a writer lock, but not both at the same time. Instead of
releasing a reader lock in order to acquire the writer lock, you can use Upgrade To Writer Lock
and Downgrade from Writer Lock.
In some situations, you might find that you're holding a reader lock and you need to upgrade to
a writer lock. In that situation, call Upgrade to Writer Lock, but understand that you don't get
the writer lock immediately. Your code will have to wait for any other readers in the queue to
release their locks, and will also have to wait behind any other writers that are already in the
write queue.
A thread should not call Acquire Writer Lock while it holds a reader lock. Doing so will cause the
thread to block while it holds the reader lock, and will lead to a deadlock if you use an infinite
timeout. You can call the Is Reader Lock Held method to determine if your thread currently
holds a reader lock before you attempt to acquire a writer lock.
Note that the opposite — calling Acquire Reader Lock while holding a writer lock — is just
fine. Since the thread has an exclusive lock on the resource, granting the lock is okay. However,
if you need to know whether your thread is currently holding a writer lock, you can call Is
Writer Lock Held.
The ReaderWriterLock class supports recursion; due to this it causes performance loss. in this
case the class needs to maintain a record of the number of times each thread acquires the lock
and increment and decrement the counter. When multiple reader threads acquire the same
lock (remember ReaderWriterLock class allows simultaneous reads), a counter is maintained for
4 | P a g e
each thread. This overhead is what causes the ReaderWriterLock to pale in comparison to the
Monitor class. It is approximately 6 times slower.
Tools:
 MICROSOFT VISUAL STUDIO (2010)

More Related Content

What's hot

Metrics lightning talk
Metrics lightning talkMetrics lightning talk
Metrics lightning talkChris Lohfink
 
Types of flows in mulesoft
Types of flows in mulesoftTypes of flows in mulesoft
Types of flows in mulesoftVishnuAnji
 
MULTITHREADING CONCEPT
MULTITHREADING CONCEPTMULTITHREADING CONCEPT
MULTITHREADING CONCEPTRAVI MAURYA
 
Operating Systems 1 (8/12) - Concurrency
Operating Systems 1 (8/12) - ConcurrencyOperating Systems 1 (8/12) - Concurrency
Operating Systems 1 (8/12) - ConcurrencyPeter Tröger
 
Thread presentation
Thread presentationThread presentation
Thread presentationAAshish Ojha
 
Introduction to LTspice iv
Introduction to LTspice ivIntroduction to LTspice iv
Introduction to LTspice ivHoopeer Hoopeer
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in javaArafat Hossan
 
Threads and Synchronization in c#
Threads and Synchronization in c#Threads and Synchronization in c#
Threads and Synchronization in c#Rizwan Ali
 
Real time operating systems (rtos) concepts 7
Real time operating systems (rtos) concepts 7Real time operating systems (rtos) concepts 7
Real time operating systems (rtos) concepts 7Abu Bakr Ramadan
 
Usp message queues
Usp message queuesUsp message queues
Usp message queuesRohitK71
 
Java Multi Thead Programming
Java Multi Thead ProgrammingJava Multi Thead Programming
Java Multi Thead ProgrammingNishant Mevawala
 
Architectural patterns part 4
Architectural patterns part 4Architectural patterns part 4
Architectural patterns part 4assinha
 

What's hot (16)

Metrics lightning talk
Metrics lightning talkMetrics lightning talk
Metrics lightning talk
 
Multi-Threading
Multi-ThreadingMulti-Threading
Multi-Threading
 
Types of flows in mulesoft
Types of flows in mulesoftTypes of flows in mulesoft
Types of flows in mulesoft
 
MULTITHREADING CONCEPT
MULTITHREADING CONCEPTMULTITHREADING CONCEPT
MULTITHREADING CONCEPT
 
Operating Systems 1 (8/12) - Concurrency
Operating Systems 1 (8/12) - ConcurrencyOperating Systems 1 (8/12) - Concurrency
Operating Systems 1 (8/12) - Concurrency
 
Thread presentation
Thread presentationThread presentation
Thread presentation
 
Introduction to LTspice iv
Introduction to LTspice ivIntroduction to LTspice iv
Introduction to LTspice iv
 
Threads in JAVA
Threads in JAVAThreads in JAVA
Threads in JAVA
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in java
 
Threads and Synchronization in c#
Threads and Synchronization in c#Threads and Synchronization in c#
Threads and Synchronization in c#
 
Real time operating systems (rtos) concepts 7
Real time operating systems (rtos) concepts 7Real time operating systems (rtos) concepts 7
Real time operating systems (rtos) concepts 7
 
Usp message queues
Usp message queuesUsp message queues
Usp message queues
 
Thread
ThreadThread
Thread
 
Java Multi Thead Programming
Java Multi Thead ProgrammingJava Multi Thead Programming
Java Multi Thead Programming
 
Architectural patterns part 4
Architectural patterns part 4Architectural patterns part 4
Architectural patterns part 4
 
Sa
SaSa
Sa
 

Viewers also liked

Dining Philosopher's Problem
Dining Philosopher's ProblemDining Philosopher's Problem
Dining Philosopher's ProblemYash Mittal
 
Ch7 OS
Ch7 OSCh7 OS
Ch7 OSC.U
 
Operating systems
Operating systemsOperating systems
Operating systemsAbraham
 
Database File System
Database File SystemDatabase File System
Database File SystemAnas R.
 
Producer and consumer classical problem
Producer and consumer classical problemProducer and consumer classical problem
Producer and consumer classical problemlatechwizard
 
The Dining Philosophers problem in Bangla
The Dining Philosophers problem in BanglaThe Dining Philosophers problem in Bangla
The Dining Philosophers problem in BanglaSifat Hossain
 
File system-and-database-chapter01-connoly
File system-and-database-chapter01-connolyFile system-and-database-chapter01-connoly
File system-and-database-chapter01-connolyTemma Tems
 
Classical problem of synchronization
Classical problem of synchronizationClassical problem of synchronization
Classical problem of synchronizationShakshi Ranawat
 
Producer consumer
Producer consumerProducer consumer
Producer consumerMohd Tousif
 
Chapter 11 - File System Implementation
Chapter 11 - File System ImplementationChapter 11 - File System Implementation
Chapter 11 - File System ImplementationWayne Jones Jnr
 
Process synchronization in Operating Systems
Process synchronization in Operating SystemsProcess synchronization in Operating Systems
Process synchronization in Operating SystemsRitu Ranjan Shrivastwa
 
Chapter 6 - Process Synchronization
Chapter 6 - Process SynchronizationChapter 6 - Process Synchronization
Chapter 6 - Process SynchronizationWayne Jones Jnr
 

Viewers also liked (18)

DPP
DPPDPP
DPP
 
Dining Philosopher's Problem
Dining Philosopher's ProblemDining Philosopher's Problem
Dining Philosopher's Problem
 
Ch7 OS
Ch7 OSCh7 OS
Ch7 OS
 
Operating systems
Operating systemsOperating systems
Operating systems
 
The bounded buffer
The bounded bufferThe bounded buffer
The bounded buffer
 
Database File System
Database File SystemDatabase File System
Database File System
 
Process synchronization in operating system
Process synchronization in operating systemProcess synchronization in operating system
Process synchronization in operating system
 
Producer Consumer
Producer ConsumerProducer Consumer
Producer Consumer
 
Producer and consumer classical problem
Producer and consumer classical problemProducer and consumer classical problem
Producer and consumer classical problem
 
The Dining Philosophers problem in Bangla
The Dining Philosophers problem in BanglaThe Dining Philosophers problem in Bangla
The Dining Philosophers problem in Bangla
 
File system-and-database-chapter01-connoly
File system-and-database-chapter01-connolyFile system-and-database-chapter01-connoly
File system-and-database-chapter01-connoly
 
Classical problem of synchronization
Classical problem of synchronizationClassical problem of synchronization
Classical problem of synchronization
 
Producer consumer
Producer consumerProducer consumer
Producer consumer
 
Chapter 11 - File System Implementation
Chapter 11 - File System ImplementationChapter 11 - File System Implementation
Chapter 11 - File System Implementation
 
Application Layer
Application Layer Application Layer
Application Layer
 
Process synchronization in Operating Systems
Process synchronization in Operating SystemsProcess synchronization in Operating Systems
Process synchronization in Operating Systems
 
Chapter 6 - Process Synchronization
Chapter 6 - Process SynchronizationChapter 6 - Process Synchronization
Chapter 6 - Process Synchronization
 
SlideShare 101
SlideShare 101SlideShare 101
SlideShare 101
 

Similar to READER/WRITER SOLUTION

Concurrency in Java
Concurrency in  JavaConcurrency in  Java
Concurrency in JavaAllan Huang
 
Thread Dump Analysis
Thread Dump AnalysisThread Dump Analysis
Thread Dump AnalysisDmitry Buzdin
 
Concurrency Programming in Java - 07 - High-level Concurrency objects, Lock O...
Concurrency Programming in Java - 07 - High-level Concurrency objects, Lock O...Concurrency Programming in Java - 07 - High-level Concurrency objects, Lock O...
Concurrency Programming in Java - 07 - High-level Concurrency objects, Lock O...Sachintha Gunasena
 
Securing docker containers
Securing docker containersSecuring docker containers
Securing docker containersMihir Shah
 
Lec 1.10 Object Oriented Programming
Lec 1.10 Object Oriented ProgrammingLec 1.10 Object Oriented Programming
Lec 1.10 Object Oriented ProgrammingBadar Waseer
 
Concurrency Learning From Jdk Source
Concurrency Learning From Jdk SourceConcurrency Learning From Jdk Source
Concurrency Learning From Jdk SourceKaniska Mandal
 
Multithreading 101
Multithreading 101Multithreading 101
Multithreading 101Tim Penhey
 
8.-OBJECT-ORIENTED-PROGRAMMING-USING-JAVA-Multithreading.pptx
8.-OBJECT-ORIENTED-PROGRAMMING-USING-JAVA-Multithreading.pptx8.-OBJECT-ORIENTED-PROGRAMMING-USING-JAVA-Multithreading.pptx
8.-OBJECT-ORIENTED-PROGRAMMING-USING-JAVA-Multithreading.pptxsandhyakiran10
 
Java Multithreading and Concurrency
Java Multithreading and ConcurrencyJava Multithreading and Concurrency
Java Multithreading and ConcurrencyRajesh Ananda Kumar
 

Similar to READER/WRITER SOLUTION (20)

Java tips
Java tipsJava tips
Java tips
 
Concurrency in Java
Concurrency in  JavaConcurrency in  Java
Concurrency in Java
 
Thread Dump Analysis
Thread Dump AnalysisThread Dump Analysis
Thread Dump Analysis
 
Concurrency Programming in Java - 07 - High-level Concurrency objects, Lock O...
Concurrency Programming in Java - 07 - High-level Concurrency objects, Lock O...Concurrency Programming in Java - 07 - High-level Concurrency objects, Lock O...
Concurrency Programming in Java - 07 - High-level Concurrency objects, Lock O...
 
Locks
LocksLocks
Locks
 
Securing docker containers
Securing docker containersSecuring docker containers
Securing docker containers
 
Introduction+To+Java+Concurrency
Introduction+To+Java+ConcurrencyIntroduction+To+Java+Concurrency
Introduction+To+Java+Concurrency
 
Lec 1.10 Object Oriented Programming
Lec 1.10 Object Oriented ProgrammingLec 1.10 Object Oriented Programming
Lec 1.10 Object Oriented Programming
 
Threading in java - a pragmatic primer
Threading in java - a pragmatic primerThreading in java - a pragmatic primer
Threading in java - a pragmatic primer
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in java
 
Concurrency
ConcurrencyConcurrency
Concurrency
 
Slide 7 Thread-1.pptx
Slide 7 Thread-1.pptxSlide 7 Thread-1.pptx
Slide 7 Thread-1.pptx
 
Concurrency Learning From Jdk Source
Concurrency Learning From Jdk SourceConcurrency Learning From Jdk Source
Concurrency Learning From Jdk Source
 
Java-7 Concurrency
Java-7 ConcurrencyJava-7 Concurrency
Java-7 Concurrency
 
Multithreading 101
Multithreading 101Multithreading 101
Multithreading 101
 
Java threading
Java threadingJava threading
Java threading
 
Java threading 2
Java threading 2Java threading 2
Java threading 2
 
8.-OBJECT-ORIENTED-PROGRAMMING-USING-JAVA-Multithreading.pptx
8.-OBJECT-ORIENTED-PROGRAMMING-USING-JAVA-Multithreading.pptx8.-OBJECT-ORIENTED-PROGRAMMING-USING-JAVA-Multithreading.pptx
8.-OBJECT-ORIENTED-PROGRAMMING-USING-JAVA-Multithreading.pptx
 
MultiThreading in Python
MultiThreading in PythonMultiThreading in Python
MultiThreading in Python
 
Java Multithreading and Concurrency
Java Multithreading and ConcurrencyJava Multithreading and Concurrency
Java Multithreading and Concurrency
 

More from Shahzeb Pirzada

Sigma Society Inauguration
Sigma Society Inauguration Sigma Society Inauguration
Sigma Society Inauguration Shahzeb Pirzada
 
Newton's Ninja - Combat'13
Newton's Ninja - Combat'13Newton's Ninja - Combat'13
Newton's Ninja - Combat'13Shahzeb Pirzada
 
The Open Systems Interconnect (OSI) Model - IS AUDIT
The Open Systems Interconnect (OSI) Model - IS AUDITThe Open Systems Interconnect (OSI) Model - IS AUDIT
The Open Systems Interconnect (OSI) Model - IS AUDITShahzeb Pirzada
 
Process Improvement Techniques - IS AUDIT
Process Improvement Techniques - IS AUDITProcess Improvement Techniques - IS AUDIT
Process Improvement Techniques - IS AUDITShahzeb Pirzada
 
Project Management Certifications - IS AUDIT
Project Management Certifications - IS AUDITProject Management Certifications - IS AUDIT
Project Management Certifications - IS AUDITShahzeb Pirzada
 
Computer Assisted Audit Techniques (CAATS) - IS AUDIT
Computer Assisted Audit Techniques (CAATS) - IS AUDITComputer Assisted Audit Techniques (CAATS) - IS AUDIT
Computer Assisted Audit Techniques (CAATS) - IS AUDITShahzeb Pirzada
 
Certifications on Security - IS AUDIT
Certifications on Security - IS AUDITCertifications on Security - IS AUDIT
Certifications on Security - IS AUDITShahzeb Pirzada
 
Google Advance Searching- Information System Audit & Control Report
Google Advance Searching- Information System Audit & Control ReportGoogle Advance Searching- Information System Audit & Control Report
Google Advance Searching- Information System Audit & Control ReportShahzeb Pirzada
 
Prolog Code [Family Tree] by Shahzeb Pirzada
Prolog Code [Family Tree] by Shahzeb PirzadaProlog Code [Family Tree] by Shahzeb Pirzada
Prolog Code [Family Tree] by Shahzeb PirzadaShahzeb Pirzada
 
Elements of Quality Management System
Elements of Quality Management SystemElements of Quality Management System
Elements of Quality Management SystemShahzeb Pirzada
 
City School Network- Routing & Switching Final Report
City School Network- Routing & Switching Final ReportCity School Network- Routing & Switching Final Report
City School Network- Routing & Switching Final ReportShahzeb Pirzada
 
THE SEVEN HABITS OF HIGHLY EFFECTIVE TEENS
THE SEVEN HABITS OF HIGHLY EFFECTIVE TEENSTHE SEVEN HABITS OF HIGHLY EFFECTIVE TEENS
THE SEVEN HABITS OF HIGHLY EFFECTIVE TEENSShahzeb Pirzada
 
Entrepreneurial Leadership-FINAL REPORT
Entrepreneurial Leadership-FINAL REPORTEntrepreneurial Leadership-FINAL REPORT
Entrepreneurial Leadership-FINAL REPORTShahzeb Pirzada
 
SP STUDENT MANAGEMENT SYSTEM-Human Computer Interaction Final Report
SP STUDENT MANAGEMENT SYSTEM-Human Computer Interaction Final ReportSP STUDENT MANAGEMENT SYSTEM-Human Computer Interaction Final Report
SP STUDENT MANAGEMENT SYSTEM-Human Computer Interaction Final ReportShahzeb Pirzada
 
White collar vs Blue collar
White collar vs Blue collarWhite collar vs Blue collar
White collar vs Blue collarShahzeb Pirzada
 
Story Narration Competition -Script
Story Narration Competition -Script Story Narration Competition -Script
Story Narration Competition -Script Shahzeb Pirzada
 
Declamation Contest Script for Moc
Declamation Contest Script for MocDeclamation Contest Script for Moc
Declamation Contest Script for MocShahzeb Pirzada
 
BOOTABLE OPERATING SYSTEM PPT
BOOTABLE OPERATING SYSTEM PPTBOOTABLE OPERATING SYSTEM PPT
BOOTABLE OPERATING SYSTEM PPTShahzeb Pirzada
 

More from Shahzeb Pirzada (20)

Sigma Society Inauguration
Sigma Society Inauguration Sigma Society Inauguration
Sigma Society Inauguration
 
Newton's Ninja - Combat'13
Newton's Ninja - Combat'13Newton's Ninja - Combat'13
Newton's Ninja - Combat'13
 
The Open Systems Interconnect (OSI) Model - IS AUDIT
The Open Systems Interconnect (OSI) Model - IS AUDITThe Open Systems Interconnect (OSI) Model - IS AUDIT
The Open Systems Interconnect (OSI) Model - IS AUDIT
 
RAID - IS AUDIT
RAID - IS AUDITRAID - IS AUDIT
RAID - IS AUDIT
 
Process Improvement Techniques - IS AUDIT
Process Improvement Techniques - IS AUDITProcess Improvement Techniques - IS AUDIT
Process Improvement Techniques - IS AUDIT
 
Project Management Certifications - IS AUDIT
Project Management Certifications - IS AUDITProject Management Certifications - IS AUDIT
Project Management Certifications - IS AUDIT
 
Computer Assisted Audit Techniques (CAATS) - IS AUDIT
Computer Assisted Audit Techniques (CAATS) - IS AUDITComputer Assisted Audit Techniques (CAATS) - IS AUDIT
Computer Assisted Audit Techniques (CAATS) - IS AUDIT
 
Certifications on Security - IS AUDIT
Certifications on Security - IS AUDITCertifications on Security - IS AUDIT
Certifications on Security - IS AUDIT
 
Google Advance Searching- Information System Audit & Control Report
Google Advance Searching- Information System Audit & Control ReportGoogle Advance Searching- Information System Audit & Control Report
Google Advance Searching- Information System Audit & Control Report
 
Prolog Code [Family Tree] by Shahzeb Pirzada
Prolog Code [Family Tree] by Shahzeb PirzadaProlog Code [Family Tree] by Shahzeb Pirzada
Prolog Code [Family Tree] by Shahzeb Pirzada
 
What is Fuzzy Logic?
What is Fuzzy Logic?What is Fuzzy Logic?
What is Fuzzy Logic?
 
Elements of Quality Management System
Elements of Quality Management SystemElements of Quality Management System
Elements of Quality Management System
 
City School Network- Routing & Switching Final Report
City School Network- Routing & Switching Final ReportCity School Network- Routing & Switching Final Report
City School Network- Routing & Switching Final Report
 
THE SEVEN HABITS OF HIGHLY EFFECTIVE TEENS
THE SEVEN HABITS OF HIGHLY EFFECTIVE TEENSTHE SEVEN HABITS OF HIGHLY EFFECTIVE TEENS
THE SEVEN HABITS OF HIGHLY EFFECTIVE TEENS
 
Entrepreneurial Leadership-FINAL REPORT
Entrepreneurial Leadership-FINAL REPORTEntrepreneurial Leadership-FINAL REPORT
Entrepreneurial Leadership-FINAL REPORT
 
SP STUDENT MANAGEMENT SYSTEM-Human Computer Interaction Final Report
SP STUDENT MANAGEMENT SYSTEM-Human Computer Interaction Final ReportSP STUDENT MANAGEMENT SYSTEM-Human Computer Interaction Final Report
SP STUDENT MANAGEMENT SYSTEM-Human Computer Interaction Final Report
 
White collar vs Blue collar
White collar vs Blue collarWhite collar vs Blue collar
White collar vs Blue collar
 
Story Narration Competition -Script
Story Narration Competition -Script Story Narration Competition -Script
Story Narration Competition -Script
 
Declamation Contest Script for Moc
Declamation Contest Script for MocDeclamation Contest Script for Moc
Declamation Contest Script for Moc
 
BOOTABLE OPERATING SYSTEM PPT
BOOTABLE OPERATING SYSTEM PPTBOOTABLE OPERATING SYSTEM PPT
BOOTABLE OPERATING SYSTEM PPT
 

Recently uploaded

Call Girls In Chandigarh ☎ 08868886958✅ Just Genuine Call Call Girls Chandiga...
Call Girls In Chandigarh ☎ 08868886958✅ Just Genuine Call Call Girls Chandiga...Call Girls In Chandigarh ☎ 08868886958✅ Just Genuine Call Call Girls Chandiga...
Call Girls In Chandigarh ☎ 08868886958✅ Just Genuine Call Call Girls Chandiga...Sheetaleventcompany
 
Vip Call Girls Hyderabad Just Call 7091864438 Top Class Call Girl Service Ava...
Vip Call Girls Hyderabad Just Call 7091864438 Top Class Call Girl Service Ava...Vip Call Girls Hyderabad Just Call 7091864438 Top Class Call Girl Service Ava...
Vip Call Girls Hyderabad Just Call 7091864438 Top Class Call Girl Service Ava...Monika Rani
 
Sri Ganganagar 💋 Call Girl 9748763073 Call Girls Escort service Ganganagar b...
Sri Ganganagar 💋 Call Girl 9748763073 Call Girls  Escort service Ganganagar b...Sri Ganganagar 💋 Call Girl 9748763073 Call Girls  Escort service Ganganagar b...
Sri Ganganagar 💋 Call Girl 9748763073 Call Girls Escort service Ganganagar b...apshanarani255
 
💚Amritsar Call Girl 💯Jiya 📲🔝8725944379🔝Call Girls In Amritsar No💰Advance Cash...
💚Amritsar Call Girl 💯Jiya 📲🔝8725944379🔝Call Girls In Amritsar No💰Advance Cash...💚Amritsar Call Girl 💯Jiya 📲🔝8725944379🔝Call Girls In Amritsar No💰Advance Cash...
💚Amritsar Call Girl 💯Jiya 📲🔝8725944379🔝Call Girls In Amritsar No💰Advance Cash...Sheetaleventcompany
 
💊💊 OBAT PENGGUGUR KANDUNGAN JAMBI 08776558899 ATAU CARA GUGURKAN JANIN KLINIK...
💊💊 OBAT PENGGUGUR KANDUNGAN JAMBI 08776558899 ATAU CARA GUGURKAN JANIN KLINIK...💊💊 OBAT PENGGUGUR KANDUNGAN JAMBI 08776558899 ATAU CARA GUGURKAN JANIN KLINIK...
💊💊 OBAT PENGGUGUR KANDUNGAN JAMBI 08776558899 ATAU CARA GUGURKAN JANIN KLINIK...Cara Menggugurkan Kandungan 087776558899
 
Call Girls Siliguri Just Call 7870993772 Top Class Call Girl Service Availabl...
Call Girls Siliguri Just Call 7870993772 Top Class Call Girl Service Availabl...Call Girls Siliguri Just Call 7870993772 Top Class Call Girl Service Availabl...
Call Girls Siliguri Just Call 7870993772 Top Class Call Girl Service Availabl...Monika Rani
 
Rehabilitation centres in zimbabwe | 📲 +263788080001
Rehabilitation centres in zimbabwe |  📲 +263788080001Rehabilitation centres in zimbabwe |  📲 +263788080001
Rehabilitation centres in zimbabwe | 📲 +263788080001Rehabilitation Centre
 
💚Call Girls Chandigarh 💯Riya 📲🔝8868886958🔝Call Girls In Chandigarh No💰Advance...
💚Call Girls Chandigarh 💯Riya 📲🔝8868886958🔝Call Girls In Chandigarh No💰Advance...💚Call Girls Chandigarh 💯Riya 📲🔝8868886958🔝Call Girls In Chandigarh No💰Advance...
💚Call Girls Chandigarh 💯Riya 📲🔝8868886958🔝Call Girls In Chandigarh No💰Advance...Sheetaleventcompany
 
Udaipur Call Girls ☎ 9602870969✅ Best Genuine Call Girl in Udaipur Escort Ser...
Udaipur Call Girls ☎ 9602870969✅ Best Genuine Call Girl in Udaipur Escort Ser...Udaipur Call Girls ☎ 9602870969✅ Best Genuine Call Girl in Udaipur Escort Ser...
Udaipur Call Girls ☎ 9602870969✅ Best Genuine Call Girl in Udaipur Escort Ser...Apsara Of India
 
Udaipur Call Girls ☎ 9602870969✅ Better Genuine Call Girl in Udaipur Escort S...
Udaipur Call Girls ☎ 9602870969✅ Better Genuine Call Girl in Udaipur Escort S...Udaipur Call Girls ☎ 9602870969✅ Better Genuine Call Girl in Udaipur Escort S...
Udaipur Call Girls ☎ 9602870969✅ Better Genuine Call Girl in Udaipur Escort S...Apsara Of India
 
RAIPUR CALL GIRL 9661985112 LOW PRICE ESCORT SERVICE RAIPUR
RAIPUR CALL GIRL 9661985112 LOW PRICE ESCORT SERVICE RAIPURRAIPUR CALL GIRL 9661985112 LOW PRICE ESCORT SERVICE RAIPUR
RAIPUR CALL GIRL 9661985112 LOW PRICE ESCORT SERVICE RAIPURSapna Call girl
 
chittorgarh 💋 Call Girl 9748763073 Call Girls in Chittorgarh Escort service ...
chittorgarh 💋  Call Girl 9748763073 Call Girls in Chittorgarh Escort service ...chittorgarh 💋  Call Girl 9748763073 Call Girls in Chittorgarh Escort service ...
chittorgarh 💋 Call Girl 9748763073 Call Girls in Chittorgarh Escort service ...apshanarani255
 
Jamnagar 💋 Call Girl 9748763073 Call Girls in Jamnagar Escort service book now
Jamnagar 💋 Call Girl 9748763073 Call Girls in Jamnagar Escort service book nowJamnagar 💋 Call Girl 9748763073 Call Girls in Jamnagar Escort service book now
Jamnagar 💋 Call Girl 9748763073 Call Girls in Jamnagar Escort service book nowapshanarani255
 
Mysore❤CALL GIRL 9647466585 ❤CALL GIRLS IN Mysore ESCORT SERVICE
Mysore❤CALL GIRL 9647466585 ❤CALL GIRLS IN Mysore ESCORT SERVICEMysore❤CALL GIRL 9647466585 ❤CALL GIRLS IN Mysore ESCORT SERVICE
Mysore❤CALL GIRL 9647466585 ❤CALL GIRLS IN Mysore ESCORT SERVICEshivam142808
 
ULHASNAGAR CALL GIRL 7857803690 LOW PRICE ESCORT SERVICE
ULHASNAGAR CALL GIRL 7857803690 LOW PRICE ESCORT SERVICEULHASNAGAR CALL GIRL 7857803690 LOW PRICE ESCORT SERVICE
ULHASNAGAR CALL GIRL 7857803690 LOW PRICE ESCORT SERVICEayushi9330
 
NAGPUR ESCORT SERVICE 9262871154 LOW PRICE NAGPUR ESCORT SERVICE
NAGPUR ESCORT SERVICE 9262871154 LOW PRICE NAGPUR ESCORT SERVICENAGPUR ESCORT SERVICE 9262871154 LOW PRICE NAGPUR ESCORT SERVICE
NAGPUR ESCORT SERVICE 9262871154 LOW PRICE NAGPUR ESCORT SERVICENiteshKumar82226
 
Call Girls Pune Call WhatsApp 7870993772 Top Class Call Girl Service Availab...
Call Girls Pune Call  WhatsApp 7870993772 Top Class Call Girl Service Availab...Call Girls Pune Call  WhatsApp 7870993772 Top Class Call Girl Service Availab...
Call Girls Pune Call WhatsApp 7870993772 Top Class Call Girl Service Availab...Monika Rani
 
Davangere ❤CALL GIRL 9973520673 ❤CALL GIRLS IN Davangere ESCORT SERVICE❤CALL ...
Davangere ❤CALL GIRL 9973520673 ❤CALL GIRLS IN Davangere ESCORT SERVICE❤CALL ...Davangere ❤CALL GIRL 9973520673 ❤CALL GIRLS IN Davangere ESCORT SERVICE❤CALL ...
Davangere ❤CALL GIRL 9973520673 ❤CALL GIRLS IN Davangere ESCORT SERVICE❤CALL ...deepak38245
 
Agra 💋Call Girl 9748763073 Call Girls in Agra Escort service book now
Agra 💋Call Girl 9748763073 Call Girls in Agra Escort service book nowAgra 💋Call Girl 9748763073 Call Girls in Agra Escort service book now
Agra 💋Call Girl 9748763073 Call Girls in Agra Escort service book nowapshanarani255
 

Recently uploaded (20)

Call Girls In Chandigarh ☎ 08868886958✅ Just Genuine Call Call Girls Chandiga...
Call Girls In Chandigarh ☎ 08868886958✅ Just Genuine Call Call Girls Chandiga...Call Girls In Chandigarh ☎ 08868886958✅ Just Genuine Call Call Girls Chandiga...
Call Girls In Chandigarh ☎ 08868886958✅ Just Genuine Call Call Girls Chandiga...
 
Vip Call Girls Hyderabad Just Call 7091864438 Top Class Call Girl Service Ava...
Vip Call Girls Hyderabad Just Call 7091864438 Top Class Call Girl Service Ava...Vip Call Girls Hyderabad Just Call 7091864438 Top Class Call Girl Service Ava...
Vip Call Girls Hyderabad Just Call 7091864438 Top Class Call Girl Service Ava...
 
Sri Ganganagar 💋 Call Girl 9748763073 Call Girls Escort service Ganganagar b...
Sri Ganganagar 💋 Call Girl 9748763073 Call Girls  Escort service Ganganagar b...Sri Ganganagar 💋 Call Girl 9748763073 Call Girls  Escort service Ganganagar b...
Sri Ganganagar 💋 Call Girl 9748763073 Call Girls Escort service Ganganagar b...
 
💚Amritsar Call Girl 💯Jiya 📲🔝8725944379🔝Call Girls In Amritsar No💰Advance Cash...
💚Amritsar Call Girl 💯Jiya 📲🔝8725944379🔝Call Girls In Amritsar No💰Advance Cash...💚Amritsar Call Girl 💯Jiya 📲🔝8725944379🔝Call Girls In Amritsar No💰Advance Cash...
💚Amritsar Call Girl 💯Jiya 📲🔝8725944379🔝Call Girls In Amritsar No💰Advance Cash...
 
💊💊 OBAT PENGGUGUR KANDUNGAN JAMBI 08776558899 ATAU CARA GUGURKAN JANIN KLINIK...
💊💊 OBAT PENGGUGUR KANDUNGAN JAMBI 08776558899 ATAU CARA GUGURKAN JANIN KLINIK...💊💊 OBAT PENGGUGUR KANDUNGAN JAMBI 08776558899 ATAU CARA GUGURKAN JANIN KLINIK...
💊💊 OBAT PENGGUGUR KANDUNGAN JAMBI 08776558899 ATAU CARA GUGURKAN JANIN KLINIK...
 
Call Girls Siliguri Just Call 7870993772 Top Class Call Girl Service Availabl...
Call Girls Siliguri Just Call 7870993772 Top Class Call Girl Service Availabl...Call Girls Siliguri Just Call 7870993772 Top Class Call Girl Service Availabl...
Call Girls Siliguri Just Call 7870993772 Top Class Call Girl Service Availabl...
 
Rehabilitation centres in zimbabwe | 📲 +263788080001
Rehabilitation centres in zimbabwe |  📲 +263788080001Rehabilitation centres in zimbabwe |  📲 +263788080001
Rehabilitation centres in zimbabwe | 📲 +263788080001
 
💚Call Girls Chandigarh 💯Riya 📲🔝8868886958🔝Call Girls In Chandigarh No💰Advance...
💚Call Girls Chandigarh 💯Riya 📲🔝8868886958🔝Call Girls In Chandigarh No💰Advance...💚Call Girls Chandigarh 💯Riya 📲🔝8868886958🔝Call Girls In Chandigarh No💰Advance...
💚Call Girls Chandigarh 💯Riya 📲🔝8868886958🔝Call Girls In Chandigarh No💰Advance...
 
Udaipur Call Girls ☎ 9602870969✅ Best Genuine Call Girl in Udaipur Escort Ser...
Udaipur Call Girls ☎ 9602870969✅ Best Genuine Call Girl in Udaipur Escort Ser...Udaipur Call Girls ☎ 9602870969✅ Best Genuine Call Girl in Udaipur Escort Ser...
Udaipur Call Girls ☎ 9602870969✅ Best Genuine Call Girl in Udaipur Escort Ser...
 
Udaipur Call Girls ☎ 9602870969✅ Better Genuine Call Girl in Udaipur Escort S...
Udaipur Call Girls ☎ 9602870969✅ Better Genuine Call Girl in Udaipur Escort S...Udaipur Call Girls ☎ 9602870969✅ Better Genuine Call Girl in Udaipur Escort S...
Udaipur Call Girls ☎ 9602870969✅ Better Genuine Call Girl in Udaipur Escort S...
 
RAIPUR CALL GIRL 9661985112 LOW PRICE ESCORT SERVICE RAIPUR
RAIPUR CALL GIRL 9661985112 LOW PRICE ESCORT SERVICE RAIPURRAIPUR CALL GIRL 9661985112 LOW PRICE ESCORT SERVICE RAIPUR
RAIPUR CALL GIRL 9661985112 LOW PRICE ESCORT SERVICE RAIPUR
 
chittorgarh 💋 Call Girl 9748763073 Call Girls in Chittorgarh Escort service ...
chittorgarh 💋  Call Girl 9748763073 Call Girls in Chittorgarh Escort service ...chittorgarh 💋  Call Girl 9748763073 Call Girls in Chittorgarh Escort service ...
chittorgarh 💋 Call Girl 9748763073 Call Girls in Chittorgarh Escort service ...
 
Jamnagar 💋 Call Girl 9748763073 Call Girls in Jamnagar Escort service book now
Jamnagar 💋 Call Girl 9748763073 Call Girls in Jamnagar Escort service book nowJamnagar 💋 Call Girl 9748763073 Call Girls in Jamnagar Escort service book now
Jamnagar 💋 Call Girl 9748763073 Call Girls in Jamnagar Escort service book now
 
Mysore❤CALL GIRL 9647466585 ❤CALL GIRLS IN Mysore ESCORT SERVICE
Mysore❤CALL GIRL 9647466585 ❤CALL GIRLS IN Mysore ESCORT SERVICEMysore❤CALL GIRL 9647466585 ❤CALL GIRLS IN Mysore ESCORT SERVICE
Mysore❤CALL GIRL 9647466585 ❤CALL GIRLS IN Mysore ESCORT SERVICE
 
ULHASNAGAR CALL GIRL 7857803690 LOW PRICE ESCORT SERVICE
ULHASNAGAR CALL GIRL 7857803690 LOW PRICE ESCORT SERVICEULHASNAGAR CALL GIRL 7857803690 LOW PRICE ESCORT SERVICE
ULHASNAGAR CALL GIRL 7857803690 LOW PRICE ESCORT SERVICE
 
NAGPUR ESCORT SERVICE 9262871154 LOW PRICE NAGPUR ESCORT SERVICE
NAGPUR ESCORT SERVICE 9262871154 LOW PRICE NAGPUR ESCORT SERVICENAGPUR ESCORT SERVICE 9262871154 LOW PRICE NAGPUR ESCORT SERVICE
NAGPUR ESCORT SERVICE 9262871154 LOW PRICE NAGPUR ESCORT SERVICE
 
Call Girls Pune Call WhatsApp 7870993772 Top Class Call Girl Service Availab...
Call Girls Pune Call  WhatsApp 7870993772 Top Class Call Girl Service Availab...Call Girls Pune Call  WhatsApp 7870993772 Top Class Call Girl Service Availab...
Call Girls Pune Call WhatsApp 7870993772 Top Class Call Girl Service Availab...
 
Davangere ❤CALL GIRL 9973520673 ❤CALL GIRLS IN Davangere ESCORT SERVICE❤CALL ...
Davangere ❤CALL GIRL 9973520673 ❤CALL GIRLS IN Davangere ESCORT SERVICE❤CALL ...Davangere ❤CALL GIRL 9973520673 ❤CALL GIRLS IN Davangere ESCORT SERVICE❤CALL ...
Davangere ❤CALL GIRL 9973520673 ❤CALL GIRLS IN Davangere ESCORT SERVICE❤CALL ...
 
NO ADVANCE PAYMENT ONLY CASH PAYMENT DIRECT MEETING GENUINE
NO ADVANCE PAYMENT ONLY CASH PAYMENT DIRECT MEETING GENUINENO ADVANCE PAYMENT ONLY CASH PAYMENT DIRECT MEETING GENUINE
NO ADVANCE PAYMENT ONLY CASH PAYMENT DIRECT MEETING GENUINE
 
Agra 💋Call Girl 9748763073 Call Girls in Agra Escort service book now
Agra 💋Call Girl 9748763073 Call Girls in Agra Escort service book nowAgra 💋Call Girl 9748763073 Call Girls in Agra Escort service book now
Agra 💋Call Girl 9748763073 Call Girls in Agra Escort service book now
 

READER/WRITER SOLUTION

  • 1. OPERATING SYSTEM October 10 2012 PROJECT REPORT : READER/WRITER SOLUTION Submitted to Sir Raazi Made by Shahzeb Pirzada Bariq Qadri
  • 2. 2 | P a g e Introduction: The .NET Framework provides several threading locking primitives. The Reader Writer Solution is one of them. The Reader Writer Solution class is used to synchronize access to a resource. At any given time, it allows concurrent read access to multiple (essentially unlimited) threads, or it allows write access for a single thread. In situations where a resource is read frequently but updated infrequently, a Reader Writer Solution will provide much better throughput than the exclusive Monitor lock. Namespace: System.Threading This namespace provides all the class methods and properties required for implementation of the Reader Writer Solution class. Assembly:mscorlib (in mscorlib.dll) Constructors: ReaderWriterLock: The constructor used to initialize a new instance of the Reader Writer Solution class. Properties:  Reader Lock Held: This property gets a value that point to whether the current thread holds a reader lock.  Writer Lock Held: This property gets a value that points to whether the current thread holds the writer lock.  Writer Sequence Num: Gets the current sequence number. Method  Acquire Reader Lock (Int32): Acquires a reader lock, using an Int32 value for the time- out.  Acquire Writer Lock (Int32): Acquires the writer lock, using an Int32 value for the time- out.  Release Lock: Releases the lock, regardless of the number of times the thread acquired the lock.  Release Reader Lock: Decrements the lock count.  Release Writer Lock: Decrements the lock count on the writer lock.
  • 3. 3 | P a g e  Upgrade to Writer Lock (Int32): Upgrades a reader lock to the writer lock, using an Int32 value for the time-out.  Restore Lock: Restores the lock status of the thread to what it was before calling Release Lock. The problem with ReaderWriterLock is with its implementation. Several experts have slammed this technique and found that outside of limited scenarios, it is actually far slower than the Monitor. Enter method used to get an exclusive lock. ReaderWriterLock gives higher priority to reader threads then writers. This makes sense if you have many readers and only a few writers. So a lot of readers are able to read the resource while the writer has to wait longer to get the lock. But what If you have equal or more writers. The process of favoring readers make writer threads queue up and take a very long time to complete. ReaderWriterLock intelligently handles recursive lock requests from the same thread. That is, if the thread calls Acquire Reader Lock recursively (i.e., it already holds a reader lock), the lock is granted immediately and the lock count is increased. The thread must still call Release Reader Lock as many times as it called Acquire Reader Lock. Or, it can call Release Lock to reduce the lock count to zero immediately. Be careful with Release Lock, though. If you subsequently call Release Writer Lock or Release Reader Lock, the runtime will throw an exception. A thread can hold a reader lock or a writer lock, but not both at the same time. Instead of releasing a reader lock in order to acquire the writer lock, you can use Upgrade To Writer Lock and Downgrade from Writer Lock. In some situations, you might find that you're holding a reader lock and you need to upgrade to a writer lock. In that situation, call Upgrade to Writer Lock, but understand that you don't get the writer lock immediately. Your code will have to wait for any other readers in the queue to release their locks, and will also have to wait behind any other writers that are already in the write queue. A thread should not call Acquire Writer Lock while it holds a reader lock. Doing so will cause the thread to block while it holds the reader lock, and will lead to a deadlock if you use an infinite timeout. You can call the Is Reader Lock Held method to determine if your thread currently holds a reader lock before you attempt to acquire a writer lock. Note that the opposite — calling Acquire Reader Lock while holding a writer lock — is just fine. Since the thread has an exclusive lock on the resource, granting the lock is okay. However, if you need to know whether your thread is currently holding a writer lock, you can call Is Writer Lock Held. The ReaderWriterLock class supports recursion; due to this it causes performance loss. in this case the class needs to maintain a record of the number of times each thread acquires the lock and increment and decrement the counter. When multiple reader threads acquire the same lock (remember ReaderWriterLock class allows simultaneous reads), a counter is maintained for
  • 4. 4 | P a g e each thread. This overhead is what causes the ReaderWriterLock to pale in comparison to the Monitor class. It is approximately 6 times slower. Tools:  MICROSOFT VISUAL STUDIO (2010)