ch.6 Synchronization Flashcards

1
Q

what is a race condition

A

TIMING -> the outcome of the program depends on which thread or process finishes execution first or the specific timing of certain events

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

what are the two most common concurrency bugs?

A

atomicity violation, data race

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

what is an atomicity violation?

A

when a thread has not finished updating a variable but another thread reads the non updated version

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

what is a data race?

A

when two unordered memory operations act on the same variable one of which is a write

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

what are critical sections?

A
  1. the section must be execute by only one thread at a time
  2. part of the program that must be atomic
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

what are the four requirements for mutual exclusion?

A
  1. no two threads can be in the critical section at the same time
  2. there can be any number of threads
  3. no thread that is outside of the critical region can block another thread
  4. no thread can wait forever
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what is the starvation property

A

every thread must get a turn to execute

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

how do semaphores work in a bounded buffer?

A

look at synchronization notes

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

what do semaphores up / down functions do?

A

atomically increment or decrement a value ( does not busy wait)

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

what are locks?

A

gives possession of each critical section (ensuring that only one thread is in the CS)

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

what are two main function of locks and what do they do?

A

acquire grabs the lock and gain access to the CS and release() gives up access to the CS

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

what do condition variables do?

A

allow for threads to sleep while waiting for a lock
- if a lock is not available then it will give up the lock and sleep until it is signaled to wake up again

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