concurrent control with readers and writers l.
Download
Skip this Video
Download Presentation
Concurrent Control with “Readers” and “Writers”

Loading in 2 Seconds...

play fullscreen
1 / 18

Concurrent Control with “Readers” and “Writers” - PowerPoint PPT Presentation


  • 162 Views
  • Uploaded on

Concurrent Control with “Readers” and “Writers”. Sagnik Bhattacharya Siddharth Dalal. Sequential Programs. Terminating Single thread or process Number of possible execution paths finite Constructions like if-then-else, while are strictly defined

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Concurrent Control with “Readers” and “Writers”' - polly


Download Now An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
sequential programs
Sequential Programs
  • Terminating
  • Single thread or process
  • Number of possible execution paths finite
  • Constructions like if-then-else, while are strictly defined
  • Mathematical tools (though complicated) exist.
concurrent programs
Concurrent Programs
  • Possibly non-terminating
  • Infinite number of possible execution paths
  • Synchronization
  • Scheduling
  • Prevention of starvation
  • Lack of formal tools to deal with concurrency
readers and writers problem
Readers and Writers Problem

Reader

Writer

Critical Section

Writer

Reader

Writer

Reader

readers and writers problem5
Readers and Writers Problem

Reader

Writer

Critical Section

Writer

Reader

Writer

Reader

YES!

readers and writers problem6
Readers and Writers Problem

Reader

Writer

Critical Section

Writer

Reader

Writer

Reader

NO!

readers and writers problem7
Readers and Writers Problem

Reader

Writer

Critical Section

Writer

Reader

Writer

Reader

NO!

the p and v operations
The P and V operations
  • Sometimes referred to as wait and signal
  • P(S) :
      • while S < 0 do no-op;
      • S := S - 1;
  • V(S) :
      • S := S + 1;
problem 1
Waiting readers have higher priority.Problem 1

GLOBALS

mutex, w : semaphore := 1; // Mutual exclusion semaphores

readcount : integer   := 0;

problem 110
Problem 1

READER

P(mutex);

readcount++;

if (readcount=1) then P(w);

V(mutex);

CRITICAL REGION

P(mutex);

readcount--;

if (readcount=0) then V(w);  

V(mutex);

WRITER

P(w);

CRITICAL REGION

V(w);

problem 2
Waiting writers have higher priorityProblem 2

GLOBALS

mutex1 : semaphore := 1; // all semaphores here are mutual exclusionmutex2 : semaphore := 1;mutex3 : semaphore := 1;w     : semaphore := 1;r      : semaphore := 1;readcount, writecount : integer := 0;

problem 213
Problem 2

READER

P(mutex3);

P(r);

P(mutex1);

readcount++;

if (readcount is 1) then P(w);

V(mutex1);

V(r);

V(mutex3);

CRITICAL REGION

P(mutex1);

readcount--;

if (readcount is 0) then V(w);

V(mutex1);

problem 214
Problem 2

WRITER

P(mutex2);

writecount++;

if (writecount is 1) then P(r);

V(mutex2);

P(w);

CRITICAL REGION

V(w);

P(mutex2);

writecount--;

if (writecount is 0) then V(r);

V(mutex2);

does this guarantee fifo order15
Does this guarantee FIFO order?
  • For Readers?
    • NO!!
  • For Writers?
    • NO!!
to achieve fifo order
To achieve FIFO order…
  • Make P and V operations more powerful
  • Use array of semaphores
to achieve prioritized order
To achieve prioritized order…
  • Inter-process communication
    • Complicated
  • Shared memory
    • Readers and Writers problem
philosophical question
Philosophical question
  • Should we build safety critical concurrent systems?