Process Synchronization and Deadlock Flashcards
What is a race condition?
occurs when two or more processes or threads are trying to access shared resources (e.g., memory, files, variables) simultaneously, and the final outcome depends on the order in which they execute.
What is process synchronisation?
refers to the techniques and mechanisms used to ensure that multiple processes or threads can work together harmoniously without causing conflicts, data corruption, or unpredictable behavior.
T/F Cooperating process can affect or be affected by the execution of another process
True
What is starvation?
A situation in which a runnable process is overlooked indefinitely by the scheduler; although it is able to proceed it is never chosen.
What is the critical section?
a section of code where a process or thread accesses shared resources or variables that could lead to race conditions or conflicts if not synchronized properly.
In a critical section, only one process or thread is allowed to execute at a time to prevent data corruption or unpredictable behavior.
What is mutual exclusion?
The property that ensures that only one process or thread at a time can access and execute a specific critical section of code.
What is bounded waiting?
It guarantees that there is a limit on the amount of time a process or thread must wait to access a shared resource while other processes or threads are using it.
What is progression?
It says that if no process is using the resource no process should be able to hold on to it.
List some locking mechanisms used in process synchronising
test-and-set, WAIT and SIGNAL, semaphores and monitors.
Describe the Test and Set method
a processor atomically reads the current state of a lock and sets it to a “locked” state in a single operation, enabling exclusive access to a critical section.
What are semaphores?
They are a type of variable that can be used to manage the execution of multiple processes or threads.
Can be thought of as a counter that helps in coordinating access to critical sections of code.
What is deadlock?
A situation where two or more processes or threads are unable to proceed because each is waiting for the other to release a resource, resulting in a cyclic waiting condition.
What are the four conditions of Deadlock?
- Mutual exclusion: at least one resource must be held in a non sharable mode.
- Hold and Wait: Processes must hold at least one resource and wait for additional resources that are currently held by other processes
- No preemption- we cannot forcefully take a resource from a process.
- Circular Wait: There exists a circular chain of processes, each waiting for a resource that’s held by the next process in the chain.
What is deadlock prevention?
Deadlock Prevention aims to prevent at least one of the necessary conditions for deadlock from occurring by enforcing restrictions on resource allocation or process behavior, potentially sacrificing system efficiency.
What is deadlock avoidance?
Involves dynamically analyzing the system state to ensure safe resource allocation, allowing processes to request resources based on a prediction of future needs.