Slides 9 Flashcards

1
Q

Define Deadlock

A

a state where each process/thread is waiting on another to release a lock → no progress is made

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

Define Livelock

A

states of the processes change, but none are progressing

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

Define starvation

A

one process does not get to run at all

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

Define unfairness

A

not all processes get equal opportunity to progress

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

What is the dining philosopher problem?

A

before eating, a philosopher must first grab two forks, immediately to the left & right
• philosopher then eats for a short time
• when done eating, the philosopher puts
down the forks in their original positions
• philosopher then thinks for a short time

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

What are important facts about mutex’s?

A

mutex is a synchronization mechanism used for
ensuring exclusive access to a resource in concurrent programs
• we can set it to True or False, just like a regular boolean variable
• but, if the lock is already locked, and some thread tries to also lock it,
then the calling thread will be automatically suspended… until whoever locked the lock unlocks it

only the thread that locks the mutex can unlock it
• a waiting queue is used to keep track of all threads waiting on
the mutex to be unlocked
• once the mutex is unlocked, one of the blocked threads will be
unlocked…
• note: which one thread gets unlocked is usually not predictable

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

What are the mutex methods?

A

phread_mutex_init(): creates mutex
phread_mutex_destroy(): destroys mutex
phread_mutex_lock(): locks mutex, block if already locked
phread_mutex_trylock(): lock a mutex or fail(non-blocking version)
phread_mutex_unlock(): unlock mutex

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