Тёмный

L-3.12: Solution of Readers-writers Problem using Binary semaphore 

Gate Smashers
Подписаться 2,1 млн
Просмотров 471 тыс.
50% 1

Опубликовано:

 

14 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 450   
@aryansingh2105
@aryansingh2105 3 года назад
- The mutex semaphore is used to ensure mutual exclusion when the variable read count is updated. - The read count(rc) variable keeps track of how many processes are currently reading the object. - The semaphore rw_mutex(db) functions as a mutual exclusion semaphore for the writers. It is also used by the first or last reader that enters or exits the critical section. - It(db) is not used by readers who enter or exit while other readers are in their critical sections. ** Note that, if a writer is in the critical section and n readers are waiting, then one reader is queued on rw_mutex(db), and n − 1 reader are queued on the mutex. Also observe that, when a writer executes signal(rw_mutex), we may resume the execution of either the waiting readers or a single waiting writer. The selection is made by the scheduler. -> From Galvin
@avnishkumar6780
@avnishkumar6780 2 года назад
well summarized . thanks man
@shubhamyache7867
@shubhamyache7867 2 года назад
comments like this should be pinned these are very informative.
@sagnikchatterjee4057
@sagnikchatterjee4057 5 лет назад
I am simply spellbound by your way of teaching. Just speechless . Made tough concepts look so easy
@Juniorexplorerindia
@Juniorexplorerindia 6 лет назад
The way u explained sir it's impeccable n ur content is lucid ..really v helpful for everyone of computer science students irrespective of whether preparing for gate or not... Really a nice initiative..it's a kind of home tuition for free Thnx a lot sir
@neelpatel122
@neelpatel122 5 лет назад
Within 10 Seconds I subscribed to this Awesome Channel....Best explanation given by tutor....thank you very much
@vigneshsaikrishnamallya5777
@vigneshsaikrishnamallya5777 4 года назад
Also mutex is used while running reader exit section code if it gets preempted and another reader tries to run , it wont work . It can mess up rc value. so rc value is also protected by mutex
@shinobiwolf8133
@shinobiwolf8133 3 года назад
I was also thinking about the use of mutex can you plz elaborate on what you have explained plz...
@i-am-mkv
@i-am-mkv 3 года назад
​@@shinobiwolf8133 What Vignesh trying to say is, "whenever we are going to update the rc value, we must down the mutex otherwise 2 or more readers can update the same rc value at same time which can result in locking the db permanently because rc value will never become zero. e.g. if rc =5 at some point, and 3 readers at the same time decrease it by 1, then all 3 of them will be decreasing it from 5 to 4. However, if you down the mutex before updating the rc value, then other readers will have to wait for the rc value to decrease by previous reader.
@AyushMo
@AyushMo 3 года назад
@@i-am-mkv That was so well explained, so darn well explained. Thanks a ton mate!
@i-am-mkv
@i-am-mkv 3 года назад
@@AyushMo Thanks for your kind words buddy.
@siddhu8558
@siddhu8558 3 года назад
I had the same doubt. Thanks for explaining
@ajaykrishnakv1870
@ajaykrishnakv1870 3 года назад
This channel is the only one that I can find that is easily understandable for OS Concepts. Thank you so much!
@mohamedarshathn7768
@mohamedarshathn7768 5 лет назад
Best Lecture in this Topic. Thank you so much, Sir.
@swetabarnwal8373
@swetabarnwal8373 4 года назад
Your methodologies and descriptions are superb... 👏
@Sharda_g
@Sharda_g 3 года назад
Guru g aap ke paar chune hai. Pure concepts clear kar diye OS ke.🙏🙏
@neharoshan2371
@neharoshan2371 5 лет назад
You explain the each and every line of program. No one can explain the program line to line...🎓
@jaineshdesai5870
@jaineshdesai5870 6 лет назад
It is awesome explanation sir truly speechless...!🤘🖒
@hozefa7887
@hozefa7887 2 года назад
Hello sir, I'm studying Integrated MCA and I was worried about my OS subject but after watching your videos I'm very much thankful to you. I appreciate your hardwork. May God bless you. I have an request sir Please make a video on concept of Monitor in OS. Waiting in hope for your response.
@ritikshrivastava9442
@ritikshrivastava9442 3 года назад
17:00 hume bhi ye concept maze se smjh aa gaya
@ashutoshjadhav
@ashutoshjadhav Год назад
In my Engineering I didn't took this seriously, Now when preparing for product based company I am preparing and thanks a wonderful explanation. I understood everything. Hope to crack a good company.
@ketansingh2342
@ketansingh2342 4 года назад
Easy to understand OS important topics ... Thanks sir ji for this lectures.🙏
@alialihassan9670
@alialihassan9670 4 месяца назад
Your passion for teaching is contagious! You make learning fun and exciting. Thanks for all your hard work!❤
@harshitkumar9312
@harshitkumar9312 Месяц назад
Simple and clear explanation and problem is also veri interesting
@shashankshetti4477
@shashankshetti4477 3 года назад
Any random example to clear the concept.. IRCTC : Permanent hoon Sir ... Great work Varun Sir.. Thanks a lot...
@nishantpuri3180
@nishantpuri3180 4 года назад
Hi sir, I genuinely love your teaching! Your lectures have made me fall in love with this subject! I have a doubt though. Why is mutex being used again and again, I can't understand the application of it Hope to hear from you soon! Thank You
@sahiljindal3202
@sahiljindal3202 4 года назад
According to me we can ignore mutex during exit part in read function. It's not required.
@abhaychinchole3482
@abhaychinchole3482 4 года назад
@@sahiljindal3202 I doubt the same what's use of mutex in exit part of reader
@akshat3751
@akshat3751 4 года назад
I think that's because the statements rc=rc+1 and rc=rc-1 are sensitive to pre-emptiveness, recall to the most basic problem of process synchronization that was explained in one of his previous videos.
@GULSHANKUMAR-xi7ww
@GULSHANKUMAR-xi7ww 4 года назад
mutex is standard no,so only.
@rakshitpandey7517
@rakshitpandey7517 3 года назад
mutex is just analogous to flag variable.. that's it
@2035-AshishMehbubani
@2035-AshishMehbubani Месяц назад
Thanks 🙏🏻 Sir For Such A Nice Explanation. I Had Not Seen Any Other YT Channel Explaining Like This
@snigdhasinha3120
@snigdhasinha3120 5 лет назад
Mind blowing ....the way you deliver each n every step is just speechless... 👌👍
@tango2olo
@tango2olo 3 года назад
I feel you.. but the steps can't be delivered "speechlessly".
@alishbaayan4069
@alishbaayan4069 6 лет назад
wah sir kya bt he kitna acha ap hr chez explain krte hu kya concept clear krwae ap ne bs ase hi acha acha smjate rhe ap ne tu sari problem hi solve kr di hmari thnkiooooooooooooooooooooooooooo
@hustler212
@hustler212 3 года назад
Just amazed!! How simply you explained this...
@rimpibhandari4964
@rimpibhandari4964 5 лет назад
Vry useful video sir.. No any doubt to say sir you are magician of knowledge.. N teach all topics with pateince.. Concept is properly cleared.. Thanxu sir
@satyamkumar8409
@satyamkumar8409 2 года назад
Sir you have explained everything so nicely. Great Job! , Thank you so much, Sir.
@hussnainmohsin9227
@hussnainmohsin9227 Год назад
its very interesting and enjoyable topic. boly to bindas ha boss
@msatyabhaskarasrinivasacha5874
The complex concepts are made easy with your teaching.....my engineering was made easy with you sir....
@himanshi7896
@himanshi7896 2 года назад
I am Nepalese student and these subtitles are helping a lot.thanks
@komalsuse7886
@komalsuse7886 Месяц назад
Your Teaching is just Awesome ❤
@saifaslam5206
@saifaslam5206 4 года назад
Awesome lectures and helpful videos... Love you sir..
@saurabhkeshri6930
@saurabhkeshri6930 5 лет назад
Exams are after 10 days Great explanation Thankyou Wants new lecture for bscit 2nd semester
@varunyadav6560
@varunyadav6560 Год назад
best Operating Series which exist on Earth . Amazing👏👏😊😊
@ishitchoudhary4987
@ishitchoudhary4987 2 года назад
Thank you so much for making this playlist, its really a godsend. All the videos are to the point and yet contain enough examples and explanations. I only had one small doubt, what is the use of the mutex semaphore in this question? Wouldn't the code run exactly the same for all cases even without the mutex semaphore?
@aditidhumal4566
@aditidhumal4566 3 года назад
Thank you sir, your lectures proved very helpful for exam preparation.
@aniketkumar967
@aniketkumar967 2 года назад
you are a great teacher sir. The way you are teaching is fabulous and making us understand each and every concept easily
@gitikarath3023
@gitikarath3023 4 года назад
Your explaination is awesome sir.Its very easy to understand and my concept is also clear now.Lot of thanks for your videos.Keep it up sir!
@AbdulBasit0044
@AbdulBasit0044 5 лет назад
You are really a great teacher keep going, from Pakistan. 👍
@error-my9ut
@error-my9ut 2 года назад
Idk who designed this but i haven't seen such a beautiful use of 'if' ever in programing
@cg.yamangaming4632
@cg.yamangaming4632 2 года назад
Very complex too use
@aniketbhunia7752
@aniketbhunia7752 5 лет назад
Thanks for these videos. They are great. Just wanted to ask a question outside of these. what do you do for living?
@himanisharma5724
@himanisharma5724 3 года назад
Sir.....u r too good...... your explanation was too good.....your way of teaching excellent..... Thank you sir🙏🙏
@JEE-nf1cv
@JEE-nf1cv 2 месяца назад
Excellent and very clean explanation
@SandVision03
@SandVision03 4 года назад
such a wonderful explanation. kudos to your work sir.
@trishanksaharia
@trishanksaharia 6 лет назад
Sir I think you should recheck your W-R case again... After the write is implemented, you didnt up the value of db. That is why in the read function, after passing the rc==1 case, when the value of db goes down again, it should be zero and not negative. Kindly see that part though. I too may be mistaken but just got that observation.
@pallavishree2821
@pallavishree2821 5 лет назад
Thank you for explaining so smoothly
@amitasamanta
@amitasamanta 2 года назад
Amazing explanation. Sir, you are the best.
@rcbfan18
@rcbfan18 Год назад
Such a good explanation superb sir thanks for doing this type of videos
@SK-eg1ok
@SK-eg1ok 4 года назад
Nice Explanation...each an every line and word understandable.....☺️👍👏
@khushijain579
@khushijain579 2 года назад
You are really the best teacher. I don't go with a single doubt after seeing your lectures. Thank you so much sir 🙌🙌
@optimizer_____2420
@optimizer_____2420 4 года назад
1.75x me mast chalta hai
@bikalpkc6256
@bikalpkc6256 3 года назад
You saved my semester sir.. Nicely explained
@priyanka_pri
@priyanka_pri 7 месяцев назад
one of the best teaching😍😍😍thank you so much sir.....in class os is so boaring and difficult,but after watching your videos feels like os is so intresting and easy 🤩🤩😛
@syedsheharyar7297
@syedsheharyar7297 4 года назад
This channel makes os more easy and convenient
@nileshsrivastava1507
@nileshsrivastava1507 3 года назад
Nice explanation, thanks.. rc also works as Critical section so locked while setting value to rc.
@parvathys715
@parvathys715 3 года назад
Thanks a lot Sir for the great explanation
@arnavattri5047
@arnavattri5047 6 лет назад
Awesome teaching veere! The way you explain is so surreal and easy to grasp. I Subbed you and keep making more awesome content.
@DeepakRajput-tb3lk
@DeepakRajput-tb3lk 5 лет назад
Sir, Can you discuss the cases in Producer-Consumer Problem like i) If down(empty) interchange with down(mutex) likewise there are four cases if you can discuss it will be very useful.
@raghavgoel1336
@raghavgoel1336 3 года назад
Thank you so much sir. Your videos have taught me a lot. I just don't understand why you have used the while(true) loop in reader() and writer() functions. Can you please explain?
@venomop638
@venomop638 3 года назад
Brother , While (true) is for infinite condition always true loop , is that process or the code running for multiple times ,
@venomop638
@venomop638 3 года назад
Or process occurs multiple times ,
@raghavgoel1336
@raghavgoel1336 3 года назад
Ok bro thanks
@itz_me_imraan02
@itz_me_imraan02 3 года назад
Make a video on sleeping barbers problem... 🙏🙏...as u explain perfectly
@sejalmehta7568
@sejalmehta7568 2 года назад
Excellent way of teaching sir 🙏
@aashishkarn
@aashishkarn 2 года назад
Thank you sir. You are all over Nepal.
@SimreenKaur
@SimreenKaur 4 года назад
Sir you have explained everything so nicely.Great Job! I just wanted to ask whether this problem is important for interview preparation? And if so , do we have to learn the code as well?
@bbxismyname6320
@bbxismyname6320 Год назад
by your way of explaining this solution I don't think that e-commerce websites use binary semaphores
@NandiniMaharaj-u5j
@NandiniMaharaj-u5j Год назад
crystal clear explanation! thank you so much!!
@kedarkawade2482
@kedarkawade2482 2 года назад
❤️❤️❤️❤️best of the best 🔥🔥
@chahatsharma7964
@chahatsharma7964 3 года назад
very grateful to u sir. thanks a lot...
@santoshnaidu8484
@santoshnaidu8484 3 года назад
Sir, Your explanation is superb. I have a doubt, while (true) is always true, what is the need of these lines in the code?
@sarangmhase8435
@sarangmhase8435 2 года назад
Best interview 👌🏻👌🏻
@alankritashandilya6314
@alankritashandilya6314 3 года назад
you are the best teacher!!
@sutanusinha3780
@sutanusinha3780 5 лет назад
Excellent explanations, pl discuss take grant model.
@monamishra9723
@monamishra9723 6 лет назад
Useful video but liked producer consumer video more because u discussed gate type question at the end but still a good video for concept clear.😊
@pritykar9946
@pritykar9946 Год назад
Tomorrow I am going to pass just because of you. Thank you so much sir
@Laxmikanta_
@Laxmikanta_ 9 месяцев назад
Just wow sir thank you so much 🙏
@aneesbutt555
@aneesbutt555 2 года назад
thank you @gatesmaashers for being help us in all the topics of different subjects. your are such an amazing person and you your teaching method means no word i have to explain means amazing fabu . thanks alot again sir great work!
@kousthubhtadanki1237
@kousthubhtadanki1237 2 года назад
if there is no mutex semaphore in the above solution we might go into deadlock situation.....here is the case: 1st reader enters critical section ...so rc=1 db=0 ...after sometime he comes out of critical section and executes exit code rc=rc-1 so rc=0 ..now before it executes if statement lets say another reader preempted and executes entry code rc=rc+1 so rc=1 and it tries to execute if statement but db=0 so reader 2 gets blocked here......now lets say reader 1 continues to execute....now when he tries to execute if statement at exit code....he can't go inside if, cause rc=1. so deadlock situation.
@utsavtaliyan7395
@utsavtaliyan7395 2 года назад
19:34, why we do up(mutex) and what is the role of mutex in reader's code, both entry and exit section
@utsavtaliyan7395
@utsavtaliyan7395 2 года назад
Role of mutex is to maintain the presence/absence of readers in the db, and if R-R can occur(this is managed due to up(mutex) only) but R-W or W-R can't occur is managed by the db Semaphore
@dheerajkumar824
@dheerajkumar824 Год назад
One should focus on the role of simaphore mutex. It is taking care of 'rc' value
@RupamSasmalYt
@RupamSasmalYt 2 года назад
For those who are thinking about why mutex is used? => The mutex semaphore is used to ensure mutual exclusion when the variable read count is updated. Thank u!
@txp6940
@txp6940 2 года назад
which language is this code in?
@pqrstwxyz1175
@pqrstwxyz1175 Год назад
@@txp6940 it is a c pseudo code
@pqrstwxyz1175
@pqrstwxyz1175 Год назад
Isn't mutex called binary semaphore?
@gaganmanocha2496
@gaganmanocha2496 2 года назад
Wonderful lecture
@ishagupta5284
@ishagupta5284 5 лет назад
Shaandaar 👌🏼👌🏼👌🏼👌🏼
@charansrinivasan4404
@charansrinivasan4404 4 года назад
Superb explanation sir👍👍👍..thank you.
@akashkumarsingh3595
@akashkumarsingh3595 3 года назад
Thank you sir, very helpful for my university exams
@biplobbanik8296
@biplobbanik8296 4 года назад
I think condition in reader should be (rc>=1), not (rc==1), if(rc==1) then any no. of reader except 1st reader can enter into critical section after 1st writer, so RAW problem is still holding.
@AnkitKumar-ey7xk
@AnkitKumar-ey7xk 3 года назад
Bhai aag lga di aapne to
@tusharchavhan7300
@tusharchavhan7300 9 месяцев назад
Great help sirrr...
@vinayaksharma-ys3ip
@vinayaksharma-ys3ip 3 года назад
Best explanation👍👍💯
@arthiannamalla5028
@arthiannamalla5028 3 года назад
Just awesome sir
@anadivyas4841
@anadivyas4841 3 года назад
Sir ko IRCTC ki site ka example bohot pasand hain
@Arpit_Arora
@Arpit_Arora 3 года назад
Sir you are great.....thank you so much Sir jiiii🙏🙏
@sudhiryadav3119
@sudhiryadav3119 4 года назад
Gajab .
@anamikashil743
@anamikashil743 4 года назад
Such an ossom explain Sir
@xyzpqrs9201
@xyzpqrs9201 5 лет назад
Sir jaldi jaldi video or daliye baki subjects pe I am waiting for that
@hafizosamanizami1377
@hafizosamanizami1377 Месяц назад
Nicely Explain
@savitabirla4714
@savitabirla4714 2 года назад
Excellent Explaination Sir👏👍
@shubhamrajput9363
@shubhamrajput9363 2 года назад
धन्यवाद सर जी 🙏
@rubeushagrid4131
@rubeushagrid4131 6 лет назад
Sir with utmost sincerity and respect i would like to tell you that i have a doubt in the 4th case of R-R. You said *_"if the 2nd reader comes in then rc increases to value 2 and then execute down(db) which it cannot change back to 1 and therefore this line gets blocked."_* If this line is not executed and blocked then how is it possible to execute the next line? It should remain blocked forever. The next line should not be executed until the down(db) value is modified.
@GateSmashers
@GateSmashers 6 лет назад
Hi harsh Pandey if(condition) statement; if there is no braces with the if statement then by default we consider only one statement under the if condition to be executed if the condition is true.. so the statement down(db) is the part of if condition not up(mutex). therefore next line continue to its execution ...
@rubeushagrid4131
@rubeushagrid4131 6 лет назад
Okay !! That is why u wrote that statement in 1 line. I caught my mistake. Thank you Sir, I have almost seen all your videos and some are yet to be seen. I have recommended your videos to most of friends who have not touched these topics since 3 years after graduation. These videos are very much knowledgeable and i wish to see more videos of yours regarding programming language Python.
@akSingh_120
@akSingh_120 4 года назад
Nice taught.. 🙏
@anusharapaka2413
@anusharapaka2413 4 года назад
This s totally binary logic wow grt
@ashleyreema5751
@ashleyreema5751 2 года назад
Wonderful!!!
@pasito287
@pasito287 2 года назад
Bhaut sahi sir
Далее
PUBG Mobile СТАЛ ПЛАТНЫМ! 😳
00:31
Просмотров 82 тыс.
小丑调戏黑天使的后果#short #angel #clown
00:16
The Readers Writers Problem
15:32
Просмотров 256 тыс.
Semaphores
22:51
Просмотров 480 тыс.
The Dining Philosophers Problem
20:16
Просмотров 333 тыс.
PUBG Mobile СТАЛ ПЛАТНЫМ! 😳
00:31
Просмотров 82 тыс.