Mod 2: Sync Problems Patterns Flashcards

1
Q

What are the most common issues with synchronization?

A

(1) Race Condition
(2) Deadlock
(3) Livelock
(4) Starvation

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

How can synchronization be done?

A

(1) Mutual Exclusion
(2) Condition Synchornization

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

When does a race condition typically happens?

A

When threads get simultaneous access to update a shared variable

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

What can a race condition cause?

A

Unpredictable values of shared variables, as a direct result of the unpredictability of the order in which the threads execute

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

What can we solve race conditions?

A

Execute the critical section in an atomic operation to ensure thread safety

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

What is a race condition?

A

They occur when two computer program processes, or threads, attempt to access the same resource at the same time and cause problems in the system

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

What is “starvation”?

A

When an action in a concurrent programming situation never get executed, i.e when a thread is unable to gain access to a shared resource

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

When does “starvation” occur?

A

When shared resources are made unavailable for long period of time by “greedy” threads

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

How do we avoid starvation?

A

By letting every thread get a fair amount of time, something that is usually a task for the OS scheduler and not something we neccessarily can affect

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

What is “deadlock”?

A

A situation when two or more threads are blocked forever, waiting for each other. In deadlock the threads are in a waiting-state.

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

What is “livelock”?

A

Livelock occurs when two or more processes continually repeat the same interaction in response to changes in the other processes without doing any useful work.

eg. threadA is waiting for threadB, and threadB are waiting for threadA

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

What is the difference between livelock and deadlock?

A

Thread in deadlock are in a waiting-state and threads in livelock are in a running-state

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

What is a “barrier”?

A

Synchronization points that processes/threads must reach before any of them are allowed to proceed

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

What does a safety property mean?

A

That each process/thread should never enter a bad state, i e. state in which some variables have faulty values, to avoid corrupt shared data

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

What does a liveness property mean?

A

That each process/thread should have liveness property, i e. process/thread eventually enter a good state, in which variables have correct values

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

What are examples of safety propeties?

A

Mutual exclusion and absence of deadlock