Week 4 - Synchronization Flashcards

1
Q

Other types of synchronization

A

thread i sends a message to thread j:

recieve operation in thread j cannot complete until send operation in thread i is reached.

Send cannot complete until thread j reaches recieve.

Join Synchronization: between parent and child threads. completes operation in parent when child terminates.

Barrier Synchronization:
across a group of N processes. no thread completes its barrier operation until all N threads have reached their barrier operation.

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

General Synchronization

A

consists in a particular thread having to wait until some condition is created by one or more other threads.

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

Dijkstra’s semaphores

A

are one rather general mechanism for achieving different kinds of synchronization.

P(S) decrease semaphore, but not below zero
V(S) increase semaphore.

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

Notification synchronization

A

compare with send/receive synchronization.

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

Resources

A

Computer systems have many kinds of resources, that can only be accessed by one process or thread at a time.

example: physical devices like printers.

if two threads update a shared data structure can corrupt.

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

Deadlocks

A

Resource deadlocks can occur when processes (or threads) need to acquire access to more than one exclusive resource (printer or scanner for e.g.)

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

Deadlock

A

Deadlock is a situation where a process or a set of processes wait indefinitely for an event that can never occur.

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

Deadlock Modelling

A

Resource deadlock can be modelled using a Resource Allocation Graph, which shows:

  • Which processes are requesting which resources.
  • Which resources have been granted to which processes.

If graph contains no cycles = no deadlock.

If graph contains a cycle = deadlock.

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

Resource Allocation Graphs (Revise directed graphs. SLIDE 15,16,17)

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

Deadlock Detection and Recovery

A

Allows system to enter deadlock state.

Runs Detection algorithm periodically to check.

Performs Recovery scheme if deadlock.

To detect deadlock, search for a cycles in the Resource Allocation Graph.

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

Deadlock Detection
(Slide 20)

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

Deadlock Recovery

A

Crudely - kill processes until the deadlock cycle is eliminated.

“Survivors” get the resources.

Commonly used in Relational Database Management Systems, where transactions identified as causing deadlock can be “rolled back”.

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

Deadlock Avoidance

A

The idea here is to keep the system “safe” – avoid entering “unsafe” states which may later turn into a deadlock.

-classic deadlock scenario of two processes sharing resources

-Each process has its own “instruction counter”.

-If we plot these as two axes of a graph, behaviour of whole system is represented as a trajectory in this graph, moving upwards and to the right.

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

Two Processes and One Resource (Slide 23, 24)

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

Two Processes and Two Resource (Slide 25, 26)

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

Unsafe Region (Slide 27,28)

A
17
Q

Banker’s Algorithm (Dijkstra,1965)

A

Basic idea:

Requires all processes to declare the max # of resource units that they may request.

Keeps track of current allocation for each process and their current “needs” (“max” – “has”).

When receives a request, “pretend” to honor the request, and

Try to fulfill the “needs” of all other processes in some order so as to check whether or not granting the request will lead to a safe state.

If safe, grant request; otherwise, deny request.