ch.7 Mutual Exclusion Flashcards

1
Q

what are the 3 mutual exclusion solutions?

A

strict alternation, Dekkers Algorithm, the bakery algorithm

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

what four things must be ensured for Mutual Exclusion?

A
  1. only one thread in CS
  2. any number of threads
  3. threads outside of CS cannot block another thread
  4. no thread can wait forever
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

what is the strict Alternation algorithm

A

uses a shared variable to determine who goes first
ex: int next = 0 blocks and int = 1 continues

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

which mutual exclusion properties does the strict algorithm work for?

A

only one thread in CS and can be extended to more than one thread

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

which mutual exclusion property does the strict algorithm not work for?

A

a thread can be blocked outside of the critical section
a thread can wait forever

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

What is Dekkers Algorithm?

A

unselfish algorithm -> each thread waits until the thread has completed their process (achieves all four mutual exclusion properties but it has issues)

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

what are some issues with Dekkers Algorithm?

A
  1. inefficient while loops (uses a lot of resources)
  2. potential to deadlock if both are waiting for the other to take their turn
  3. live lock can occur if each thread keep yielding to the other thread
  4. hard to scale
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

what is the bakery Algorithm?

A

an analogy : a bakery’s ticket counter
a. thread “enters” the “bakery”
b. thread “gets” the next ticket
c. thread waits for its turn

provides mutual exclusion

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

what is the best property of the bakery algorithm?

A

the algorithm does not depend on the output of a thread

ex: if there are concurrent read and write operations the algorithm does not depend upon a correct read, the read can return any arbitrary value!

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