slides07 - Synchronization Techniques Flashcards

1
Q

Concurrent processes

A

Processes that are aware of each other and directly or indirectly work together and may affect the execution of the other

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

Race conditions & how to avoid them

A
  • When two or more processes are reading/writing shared data and final result depends on who runs first
  • Avoid them by prohibiting more than one process reading/writing shared data at the same time - mutual exclusion
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Critical section

A
  • Part of program that accesses shared data
  • No two processes should be in their CS at the same time
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Requirements of a CS

A
  1. No two processes may simultaneously be in their CS
  2. No assumptions be made about speeds or number of CPUs
  3. No process running outside its CS may block other processes
  4. No process should have to wait forever to enter its CS
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Implementing CS using lock variable

A
  • if lock == 0 set lock = 1 and enter_CS; if lock == 1 wait until lock becomes 0
  • does not work because its still a shared variable
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Strict alternation

A
  • Two processes take turns entering CS using global variable set to either 1 or 0 (global variable switched after program exists its CS)
  • Drawback: can lead to starvation (one process waiting indefinitely for the other process thats not in its CS)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Peterson’s Algorithm

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