Classic Synchronization Problems Flashcards

1
Q

What are the 3 classic synchronization problems?

A
  • Producer-Consumer AKA bounded-buffers
  • Readers-Writers
  • Dining-Philosophers
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

The classic synchronization problems are ________ that can be used to model money ______ ________ problems

A

abstractions, resource, sharing

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

The classic synchronization problems can be used to _______ newly proposed synchronization problems

A

test

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

In the bounded-buffer problem, what do producers and consumers do, and where?

A

producers insert into a buffer, and consumers remove from buffer

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

In the bounded-buffer problem, it is possible to have _________ producers and consumers

A

multiple

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

In the bounded-buffer problem, what are 3 issues?

A
  • Violation of buffer structure
  • Producing when full
  • Consuming when empty
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

In the bounded-buffer problem, the solution uses ______ semaphores

A

three

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

In the bounded-buffer problem, what are the 3 semaphores used in the solution called, and what are they initialized to?

A
  • mutex: 1
  • full: 0
  • empty: N
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

In the bounded-buffer problem, the producer ________ full and _________ empty

A

increments, decrements

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

In the bounded-buffer problem, there is a _______ between producers and consumers

A

symmetry

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

In the readers-writers problem, _____ is shared among multiple processes

A

data

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

In the readers-writers problem, readers only _____ and do not perform any ________

A

read, updates

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

In the readers-writers problem, writers can _____ and ________

A

read, write

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

In the readers-writers problem, what are the 2 requirements for a solution?

A
  • Allow multiple concurrent readers and no writer

- Allow one writer and no reader

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

In the readers-writers problem, a solution as provided by the OS and runtime libraries called __________ in Pthread

A

pthread_rw_lock*

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

In the readers-writers problem, a process can ask for ______________ lock either in read or write mode

A

readers-writes

17
Q

In the readers-writers problem, when should you use reader-writer locks? (2 reasons)

A
  • When it’s easy to identify readers and writers

- When there are more readers than writers

18
Q

reader-writer locks are more ________ to implement than mutex

A

complex

19
Q

reader-writer locks have more _________ because of coordination between readers and writers

A

overhead

20
Q

Why do reader-writer locks have high concurrency?

A

They allow multiple readers

21
Q

In the reader-writer lock struct, what 3 values are there, and what are they initialized to?

A
  • read_count: 0
  • rw_mutex: 1
  • mutex: 1
22
Q

In the reader-writer lock struct, what does read_count do?

A

tracks the number of reader holding the lock

23
Q

In the reader-writer lock struct, the rw_mutex allows either many _______ or one _______

A

readers, writer

24
Q

In the reader-writer lock struct, the mutex protects __________

A

read_count

25
Q

The dining philosophers problem models ________ processes sharing __________ resources

A

multiple, multiple

26
Q

What is the goal of the dining philosophers problem?

A

To coordinate forks utilization among all philosophers

27
Q

In the dining philosophers problem, a broken solution is to use one ________ per fork. This causes a _________ when all philosophers grab their left forks at the same time

A

semaphore, deadlock

28
Q

In the dining philosophers problem, what are 3 working solutions?

A
  1. require at least one philosopher acquire forks in a different order
  2. timeout + retry
  3. make sure no neighbours are eating (using condition variables)
29
Q

What are 2 functions condition_variable x has?

A

x. wait()

x. signal()

30
Q

condition_variable x.wait() ______ the calling thread

A

suspends

31
Q

condition_variable x.signal() ______ the one of ANY process that invoked wait

A

resumes

32
Q

A _______ is an abstract data type for synchronization

A

monitor

33
Q

A monitor __________ mutual exclusion operations

A

encapsulates

34
Q

A monitor only has one active ______ within it

A

process

35
Q

A monitor is implemented using ________ internally

A

semaphores

36
Q

A ________ priority process must wait if the resource it requires is being used by a __________ priority process

A

higher, lower

37
Q

Imagine a scenario with processes PL, PM, and PH and PL has a resource desired by PH. PL is running first. What happens when PM becomes runnable? What is this event called?

A

PM preempts PL, affecting the waiting time for PH. This is called a Priority inversion

38
Q

Imagine a scenario with processes PL, PM, and PH and PL has a resource desired by PH. PL is running first. How do we prevent PM from affecting PH’s waiting time? What is this called?

A

PL inherits H since PH is waiting on resource held by PL so PM cannot preempt. This is called priority inheritance.