0
0
Operating Systemsknowledge~10 mins

Deadlock detection and recovery in Operating Systems - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to identify the condition that causes a deadlock.

Operating Systems
if (resource_allocation == [1]) {
    // Deadlock detected
}
Drag options to blanks, or click blank then click option'
Acircular_wait
Bresource_available
Cno_wait
Dpreemption
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing resource availability with deadlock condition.
Thinking preemption alone causes deadlock.
2fill in blank
medium

Complete the code to check if a process is part of a deadlock cycle.

Operating Systems
if (process_waits_for(process1, [1])) {
    // Process is in deadlock
}
Drag options to blanks, or click blank then click option'
Aresource
Bprocess2
Ccpu
Dmemory
Attempts:
3 left
💡 Hint
Common Mistakes
Checking if process waits for a resource instead of another process.
Confusing CPU or memory as the waiting entity.
3fill in blank
hard

Fix the error in the deadlock detection function by completing the missing condition.

Operating Systems
function detect_deadlock() {
    for each process in processes {
        if (process.state == [1]) {
            check_cycle(process);
        }
    }
}
Drag options to blanks, or click blank then click option'
Arunning
Bready
Cterminated
Dwaiting
Attempts:
3 left
💡 Hint
Common Mistakes
Checking running or ready processes instead of waiting.
Including terminated processes in deadlock detection.
4fill in blank
hard

Fill both blanks to complete the recovery step after detecting deadlock.

Operating Systems
function recover_deadlock() {
    select [1] to terminate;
    release [2] held by it;
}
Drag options to blanks, or click blank then click option'
Aprocess
Bresource
Cmemory
Dcpu
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to release CPU or memory directly instead of resources.
Terminating resources instead of processes.
5fill in blank
hard

Fill all three blanks to complete the deadlock detection algorithm snippet.

Operating Systems
for each [1] in system {
    if ([2] waits for [3]) {
        mark as deadlocked;
    }
}
Drag options to blanks, or click blank then click option'
Aprocess
Bresource
Dthread
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing threads with processes.
Swapping resource and process in the wait condition.