Char Coffman conditionssabhi hold karni chahiye: mutual exclusion, hold-and-wait, no preemption, aur circular wait. Detection assume karta hai ki hum inhe hone dete hain aur phir consequence dhundh te hain.
Available[1..m]: m resource types mein se har ek ke free instances.
Allocation[n][m]: process i abhi kitna hold kar raha hai.
Request[n][m]: process iabhi kya request kar raha hai (note: yeh request hai, Banker's ka "max need" nahi).
YEH KYU KAAM KARTA HAI: agar Requesti≤Work hai, toh process i jo maang raha hai woh mil sakta hai, woh run kar sakta hai, aur jo hold kar raha hai sab release kar dega — Allocationi pool mein wapas aayega. Hum optimistically resources unhe dete hain jo run kar sakte hain, free pool badhta jaata hai. Jis bhi process ko hum is tarah kabhi satisfy nahi kar sakte, woh genuinely stuck hai.
Detect hone ke baad, kam se kam ek Coffman condition todo. Teen families:
Recall Feynman: ek 12-saal ke bachche ko samjhao
Socho char bachche hain, har ek ke paas do khilaunon ke ek-ek aadhe hisse hain jo woh swap karna chahte hain, aur har ek doosre ka intezaar kar raha hai ki pehle woh apna aadha de. Koi nahi chhodta, toh sab freeze ho jaate hain — yahi deadlock hai. Teacher (OS) ek checklist lekar ghoomti hai: "Kya koi bhi abhi jo khilaune khule pade hain unse finish kar sakta hai?" Agar haan, woh bachcha kheelta hai, phir apne khilaune box mein wapas daal deta hai taaki doosre le sakein — aur teacher chalti rehti hai. Agar woh ek aisi jagah pahunch jaaye jahan koi bachcha kabhi nahi khel sakta, woh stuck hain. Theek karne ke liye woh ya toh ek bachche ko quit karwa deti hai aur khilaune le leti hai (termination) ya ek khilauna chhin leti hai aur de deti hai (preemption) — woh bachcha choose karti hai jis ka kam se kam progress zaaya ho.
Single-instance system mein, deadlock ke liye kaun si graph condition necessary AND sufficient hai?
Wait-For Graph (WFG) mein ek cycle hona.
Multiple resource instances ke saath cycle deadlock ke liye sufficient kyun nahi hai?
Koi doosra holder ek aisa instance release kar sakta hai jo waiting process ko satisfy kar de, toh cycle sab ko stuck kiye bina resolve ho sakti hai. Tumhe finishing simulate karni padegi.
Detection actual current Request use karta hai (baad mein, optimistic); Banker's Need = Max − Allocation use karta hai (worst-case, pehle se, unsafe states prevent karne ke liye).