Please enable JavaScript.
Coggle requires JavaScript to display documents.
Chapter 5 Process Synchronization Silberschatz - Operating System…
Chapter 5
Process Synchronization
Silberschatz - Operating System Concepts 9th
Monitors
Is an ADT (abstract data type) that includes a set of programmer defined operations that are provided with mutual exclusion within the monitor.
The critical-section problem
The problem is to design a protocol that the processes can use to cooperate
A solution must satisfy the following requirements
Mutual Exclusion
If one process is executing in its critical section, then other processes can be executing in their critical sections
Progress
Only the processes that are not executing in their remainder sections can participate in deciding which will enter its critical section
Bounded waiting
There exists a bound 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
Peterson’s solution
do{
flag[i]=true;
turn = j;while(flag[j]&&turn==j);
//critical section
flag[i]==false;
//remainder section
}while(true);
Synchronization hardware
3.Synchronization hardware
There are more solutions using techniques ranging from hardware to software-based APIs available to both kernel developers and application programmers.
test_and_set()
compare_and_wap()
4.Mutex Locks
Short for Mutual Exclusion
Has a boolean variable whose value indicated if the lock is available or not
Acquire()
release()
5.Semaphores
Implementation
typedef struct{
int value;
struct process * list;
}semaphore;
wait(semaphore * S){
S->value--;
if(S->value<o){ add this process to S->list;
block();
}
signal(semaphore *S){
S->value++;
if(S->value<=0){
remove a process P from S-> list;
wakeup(P);
}
}
Deadlocks and Starvation
Two or more processes are waiting indefinitely for an event that can be caused only by one of the waiting processes
Usage
To control access to a given resource consisting of an infinite number of instances
Priority Inversión
Solution is to use a priority-inheritance protocol
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
Is an integer variable that is accessed only through two standard atomic operations: wait() and signal()
Daniela Porras Quiros
2015071255