Process Synchronization (race can corrupt data and how to prevent it (The…
system deadlock and livelock can occur
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
detect and recover from deadlocks
Recover from the deadlock when the detection algorithm determines that a deadlock exists.
Provide an algorithm that to determine whether the system has entered a deadlock state.
Maintain information about the current allocation of data items to transactions.
race can corrupt data and how to prevent it
The hold and wait or resource holding conditions may be removed by requiring processes to request all the resources they will need before starting up
The no preemption condition may also be difficult or impossible to avoid as a process has to be able to have a resource for a certain amount of time, or the processing outcome may be inconsistent or thrashing may occur
Removing the mutual exclusion condition means that no process will have exclusive access to a resource.
The final condition is the circular wait condition.
detect and recover from starvation
Detection of cycle is necessary but not sufficient condition for deadlock detection, in this case system may or may not be in deadlock varies according to different situations.
In this case for Deadlock detection we can run an algorithm to check for cycle in the Resource Allocation Graph. Presence of cycle in the graph is the sufficient condition for deadlock.
process can become deadlocked
Deadlock is a situation when two threads are waiting for each other and the waiting is never ends.
threads are also waiting for each other
Here both threads cant completes their tasks