Process Synchronization: Solution for Critical Section Problem | L 14 | Operating System | GATE 2022
Вставка
- Опубліковано 9 вер 2024
- The Great Learning Festival is here!
Get an Unacademy Subscription of 7 Days for FREE!
Enroll Now - unacademy.com/...
.. Click for free access to Educator's best classes: : www.unacademy....
For regular updates follow : unacademy.com/...
To purchase please click : unacademy.onel...
GATE Unlock25 Offer
Get flat 25% & FREE Extension
Join the new Foundation batches for GATE, ESE*, & PSUs 2024
➤ Subscribe today: unacademy.com/goal/gate-cs-it/NVLIA/subscribe?referral_code=VDEEP10
I never learn synchronization in such a interesting way!!! Love the way you teach. And examples are mind blowing... I wonder how you create it🤩
Can't believe such an amazing content for free.... Thanks sir🥰🥰
Exit section helps in letting us know that cs execution has completed
sorry sir lekin ye lecture bilkul nhi samaj aaya...........bs ye rat liya hai maine ki peterson soln is perfect.......baki kuch zyada samaj me nhi aaya
if flag[0] = true and than process p1 preempts and than p2 enters it will no be able to enter in the loop.
Great sir
Superab , comparison with real life example make it very easy
start 8:35
The most interesting and best lecture
Start 8:30
You're the best. Checking your timestamp is the first thing I do before starting the video
@@roopalsood9817 +1
Bro, Whenever I open the Video, I search for ur comment. Ur doing great Job. Thnx Dude
No doubt sir boht acha teach krte hain.. but agr video ki speed normal h to pakka tum sone Wale ho it happens with me many times. I always in 1.5 speed
2x always 😅
Make preemption at all possible instructions to check for solution requirements
See solution 2 for more understanding it emphasizes mainly on progress I.e if a process is interested to enter cs it can enter if the cs section is free of any process
54:50 Peterson's solution
Ready sir
28:42 english me kuch bol deta hu ....... cool lagunga
In Using lock variable, how P0 process starts while ke andr true likha hai. Aur lock false pe set hai😢
thank you sir
Best...
Bhagwan 🙏🙏
22:56
There is a deadlock in Peterson's solution
How it is correct??
If flag 0 true turn =1
Premept
Now flag 1 true
Premept
Now we can't execute any process
Deadlocked
It's not actually deadlock, it doesn't satisfy progress if there is only two processes.
Let's proceed further,
If flag 0 true turn =1
Premept
Now flag 1 true
Premept
condition for P0 satisfied, P0 waiting .... preempt
turn = 0
condition for P1 satisfied, P1 waiting ... preempt
condition false for P0 as turn != 1
P0 enters into the critical section.
Nope. Deadlock won't occur. Check out the following explanation:-
Initially, status of variables -
flag[0] = false
flag[1] = false
turn = 0 // could be either 0 or 1. Let's assume that it's 0, it won't make a difference.
Process 0 running:
flag[0] = true
turn = 1
Preempts
Status of variables -
flag[0] = true
flag[1] = false
turn = 1
Process 1 running:
flag[1] = true
Preempts
Status of variables -
flag[0] = true
flag[1] = true
turn = 1
Process 0 running:
while(flag[1] && turn == 1); // while condition resolves to true, process 0 is stuck in an infinite loop
After some time, preempts
Status of variables -
flag[0] = true
flag[1] = true
turn = 1
Process 1 running:
turn = 0
while(flag[0] && turn == 0); // condition resolves to true, process 1 also stuck in an infinite loop
After some time, preempts
Status of variables -
flag[0] = true
flag[1] = true
turn = 0
Process 0 running:
while(flag[1] && turn == 1); // now it resolves to false because process 1 had changed the value of turn to 0
Process 0 executes the critical section and sets flag[0] as false
Preempts
Status of variables -
flag[0] = false
flag[1] = true
turn = 1
Process 1 running:
while(flag[0] && turn == 0); // resolves to false as flag[0] is false
Process 1 executes the critical section and sets flag[1] as false
Preempts
Status of variables -
flag[0] = false
flag[1] = false
turn = 1
Both processes have executed the critical section one time till now.
Let's say process 0 wants to enter the critical section again
Process 0 running:
flag[0] = true
turn = 1
while(flag[1] && turn == 1); //resolves to false as flag[1] is false
Process 0 enters the critical section, executes it, and leaves the section after setting flag[0] as false
Preempts
Status of variables -
flag[0] = false
flag[1] = false
turn = 1
Process 1 running:
flag[1] = true
turn = 0
while(flag[0] && turn == 0); // resolves to false as flag[0] is false
Process 1 enters the critical section, executes it, and leaves the section after setting flag[1] as false
Preempts
And the story goes on...
I hope that I have cleared your doubt ;)
@@mandeepdaksh376 ik number bhai. Maza aagya
If flag 0 = true
turn =1
Premept
Now flag 1 = true
Premept
Now we can't execute any process
If preemption can happen while process 0 is not able to enter the CS (The way you preempted). Then in the same way we can achieve "Progress" for "Turn variable method".
(However Process 0 should enter because then now we can say that the "Progress" is holding.)
please clarify...
@@mandeepdaksh376 thanks 👍
46:27
Mujhe to sir ye samajh main nehi aata ki , khasne par , ya chinkh ne par sorry bolne ki kya zaroorat hai ? Sarir hai to hoga hi sabka hota hai
Zarrorat to aapke comment ki bhi nhi thi bhai. Aur na hi mere reply krne ki. But krrhe h na dono hi.
Aur ye etiquettes m aate h... Agr aap sorry nhi bhi bologe to aapko jail nhi hogi na hi koi FIR..
Sir lock is'nt a shared variable for P0 and P1 ??
ur answer is answered by sir 45:00
One thing I can say is these Desi teachers r no where close to the calibre of foreign teachers..
Why so???
Nptel os and harry.
Padhate kam bak***di jyaada krte hain ye.
Prices rising by 10% on 30th April'23 11:59 PM
Flat 25% off & up to 4 Months Extra*! Save up to 53%
Subscribe Now - unacademy.com/goal/gate-cs-it/NVLIA/subscribe?plan_type=iconic
Unacademy GATE & ESE Ultra Combat
23rd April at 11:00 AM
Enroll Now: unacademy.com/scholarship/ULTRACOMBATGATEESE
..
27:26