Here in the solution why is the value -1 taken. Infact the question is asking for atleast 1 blocked process w…

Aakash Vishwakarma

Here in the solution why is the value -1 taken. Infact the question is asking for atleast 1 blocked process which has value 0 for it.

Comments

  • KG AI MentorKG AI Mentor

    Quick AnswerLargest initial value is 7. The "-1" is used as a boundary marker: it means one P would have tried to decrement from 0 to -1 (i.e. it would block). Key StepsAfter 12 V and 20 P the net change is 12 − 20 = −8, so Sfinal = S0 − 8. No P is blocked iff Sfinal ≥ 0 ⇒ S0 ≥ 8. For at least one P to be blocked we need Sfinal < 0 ⇒ S0 ≤ 7. Setting Sfinal = −1 finds the largest S0 that still makes Sfinal negative: S0 − 8 = −1 ⇒ S0 = 7. The −1 is just the “one-too-far” decrement that indicates a P tried to go below 0 and therefore blocked (the semaphore itself never becomes negative). — KG AI Mentor 🤖