Lecture 13: Synchronization 4 Flashcards

1
Q

“Readers/Writers Problem”

A

“Idea:
You have a buffer of updatable data (i.e.: no inserts & removes)
Threads:
Two kinds:
1. Readers
2. Writers
• some concurrency ok: multiple readers reading data
some concurrency not ok: writer must have exclusive
access to data
Synchronization rules:
Can allow access of:
• any number of readers at a time, or
• exactly one writer”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Solving with Semaphores:

A

“Basic Idea:
• binary semaphore (rwlock)
+
count of readers (rcount)
• 1st read acquires rwlock (rcount = 1)
• last reader releases rwlock (rcount = 0)
• need additional binary semaphore (mutex) to ensure exclusive access to rcount”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly