readers writers Problem in operating system

VADAPALLYPRAVEENKUMA1 254 views 9 slides Jul 09, 2024
Slide 1
Slide 1 of 9
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9

About This Presentation

Readers Writers Problem


Slide Content

The Reader-Writer Problem
OPERATING SYSTEMS

INTRODUCTION
The Reader-Writer Problem is a fundamental challenge in concurrent
programming, where multiple threads or processes need to access
shared data simultaneously. It involves coordinating read and write
operations to ensure data integrity and maximize system throughput.

Defining the Reader-Writer Problem
Readers
Threads or processes that
only read from the shared
data, without modifying it.
Writers
Threads or processes that
need to modify the shared
data.
Synchronization
The key challenge is to
ensure that readers and
writers do not interfere with
each other's operations.

Characteristics of the Reader-Writer
Problem
Concurrency
Multiple readers and writers
can access the shared data
simultaneously.
Data Integrity
Ensure the shared data
remains consistent and correct,
even with concurrent access.
Performance
Maximize the throughput of the
system by allowing as much
concurrent access as possible.

Synchronization Challenges
1Mutual Exclusion
Ensure that only one
writer can access the
shared data at a time to
prevent data corruption.
2Starvation
Avoid a situation where
readers or writers are
indefinitely denied access
to the shared data.
3Deadlocks
Prevent a scenario where
two or more threads are
waiting for each other to
release resources,
leading to a system-wide
halt.

Approaches to Solving the
Reader-Writer Problem
1
Shared Lock
Allow multiple readers to access
the shared data simultaneously,
but grant exclusive access to
writers.
2
Exclusive Lock
Grant exclusive access to
either all readers or a single
writer, preventing any
concurrent access.
3
Priority-based
Assign priorities to readers and
writers to ensure fairness and
avoid starvation.

Shared Lock Approach
Multiple Readers
Readers can access the shared
data simultaneously, as long as
no writer is active.
Single Writer
Writers are granted exclusive
access to the shared data,
blocking all readers.
Fair Scheduling
The algorithm ensures that
readers and writers are
scheduled fairly, preventing
starvation.

Exclusive Lock Approach
Reader-Priority
Readers are granted access
as long as no writer is active,
ensuring low latency for read
operations.
Writer-Priority
Writers are given priority over
readers, ensuring that write
operations are completed in a
timely manner.
Hybrid Approach
A combination of reader and
writer priorities, balancing the
needs of both read and write
operations.

THANK YOU!