Operating Systems Ch. 5: Process Synchronization
Solution to Critical Section Problem Requirements (3)
1. Mutual Exclusion 2. Progress 3. Bounded Waiting
A deadlock situation can arise if the following four conditions hold simultaneously in a system:
1. Mutual exclusion. At least one resource must be held in a nonsharable mode; that is, only one process at a time can use the resource. If another process requests that resource, the requesting process must be delayed until the resource has been released. 2. Hold and wait. A process must be holding at least one resource and waiting to acquire additional resources that are currently being held by other processes. 3. No preemption. Resources cannot be preempted; that is, a resource can be released only voluntarily by the process holding it, after that process has completed its task. 4. Circular wait. A set {P0, P1, ..., Pn} of waiting processes must exist such that P0 is waiting for a resource held by P1, P1 is waiting for a resource held by P2, ..., Pn−1 is waiting for a resource held by Pn, and Pn is waiting for a resource held by P0.
a process may utilize a resource in only the following sequence:
1. Request. The process requests the resource. If the request cannot be granted immediately (for example, if the resource is being used by another process), then the requesting process must wait until it can acquire the resource. 2. Use. The process can operate on the resource (for example, if the resource is a printer, the process can print on the printer).
Monitor
A high-level language construct that guarantees mutual exclusion of processes.
Process Synchronization/ Coordination
The idea of getting our processes coordinated so that we don't have race conditions.
Swap Operation
The process of switching processes in and out of execution.
Entry Section
The section of code that process must have to request to enter its critical section.
Counting Semaphore
The value of this semaphore can be over an unrestricted domain.
Binary Semaphore
The value of this semaphore must either be 0 or 1.
Bounded Waiting
There exists a limit on the number of times that process can enter their critical section based on the number of requests to get they made.
Condition Variable
These are used with monitors as ways to make sure processes either wait or signal other processes from modifying the variables.
Progress
This cannot be postponed indefinitely, and is described as the following: If no processes are in their critical section and some want in then only those that are not in their remainder section can come in. some process p enters its Critical section next.
Condition Variable signal operation
This condition command tells processes that they may now execute their code.
Condition variable wait operation
This condition command tells processes to wait.
Semaphore wait/acquire operation
This is a command that makes semaphores stop executing before they can enter their critical section.
Semaphore
This is an integer variable that, apart from initialization, is accessed only through two standard atomic operations: wait and signal.
Peterson's Solution
This is restricted to two processes that alternate between processes and their respective critical and remainder sections.We now prove that this solution is correct. We need to show that: 1. Mutual exclusion is preserved. 2. The progress requirement is satisfied. 3. The bounded-waiting requirement is met.
Atomic
This is the same thing as one uninterruptible unit. An example is being able to make two operations as one.
Exit Section
This is the section that follows the critical section.
Critical Section Problem
This is to design a protocol that the processes can use to cooperate. The section of code implementing this request is the entry section. The critical section may be followed by an exit section. The remaining code is the remainder section.
Deadlock
This means that no processes are making any progress.
Priority Inversion
This occurs in systems with more than two priorities, and is described as when a higher-priority needs to use resources that are currently accessed by a lower-priority process.
Semaphore signal/release operation
This operation lets other processes know that are waiting that they can now enter their critical section.
Priority Inheritance protocol
This protocol states that all processes that are accessing resources needed by a higher-priority process inherit the higher priority until they are finished with the resources in question.
Critical Section
This the section of code that multiple processes could modify certain variables in.
Generally speaking, we can deal with the deadlock problem in one of three ways:
We can use a protocol to prevent or avoid deadlocks, ensuring that the system will never enter a deadlocked state. • We can allow the system to enter a deadlocked state, detect it, and recover. • We can ignore the problem altogether and pretend that deadlocks never occur in the system.
TestAndSet Operation
We test to see if we can enter the critical section and then we set the new value.
Race Condition
When several processes access and manipulate the same data concurrently and the outcome of the execution depends on the particular order in which the access takes place.
Busy Waiting
While a process is in its critical section, any other process that tries to enter its critical section must loop continuously in the call to acquire().
preemptive kernels
allows a process to be preempted while it is running in kernel mode.
nonpreemptive kernels
does not allow a process running in kernel mode to be preempted
critical sections handling approaches
in operating systems: preemptive kernels and nonpreemptive kernels.
locking
protecting critical regions through the use of locks.
mutex lock
term mutex is short for mutual exclusion.) We use the mutex lock to protect critical regions and thus prevent race conditions. That is, a process must acquire the lock before entering a critical section; it releases the lock when it exits the critical section.
system resource-allocation graph
where deadlocks can be described more precisely in terms of a directed graph
abstract data type (ADT)
ADT—encapsulates data with a set of functions to operate on that data that are independent of any specific implementation of the ADT.
Starvation/ Indefinite blocking
Also known as indefinite blocking, this is a situation in which processes wait indefinitely within the semaphore.
Atomic operation
An operation that completes in its entirety without interruption
Spinlock
Any mutex lock that uses busy waiting is called this because of the continuous looping.
Mutual Exclusion
If process P1 is currently in its critical section then we want no other processes executing in their critical sections.
Remainder Section
If there is any more code after the exit section then the remaining code is part of this section.