Deadlock occurs when two or more processes are blocked indefinitely, each waiting for the other to release a resource. This mutual blocking prevents any of the processes from continuing their execution.
Which of the following is a necessary condition for a deadlock to occur?
A Mutual Exclusion
B Task Synchronization
C Process Scheduling
D Resource Allocation
Mutual exclusion is a necessary condition for deadlock. It occurs when at least one resource must be held in a non-shareable mode, preventing other processes from accessing it while it is in use.
Which technique is used by operating systems to prevent deadlock?
A CPU Scheduling
B Swapping
C Priority Scheduling
D Resource Allocation Graph
A Resource Allocation Graph (RAG) is used to prevent deadlock by tracking which processes hold which resources and which resources are requested. It helps detect cycles that could lead to deadlock, allowing the system to avoid it.
What is a semaphore in the context of operating systems?
A File Management Tool
B Task Management Tool
C Synchronization Mechanism
D Memory Management Tool
A semaphore is a synchronization mechanism used to control access to shared resources in concurrent programming. It ensures that only one process or thread can access a critical section at any given time.
Which of the following is an advantage of using a mutex for synchronization?
A Avoids Race Conditions
B Increases CPU Usage
C Simple to Implement
D Faster Memory Access
A mutex (short for mutual exclusion) prevents race conditions by ensuring that only one thread can execute a critical section at a time. This guarantees the integrity of shared resources and prevents data corruption.
Which of the following is a primary method for avoiding deadlock in an operating system?
A Priority Scheduling
B Deadlock Detection
C Resource Pre-allocation
D Process Synchronization
Deadlock avoidance can be achieved by resource pre-allocation, where the operating system ensures that all resources needed by a process are allocated before the process starts. This prevents circular wait conditions.
What is the function of the “wait” operation in a semaphore?
A Synchronize Threads
B Request Resource Access
C Process Scheduling
D Release Resource
The “wait” operation is used in semaphores to request access to a shared resource. If the resource is available, the process proceeds; if not, it is blocked until the resource becomes available.
What is the purpose of the “signal” operation in a semaphore?
A Terminate Process
B Allocate Memory
C Synchronize Processes
D Release Resource
The “signal” operation in a semaphore is used to release a resource that was previously acquired by another process. This operation unblocks other processes waiting for the resource, allowing them to continue execution.
In which situation is deadlock detection most commonly used?
A Post-Deadlock Recovery
B Resource Allocation
C Process Synchronization
D Preemptive Scheduling
Deadlock detection is typically used in systems where deadlock cannot be avoided. The system detects deadlock after it has occurred and attempts to recover by terminating processes or rolling back transactions to resolve the deadlock.
Which of the following is a method for recovering from deadlock in an operating system?
A Task Preemption
B Memory Swapping
C Process Termination
D Priority Scheduling
One method for recovering from deadlock is process termination. The operating system may choose to terminate one or more processes involved in the deadlock to break the cycle and free up resources for other processes.
Which of the following conditions must be satisfied for deadlock to occur in an operating system?
A Circular Wait
B High Resource Demand
C Task Scheduling
D Multiple Processes
Circular wait occurs when each process in a set is waiting for a resource held by another process in the set. This creates a closed loop that causes all processes to be blocked, resulting in a deadlock situation.
What is the main purpose of using a resource allocation graph (RAG)?
A Detect Deadlocks
B Allocate Memory
C Track Process States
D Manage CPU Scheduling
A Resource Allocation Graph (RAG) helps in detecting deadlocks by visualizing the relationships between processes and resources. It shows which processes hold which resources and which resources are requested, helping to identify potential deadlock conditions.
What does the term “race condition” refer to in concurrent programming?
A Task Scheduling Issue
B Resource Contention
C Memory Access Conflict
D Multiple Processes
A race condition occurs when two or more processes attempt to modify shared data at the same time, leading to unpredictable results. Proper synchronization mechanisms like semaphores or mutexes are used to avoid race conditions.
What is the main difference between a mutex and a semaphore?
A Semaphore restricts thread access
B Mutex is for thread synchronization
C Mutex allows multiple threads
D Semaphore uses priority scheduling
A mutex is a synchronization tool used to ensure that only one thread can access a critical section at a time. A semaphore, on the other hand, can allow multiple threads to access shared resources, depending on its value.
Which of the following algorithms is used to prevent deadlock?
A First-Come, First-Served
B Shortest Job First
C Banker’s Algorithm
D Round Robin
The Banker’s Algorithm is used to prevent deadlock by allocating resources only if the system remains in a safe state after the allocation. It simulates resource allocation and checks if the system can avoid deadlock.