Deadlock Dilemma: The Ultimate Quiz Quiz

  1. Deadlock Definition

    What is a deadlock in the context of concurrent programming?

    1. A situation where a program crashes due to memory errors.
    2. A situation where two or more threads are blocked indefinitely, waiting for each other to release resources.
    3. A condition where a thread is temporarily suspended.
    4. A type of race condition that corrupts data.
    5. A compiler error that prevents the program from running.
  2. Necessary Conditions

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

    1. Mutual exclusion
    2. Hold and wait
    3. No preemption
    4. Circular wait
    5. Priority inversion
  3. Mutual Exclusion

    What does the 'mutual exclusion' condition for deadlock mean?

    1. Multiple threads can access a resource simultaneously.
    2. A resource can only be held by one thread at a time.
    3. Threads are excluded from accessing certain parts of memory.
    4. The operating system excludes certain threads from running.
    5. Threads must exclude each other from using the CPU.
  4. Hold and Wait Explained

    Which scenario best describes the 'hold and wait' condition in a deadlock?

    1. A thread continuously waits for a resource without releasing any resources it already holds.
    2. A thread releases all its resources before requesting any new ones.
    3. A thread holds multiple resources and then waits for a specific amount of time before releasing them.
    4. A thread waits indefinitely for a resource, even if other resources are available.
    5. A thread attempts to acquire a resource that is currently being held by another thread.
  5. No Preemption

    What does 'no preemption' signify in the context of deadlock conditions?

    1. A resource can be forcibly taken away from a thread holding it.
    2. A thread can request a resource before releasing its current resources.
    3. A resource cannot be forcibly taken away from a thread holding it; the thread must release it voluntarily.
    4. The operating system cannot interrupt a running thread.
    5. Threads cannot be paused or resumed during execution.
  6. Circular Wait Scenario

    Which of the following scenarios exemplifies a 'circular wait' condition?

    1. Thread A waits for a resource held by Thread B, and Thread B waits for a resource held by Thread A.
    2. Thread A waits for a resource held by Thread B, but Thread B is not waiting for any resource.
    3. Thread A and Thread B both try to acquire the same resource simultaneously.
    4. Thread A and Thread B both release their resources before requesting new ones.
    5. Thread A waits for a resource, and Thread B is preempted while holding that resource.
  7. Deadlock Prevention Strategy

    Which strategy aims to prevent deadlocks by eliminating the 'circular wait' condition?

    1. Resource ordering (imposing a hierarchy on resource requests)
    2. Resource preemption (allowing resources to be forcibly taken away)
    3. Mutual exklusion
    4. Holding and Weighting
    5. Increasing CPU core count.
  8. Deadlock Avoidance vs. Prevention

    What is the key difference between deadlock prevention and deadlock avoidance?

    1. Prevention avoids deadlocks at runtime, while avoidance prevents them during compilation.
    2. Prevention aims to eliminate one or more of the necessary conditions, while avoidance allows deadlocks to potentially occur but avoids them by carefully allocating resources.
    3. Prevention is always more efficient than avoidance.
    4. Avoidance requires more overhead than prevention.
    5. They are the same.
  9. Banker's Algorithm Purpose

    What is the primary purpose of the Banker's Algorithm?

    1. To detect deadlocks after they have occurred.
    2. To prevent deadlocks by eliminating mutual exclusion.
    3. To avoid deadlocks by carefully allocating resources based on maximum potential needs.
    4. To resolve deadlocks by forcibly preempting resources.
    5. To ensure fair scheduling of threads.
  10. Deadlock Detection Technique

    Which technique is used to detect deadlocks when they occur?

    1. Resource allocation graphs
    2. Banker's algorithm
    3. Resource ordering
    4. Prevention
    5. Ignore and pray