Week 4 Flashcards

1
Q

What is process synchronization?

A

Process synchronization involves managing processes that share the same memory space. It maintains consistency of data by allowing only one process to make changes to the shared memory at one time.

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

What is the race condition?

A

A race condition is where multiple processes access and manipulate the same data simultaneously and the outcome of the execution depends on the order in which the access takes place.

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

What is the critical section problem?

A

The critical section problem is to make sure that only one process should be in a critical section at a time.

The critical section problem is to design a protocol that processes can use to synchronize their activity so as to cooperatively share data.

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

What is the critical section in a process?

A

The critical section is a segment of code in a process where the process may be accessing and updating data that is shared with at least one other process. When one process is executing its critical section, no other process is allowed to execute it’s critical section.

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

What is the structure of a process?

A
  1. Entry Section - Requests permission to enter critical section
  2. Critical Section - The segment of code where the process may be accessing and updating shared data
  3. Exit Section - Exits critical section
  4. Remainder Section - Contains all remaining code
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are the three requirements a solution to the critical section problem must satisfy?

A
  1. Mutual Exclusion - If a process is executing in it’s critical section, then no other process can be executing in their critical sections
  2. Progress - If no process is executing in its critical section and some process wish to enter their critical sections, then only those processes that are not executing in their remainder sections can participate in deciding which will enter its critical section next, and this selection cannot be postponed indefinitely.
  3. Bounded waiting - There exists a bound, or limit, on the number of times that other processes are allowed to enter their critical sections after a process has made a request to enter its critical section and before that request is granted.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What Peterson’s solution?

A

Peterson’s solution is a solution to the critical section problem. It is restricted to two processes that alternate execution between their critical sections and remainder sections. It requires that both processes share two properties which are a Boolean flag and int Turn. When a process is executing in a critical section, then the other process executes the rest of the code.

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

What are the limitations to Peterson’s solution?

A

The limitations to Peterson’s solution are:
1. It involves busy waiting (process is waiting for condition to be satisfied in a tight loop)
2. Not guaranteed to work on modern architectures
3. May give inconsistent or unexpected results for multithreaded applications

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

What is the mutex lock?

A

The mutex lock is a software tool which solves the critical section problem. The mutex lock is used to protect critical sections and thus prevent race conditions. A process must acquire the lock before entering a critical section using the acquire() function, and release the lock when it exits the critical section using the release() function

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

What is a semaphore?

A

Semaphore is an integer variable S, that is initialized with the number of resources present in the system and is used for process synchronization. It uses two functions to change the value of S those being wait() and signal(). Only one process can change the value of S at a particular time.

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

What are the two types of Sempahore?

A
  1. Counting Semaphore - Counting semaphores are set to the maximum amount of processes that can access the resource at one time. The counting semaphore indicates that a process can access the resource if it has a value greater than 0.
  2. Binary Semaphore - When the semaphore is set to 1, it means that some process is working on its critical section, and if it is set to 0 that means that any process can enter the critical section.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is a deadlock?

A

A deadlock is a situation where two or more processes are waiting for each other.

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

What are the four conditions that when held simultaneously can lead to a deadlock?

A
  1. Mutual exclusion: only one process can use a resource at a time.
  2. Hold and wait: A process holding at least one resource is waiting to acquire additional resources held by other processes
  3. No pre-emption: A resource cannot be pre-empted (acquired) by another process forcefully. Need to wait.
  4. Circular wait: P0 is waiting for a resource held by P1, P1 is waiting for a resource held by P2, and P2 is waiting for a resource held by P0.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are the 3 methods of handling deadlocks?

A
  1. Ignore the problem and pretend that deadlocks never occur in the system: used by most operating systems, including UNIX
  2. Allow the system to enter a deadlock state and then recover
  3. Ensure that the system will never enter a deadlock state through either:
    - Deadlock prevention
    - Deadlock avoidance
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are the methods of deadlock prevention?

A
  1. Hold and Wait - ensuring that whenever a process requests a resource, it does not hold any other resources.
  2. No pre-emption - forcefully pre-empt that resource from the process that is holding that resource. By doing so, we can remove the deadlock
  3. Circular wait - Impose a total ordering of all resource types to require that each thread requests resources in an increasing order of enumeration
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are the 3 methods of deadlock avoidance?

A
  1. Each process declares the maximum number of resources of each type that it may need.
  2. Deadlock avoidance algorithm dynamically examines the resource-allocation state to ensure that there can never be a circular wait condition.
  3. Resource-allocation state is defined by the number of available and allocated resources, and the maximum demands of the process.