Deadlock Fundamentals in Multi-Core Systems Quiz

Explore essential concepts of deadlocks in multi-core environments, including conditions, examples, and prevention techniques. This quiz helps reinforce your understanding of synchronization challenges and resource management in concurrent systems.

  1. Definition of Deadlock

    Which statement best defines a deadlock in a multi-core system?

    1. A temporary slow-down of the system due to network delay.
    2. A point when there are too many resources available.
    3. A scenario where a process completes before releasing its resource.
    4. A situation where two or more processes are indefinitely blocked, each waiting for resources held by the others.

    Explanation: A deadlock occurs when processes cannot proceed because each is waiting for resources held by others, causing a permanent block. The second option does not describe indefinite waiting. The third distractor refers to resource abundance, which does not cause deadlocks. The fourth option mentions network delay, which is unrelated to deadlock conditions.

  2. Necessary Conditions

    Which of the following is NOT one of the four necessary conditions for a deadlock to occur?

    1. Mutual exclusion
    2. Circular wait
    3. Hold and wait
    4. Preemption

    Explanation: Preemption is not one of the necessary conditions for deadlock; in fact, lack of preemption is a requirement for deadlock. Mutual exclusion, hold and wait, and circular wait are all required conditions for a deadlock. Choosing 'preemption' shows an understanding that allowing resource preemption can help prevent deadlocks.

  3. Resource Allocation Scenario

    If Process A holds Resource 1 and waits for Resource 2, while Process B holds Resource 2 and waits for Resource 1, what situation is this an example of?

    1. Priority inversion
    2. Deadlock
    3. Starvation
    4. Load balancing

    Explanation: This is a classic example of deadlock, where both processes are stuck waiting for each other's resources. Starvation describes indefinite waiting due to scheduling, not mutual resource holding. Load balancing is unrelated to waiting or process blocking. Priority inversion involves lower-priority tasks delaying higher-priority tasks, not mutual waiting.

  4. Deadlock Prevention

    Which strategy can help prevent deadlocks in multi-core systems?

    1. Avoiding hold and wait by requiring processes to request all resources at once
    2. Increasing the number of CPUs only
    3. Allowing circular wait among processes
    4. Ensuring all resources are shared everywhere

    Explanation: Preventing hold and wait by requiring processes to request all needed resources at the outset can prevent deadlocks. Allowing circular wait enables deadlock. Simply sharing resources or adding CPUs does not address the fundamental conditions that can cause deadlock. The correct option removes the hold and wait requirement, effectively reducing deadlock risk.

  5. Deadlock Detection

    What is a typical method for detecting deadlocks in a multi-core operating system?

    1. Restarting all processes at intervals
    2. Increasing memory size
    3. Switching all processes to single-threaded mode
    4. Resource allocation graph analysis

    Explanation: Resource allocation graph analysis can reveal cycles indicative of deadlocks. Restarting processes is disruptive and not considered a detection method. Increasing memory does not impact deadlock detection. Forcing processes to single-threaded operation limits concurrency but does not detect deadlocks. The analysis method directly addresses the recognition of deadlock cycles.

  6. Starvation vs Deadlock

    How does deadlock differ from starvation in multi-core systems?

    1. Deadlock is permanent blocking due to resource cycles; starvation is repeated denial of resources due to scheduling.
    2. Starvation always leads to deadlocks.
    3. Deadlock only happens in single-core systems.
    4. In starvation, processes complete their execution faster.

    Explanation: Deadlock is caused by resource cycles and results in indefinite blocking, whereas starvation happens when a process is continually denied resources, but not due to cycles. Starvation does not always lead to deadlock. Faster execution is unrelated to starvation. Deadlocks can occur in both single-core and multi-core systems, so the last distractor is incorrect.

  7. Circular Wait

    Which scenario best describes the circular wait condition in deadlock?

    1. One process holds all resources at once.
    2. All resources can be preempted at any time.
    3. Each process holds at least one resource and waits for a resource held by the next process in the chain.
    4. No process requests any resource.

    Explanation: Circular wait involves each process holding a resource while waiting for another, creating a circle. Holding all resources at once prevents waiting and thus deadlock. Not requesting resources prevents deadlocks but does not describe circular wait. Allowing preemption breaks deadlock chains rather than forming them.

  8. Role of Mutual Exclusion

    Why is mutual exclusion necessary for deadlocks to occur in multi-core systems?

    1. Because at least one resource must be non-shareable for processes to wait.
    2. Because mutual exclusion prevents resource allocation.
    3. Because it allows resources to be infinitely shareable.
    4. Because mutual exclusion guarantees faster communication.

    Explanation: Mutual exclusion ensures that resources cannot be shared, leading to potential waiting and blocking. If resources were infinitely shareable, waiting would not occur, ruling out deadlocks. Mutual exclusion does not guarantee faster communication or prevent allocation; instead, it sets up the environment for possible contention.

  9. Handling Deadlocks

    Which of the following is a valid way to recover from a deadlock in a multi-core system?

    1. Doubling the number of locks
    2. Reducing the number of running threads
    3. Terminating one or more involved processes and reallocating resources
    4. Ignoring the situation and waiting indefinitely

    Explanation: Terminating processes helps break the deadlock cycle and free resources. Ignoring the deadlock results in indefinite blocking. Reducing thread count may not resolve the circular waiting. Doubling locks could actually increase contention and deadlock risk, not resolve it.

  10. Deadlock Example

    If two threads in a multi-core system each lock one file and then try to lock the other's file, causing both to stop progressing, what is this situation called?

    1. Cache coherence
    2. Synchronization error
    3. Throughput gain
    4. Deadlock

    Explanation: When both threads are waiting on resources held by each other, it creates a deadlock. Throughput gain refers to increased performance, which does not fit this scenario. Synchronization error can be a broad term, but specifically, this case is a deadlock. Cache coherence pertains to memory consistency among cores and is not relevant here.