L-3.8: Semaphores | Wait, Signal Operation | Counting Semaphore | Example| Operating system

Поділитися
Вставка
  • Опубліковано 15 лип 2024
  • 👉Subscribe to our new channel: / @varunainashots
    Semaphore is a variable that is non-negative and shared between threads. A semaphore is a signaling mechanism, and a thread that is waiting on a semaphore can be signaled by another thread. It uses two atomic operations, 1) Wait, and 2) Signal for the process synchronization.
    0:00 - Introduction
    0:48 - Semaphore
    2:42 - Various operations in Semaphore
    4:59 - Entry section code
    12:03 - Exit section code
    19:56 - Questions on Semaphore
    ►Operating System (Complete Playlist):
    • Operating System (Comp...
    Other subject-wise playlist Links:
    --------------------------------------------------------------------------------------------------------------------------------------
    ►Design and Analysis of algorithms (DAA):
    • Design and Analysis of...
    ►Database Management System:
    • DBMS (Database Managem...
    ► Theory of Computation
    • TOC(Theory of Computat...
    ►Artificial Intelligence:
    • Artificial Intelligenc...
    ►Computer Networks (Complete Playlist):
    • Computer Networks (Com...
    ►Computer Architecture (Complete Playlist):
    • Computer Organization ...
    ►Structured Query Language (SQL):
    • Structured Query Langu...
    ►Discrete Mathematics:
    • Discrete Mathematics
    ►Compiler Design:
    • Compiler Design (Compl...
    ►Number System:
    • Number system
    ►Cloud Computing & BIG Data:
    • Cloud Computing & BIG ...
    ►Software Engineering:
    • Software Engineering
    ►Data Structure:
    • Data Structure
    ►Graph Theory:
    • Graph Theory
    ►Programming in C:
    • C Programming
    ►Digital Logic:
    • Digital Logic (Complet...
    ---------------------------------------------------------------------------------------------------------------------------------------
    Our social media Links:
    ► Subscribe to us on UA-cam: / gatesmashers
    ►Subscribe to our new channel: / @varunainashots
    ► Like our page on Facebook: / gatesmashers
    ► Follow us on Instagram: / gate.smashers
    ► Follow us on Instagram: / varunainashots
    ► Follow us on Telegram: t.me/gatesmashersofficial
    ► Follow us on Threads: www.threads.net/@gate.smashers
    --------------------------------------------------------------------------------------------------------------------------------------
    ►For Any Query, Suggestion or notes contribution:
    Email us at: gatesmashers2018@gmail.com

КОМЕНТАРІ • 1 тис.

  • @izanagi7
    @izanagi7 4 роки тому +175

    Dude, i actually struggled to understand the usage and application of a semaphore through the slides of my engineering course, but after watching your toilet example, i finally understand. Thank you so much, you are the professor we don't deserve, but the professor we need.

  • @tanyadixit8257
    @tanyadixit8257 2 роки тому +36

    During exams my entire college only remembers one name: Gatesmashers. You are really the teacher and guide our college professors (whom we pay) couldn't be. Thank you so much for providing such valuable content free of cost :)

  • @snigdhasinha3120
    @snigdhasinha3120 5 років тому +318

    U r amazing .....far better than our faculty....👌👌👍 keep going

  • @BK69XXX
    @BK69XXX 2 роки тому +123

    I failed my intial exams of previous semester and then i started learning Data structure from your playlist and socred almost full marks in terminal exam. Now for OS i daily watch two or three videos and lectures are very addictive, sometimes i spend entire weekend on youtube learning for your videos.

  • @imprakrut
    @imprakrut 5 років тому +1140

    Are you also watching this 1 day before your exam?

  • @roshannayak1463
    @roshannayak1463 3 роки тому +24

    Finally, I can confidently tell that I have understood this topic!! Loved it!!

  • @AyushMo
    @AyushMo 3 роки тому +21

    Yaar ek baat samajh nhi aayi, khali 440k subscriber kaise hai ab tak. Poore youtube pei aur koi operating system aur koi nahi padhaya aise. Deserves more support.
    Freakin Fantastic, thanks a ton for the course!

    • @GateSmashers
      @GateSmashers  3 роки тому +5

      Wow..thank u..jaldi ho jayenge million

    • @hiteshbansal4878
      @hiteshbansal4878 3 роки тому

      @@GateSmashers I have a doubt, when process (P4) waking up from the block state and there is already some space created in critical section as one process(P1) have come outside, and also the P4 has already run the entry level code uptill the suspend was called and should resume after that(also the value of S is decreased already one time), so it should go to critical section directly resuming from that line but as you said in video it is running again entry code, why?
      Please Reply
      And Thank you for these amazing videos

    • @prasadprojects
      @prasadprojects 3 роки тому

      @@hiteshbansal4878 Any process to enter into critical section have to execute the entry code and exit code, even the process is from wake up() state (blocking state) like P4, P5 ....or the new process like P6, P7, P8, ....
      so it should not directly go to critical section, as discussed in video it is running again entry code.....

    • @priyamraj7548
      @priyamraj7548 3 роки тому

      @@hiteshbansal4878 Yeah bro, it should not execute the entry code again but rather enter the Critical Section directly

    • @AyushMo
      @AyushMo 3 роки тому +1

      Maine ek aur jageh yeh comment post kia tha, toh yaha pe paste kar rha hu in case you're still struggling or for anyone who doesn't understand it in the future:
      Reposting a comment from 9 months ago that went unanswered:
      "sir in 18:23 p4 try karta hi enter karane ke liye then s.value -1 hoti hi ...assume karo wo dobara suspend ho jata hi aur p3 exit code chalata hi to uske baad s. value =0 hogi ..phir iske baad to koi process critical section mei ni hoga ...aur koi next process agar aata hi to s. value negative hoti jayegi , aise case mei to koi andar ni jaa payegaa, humeshaa suspend hote rahengey..pls provide solution"
      Another comment in English:
      "what if value of S = 1 and one process entered in CS, value of S becomes 0, Now 50 process try to enter but they get blocked, Now value of S becomes -50, one process which was in CS now come out of CS, value of S becomes -49, now how another process entered in CS"
      I have the same doubt.
      From what I've understood, there a couple of things that are therefore incorrect.
      First off, whenever a process comes back from block list, it doesn't restart its execution of Down(), it would rather resume where it left off from, ie last line of if block.
      So secondly, this means that the code should actually be 'return;' instead of ' else { return; } ' so that it can actually resume its execution and enter into the critical state.
      Edit:
      Actually, I'm watching this again 4 months later. Perhaps you don't need to make the code change. The code is perhaps right, the explanation was wrong. So yes, whenever a process comes back from block list, it doesn't restart its execution of Down() like I said earlier. It continues from where it left indeed. And it left at a place where there's nothing left to execute(There's nothing after if else), so it's done executing Down() and can now enter the critical section. So the code as it is right now is correct, just the explanation that went with it was a little flawed.

  • @sajib.khan99
    @sajib.khan99 3 роки тому +54

    Your teaching ability is more capable than some of our university faculty.

  • @dnariankajol3542
    @dnariankajol3542 5 років тому +7

    just amazing...very easy to understand when i see ur lecture.
    thq so much....

  • @zakriarehman8014
    @zakriarehman8014 2 роки тому +11

    I wish you could teach us face to face in University. Totally in love with your teaching skills and knowledge transfer.
    Love from Pakistan.

  • @evendevilscry1431
    @evendevilscry1431 4 роки тому +1

    Best explanation. The words you choose to speak and even a small bit of information is elaborated so nicely. Thank you

  • @saurabhrana4276
    @saurabhrana4276 3 роки тому +5

    went through few comments....people are watching this video 1 day before exam,mean while me watching this video during exam... #covid19
    thank you sir..!!

  • @noobcharisma3807
    @noobcharisma3807 3 роки тому +10

    Your teaching skills are amazing, you convey us the concept in 5 mins which our teachers do in 1.5 hours and we still don't understand them.
    Love from Pakistan

    • @amanbhadani8840
      @amanbhadani8840 2 роки тому +5

      Happy to see that u guys are having a pen in your hand not a weapon.

    • @jashanpreetsingh6056
      @jashanpreetsingh6056 2 роки тому +1

      @@amanbhadani8840 great thinking ...sir

  • @saadrehman3156
    @saadrehman3156 3 роки тому +22

    I can only say YOU are a true GEM personality, none of the UA-camrs, even our faculty staff in uni are not as good as YOU are Sir. Much appreciated and lots of love from Pakistan

  • @naeemaibrahim1645
    @naeemaibrahim1645 3 роки тому +2

    YOU ARE THE DEFINITION OF A GOOD TUTOR I SWEARRRR

  • @aakankshasharma4346
    @aakankshasharma4346 4 роки тому +1

    U are best sir... Aj se phle kbhi process synchronization , semaphore kbhi smjh nahi aaya, but apki video dekhne k bad crystal clear ho gya concept

  • @sameerahmed3033
    @sameerahmed3033 4 роки тому +6

    Perfect example of a Best Teacher

  • @insideentrepreneur7904
    @insideentrepreneur7904 4 роки тому +27

    If I own a college and I have to select only one teacher, it will be Varun Singla. Huge respect sir!!!

  • @ayushjindal4981
    @ayushjindal4981 4 роки тому +14

    Please dont delete this OS series ever from youtube. I am not making notes expecting that I can access these videos anytime in future..

  • @amandwivedi5644
    @amandwivedi5644 4 роки тому +3

    We love you sir..You are a good teacher at all.
    Keep doing it sir.
    May god keep you alwz happy and healthy.

  • @shoaib_388
    @shoaib_388 Рік тому +5

    i can understand only your videos to mark scores in my academic yr ,,,may god give you long life and safe your family from problems and disease

  • @Er.meghajain
    @Er.meghajain 6 років тому +10

    Thanks I had too much confusion on this topic but now cleared

  • @CricketFan_Krishna
    @CricketFan_Krishna 3 роки тому +14

    mine faculty is like complicating everything and
    you sir
    simplicity at next level ...

  • @kartikpurohit7457
    @kartikpurohit7457 5 років тому +3

    Sir aapne semaphores ko ittna clearly explain kiya jisse classical problems bohat ache se samaj aayi iske liye sir thanku so much aapke padaane ka tarika bohat acha hai

  • @abhaydwivedi6354
    @abhaydwivedi6354 5 років тому +7

    This is the best explanation in UA-cam

  • @vishalsnsingh
    @vishalsnsingh 3 роки тому +4

    I see half of video and all concept got clear!🙏🙏

  • @sanazamir291
    @sanazamir291 4 роки тому +2

    Very informative and understandable lecture... Stay blessed

  • @onmywaytopassion5382
    @onmywaytopassion5382 3 роки тому +3

    So thankful, so easy to understand by your teaching❤

  • @prithwi1820
    @prithwi1820 2 роки тому +3

    Amazing explanation....after watching your video it is clear to me...

  • @ShubhamSharma-ky2tf
    @ShubhamSharma-ky2tf Рік тому +1

    Thank you Varun Sir for explaining the complex concepts in such simple terms. Indebted to you for my interview preparation

  • @harshiniadusumilli2509
    @harshiniadusumilli2509 3 роки тому +2

    U r awesome sir,understood the topic very well and now I am ready to answer all the questions from this topic....Thank you sir

  • @rashikasharma9199
    @rashikasharma9199 6 років тому +29

    Sir you are an Amazing teacher 🙏👌all doubts are cleared now..

  • @nupurahluwalia6575
    @nupurahluwalia6575 6 років тому +3

    Very well explained Sir. Your videos are very helpful. :)

  • @shivamkhare9472
    @shivamkhare9472 2 роки тому +2

    after watchig your videos my confidence on this on this subject is increased thank you sir your way of explanation is vary easy

  • @mabbrarsaif7534
    @mabbrarsaif7534 2 роки тому +1

    Sir YOU are the best teacher i have ever seen , such a clear cut explaination.Thank you Sir

  • @aliyazdan4577
    @aliyazdan4577 2 роки тому +8

    I have a big job interview next week and I need to cover all this stuff I studied 7 years ago. Your videos have been so helpful buddy, thanks a lot 😊

  • @noorulain8463
    @noorulain8463 3 роки тому +4

    a lot of appreciation from Pakistan :*

  • @kr4k3nn
    @kr4k3nn 4 роки тому +1

    Awesome Explanation brother....keep it up...God bless you..Thank you Very MUch for making such Video

  • @anjalimuchhala4954
    @anjalimuchhala4954 3 роки тому +2

    Sir you are such a great teacher and your teaching technique also best........thank you so much sir🙏

  • @YasirAli-ow5zt
    @YasirAli-ow5zt 5 років тому +16

    Sir Varunn you are great.... I am natuical officer.... nd i love to learn computer ... i have learnt many things from u... ur videos very help full....
    ur videos are exam nights last hope....

  • @afsha.fahm0910
    @afsha.fahm0910 5 років тому +6

    First time i got this concept .Truly amazing Sir!

  • @VishalYadav-gk1kg
    @VishalYadav-gk1kg 7 місяців тому +2

    Very Nice Explanation Sir, Thank you !

  • @labbusharma9865
    @labbusharma9865 4 роки тому +2

    thank you so much sir
    you are so amazing .....your teaching really helps me

  • @sumitshokeen8774
    @sumitshokeen8774 5 років тому +4

    Thank u sir ji 🙏 way of explanation is lit🔥

  • @smritipradhan6921
    @smritipradhan6921 3 роки тому +4

    Thank you for providing industry level education for free.That too such a great course free is the best thing one can avail.

  • @rj...12ka4
    @rj...12ka4 5 років тому +1

    Really it's very helpful . Such a nice and clear explanation Thanks a lot Sir🙏🙏😊😊

  • @ajayboudh
    @ajayboudh 5 років тому +1

    This is the easiest video to understand..thanks a lot Sir

  • @nicholasgaming5711
    @nicholasgaming5711 3 роки тому +4

    This channel is Amazing 😍😍😍

  • @aryaaryaa4216
    @aryaaryaa4216 2 роки тому +4

    woah mind blowing explanation. I'm from non-IT branch but i have started loving all your tutorials.. u have made this subject easy. Thank you so much sir More power to you.

  • @sudeshmandan2637
    @sudeshmandan2637 4 роки тому +1

    Amazing way of teaching.. 👍

  • @anshumangaurav6616
    @anshumangaurav6616 5 років тому

    Sir.... Aaap ne dil khush kr diya.... Waah ...

  • @ishanpand3y
    @ishanpand3y 5 років тому +16

    I wish you were my professor in my college ☺️😅. You are just amazing as teacher 🤩😍

  • @mindbodyps
    @mindbodyps 2 роки тому +3

    This is how teaching become fun

  • @sadiyakhatoon2867
    @sadiyakhatoon2867 3 роки тому +1

    Thank u soo much sir for explaining each and every point in such an easy way....

  • @pankajbhatt8315
    @pankajbhatt8315 5 років тому

    Interactive lectures. Thanks

  • @RohitMishra-ox6oy
    @RohitMishra-ox6oy 3 роки тому +4

    I challenge in the whole UA-cam u r the best teacher i have come through 🔥

    • @satvikkhare1844
      @satvikkhare1844 3 роки тому

      well then you watching only Indian youtube.

  • @divyashivpandey7750
    @divyashivpandey7750 4 роки тому +6

    Your videos are really great and easy to understand. They develop a very clear and organized view of the topic enabling student to grasp and gain command on it. As a student the only problem i faced while watching your videos was revision of the topic. For this student has to watch the whole video again (which is not always possible).
    If possible, you can add a revision notes to each video which covers the topic and are meant for revision purpose. This would not only enhance the content of your channel (which would also promote your channel when students will share notes among them) but also provide students with good study content.
    Thank you.

  • @NamithaRamachandran
    @NamithaRamachandran 3 роки тому

    excellent work , that much simplified ....thanks

  • @ranafaisaljoyia965
    @ranafaisaljoyia965 4 роки тому

    sir you are great, huge respect and love from pakistan. you are far more better than our phd professors. jinki hmy zra smjh ni ati.

  • @vishalchauhan9832
    @vishalchauhan9832 5 років тому +6

    Best explanation!

  • @ayushigoyal6853
    @ayushigoyal6853 3 роки тому +4

    These vedio lecture series are really helpful.. I m following them for OS,CD.. And will follow for many more.. These lectures are responsible for completing my syllabus on time.. Thank you sir

  • @riturajdas214
    @riturajdas214 4 роки тому +1

    You are really amazing Sir!.. Great explanation 👌👌 . All doubts cleared 😊

  • @thejusv.s672
    @thejusv.s672 6 років тому

    Good explanation boss..ty very much..now i'm very clear about this topic

  • @arpitsaxena5972
    @arpitsaxena5972 4 роки тому +21

    Always prefer Gate smashers for my semesters related computer subjects♥️♥️♥️♥️🔥🔥🔥 love your explanation 🔥🔥🔥

  • @OmitA25
    @OmitA25 6 років тому +3

    awesome explantion.........plz make a vdeo on computer org.

  • @supriyakumari7279
    @supriyakumari7279 4 роки тому +2

    Sir your lecture is too good .your teaching style is very impressive .

  • @goldyhandsome3267
    @goldyhandsome3267 2 роки тому +2

    aap ka chahra bhut cute he positive vibes and 25 ke 25 min sun ne me dikkat nahi hoti

  • @xd69_naruto
    @xd69_naruto 3 місяці тому +3

    Exam Tomorrow at 11:30 AM , watching now at 10:45 PM

  • @MrJ84130
    @MrJ84130 Рік тому +3

    Hello Sir, I was not able to grasp the concepts of Operating system, but after seeing your videos, I'm able to understand very easily. Thank you very much for your efforts in helping us understand concepts very easily.
    I had a question: Does counting semaphore provide mutual exclusion? Because I saw many processes are entering the critical section simultaneously. And providing mutual exclusion is a necessity for process synchronization.

  • @priyankadeka8603
    @priyankadeka8603 2 місяці тому

    When we have a teacher like him on youtube then it is so easy for distance students. Thank u so much sir❤

  • @swarasworld9813
    @swarasworld9813 4 роки тому

    Wowww. Nicely explained 🤟 now crystal clear 🙏

  • @shudderranz5919
    @shudderranz5919 2 місяці тому +4

    aapko 1.5x pe dekhne ki habit ho gyi hai jaise hi 1x pe video chalti hai bada funny lagta hai 😂

  • @Vikashpoonia.ExamsABC
    @Vikashpoonia.ExamsABC 5 років тому +3

    Dear Friend,
    If you can prepare series on Computer architecture and organization then plz prepare that. We would love to learn from your videos. God bless you.

  • @geshudsouza3646
    @geshudsouza3646 5 років тому +1

    Thank u so much sir .....i watch only the vedios which u upload and it helps me a lot and i watch it only one day before my exams but i score good marks....thank u sir

  • @bharatkanojiya537
    @bharatkanojiya537 3 роки тому +1

    nice expiation sir
    superb method i understand easily all concept thank your so much sir......

  • @ShubhamGhuleCode
    @ShubhamGhuleCode 3 роки тому +18

    Correction:
    15:58 When P4 wakes up it can directly enter the critical section because it has already executed the entry section code !
    Thank you for this wonderful lecture series ❤️

    • @ita755khushalkoli2
      @ita755khushalkoli2 3 роки тому

      I had some doubts about it but I Advice you to solve an example.

    • @suryasikharej8116
      @suryasikharej8116 3 роки тому +1

      if you read about multi threading you will see that when a thread is running and wait() is called and after waiting the thread does not directly jump to running state. The thread scheduler(program which decides which thread to run) decides when the thread will run again. Mean while all the operations done by the thread before calling wait() is saved.

    • @utkarshgangwar2173
      @utkarshgangwar2173 3 роки тому +2

      @@suryasikharej8116 take 2 processes p1 and p2, suppose p1 comes first and executes down() (take s = 1 initially) means s will become 0 (1-1), now suppose while p1 is in cs , p2 wants to execute down(), where s will become -1(0-1), so 'if' will run for p2 and p2 will get blocked, now suppose p1 completes it's cs and executes up() where s will become 0(-1+1), means 'if' will run and p2 will get wake up but s is currently 0 means if according to sir that p2 will again check down() which means s will become -1(0-1), so in that case 'if' will run means p2 will again get blocked , so in this way p2 will starve, am i right ?
      or p2 will not execute down() from starting , will it resume after the sleep() call where then it will get the access to cs ? just clear this doubt

    • @suryasikharej8116
      @suryasikharej8116 3 роки тому

      @@utkarshgangwar2173 You are using binary or counting in your example?

    • @suryasikharej8116
      @suryasikharej8116 3 роки тому

      p2 will execute down and will go to a list which contains process which are waiting to execute cs. After p1 completes cs and while doing up() it will take one process(lets say p2) from the waiting list and start its exeution .

  • @manmathkumarbhuyan6287
    @manmathkumarbhuyan6287 2 роки тому +6

    In critical section chapter, it is told that only one process can execute the critical section. But here it is told that more than one process can enter into the critical section even if there is another one.

    • @snehasispradhan3992
      @snehasispradhan3992 Рік тому

      same doubt. Help me to understand.

    • @madhu19993
      @madhu19993 Рік тому

      7:59 mutual exclusion doubt will clear at this point of time.

    • @machireddypalakondareddy9958
      @machireddypalakondareddy9958 10 місяців тому +1

      a counting semaphore can allow multiple processes or threads to access the critical section, hence mutual exclusion is not guaranteed.

    • @machireddypalakondareddy9958
      @machireddypalakondareddy9958 10 місяців тому +1

      @@madhu19993 mutual exclusion may or may not be achieved

  • @darshandz1227
    @darshandz1227 3 роки тому +1

    Amazing understanding u gave us

  • @krimeera
    @krimeera 5 років тому

    2nd best teacher i hv learned from .. Too good 👍👍

  • @ashwindhuriya6598
    @ashwindhuriya6598 3 роки тому +6

    sir consider if semaphore value is 1......if process P1 tries to enter critical section the S will become 0 and it will enter. Next if process P2 wants to enter S value will become -1 and it will go in suspended state . Now consider P1 is completed and it incremented S to 0 which will wake up P2 and will bring it to ready state,now if P2 again wants to enter critical section then S value is currently 0 so it will still go back to suspended state and P1 is also completed....please solve this doubt sir!

    • @AyushMo
      @AyushMo 3 роки тому +2

      Exactly, do comment back if you manage to find an answer to that.

    • @wasifrock687
      @wasifrock687 2 роки тому

      nice observation

  • @princekhatri88
    @princekhatri88 9 місяців тому +5

    5 minutes before exam.

    • @Rahul-kw6zf
      @Rahul-kw6zf 14 днів тому

      Hum bhai exam me hi phone leke aaye😊

  • @dattatreypoojari690
    @dattatreypoojari690 5 років тому

    amazing teaching...my favorite teachers

  • @VaibhavTalks
    @VaibhavTalks Рік тому +2

    thankyou sir for amazing lecture

  • @dvlsravya9100
    @dvlsravya9100 3 роки тому +8

    Your videos are amazing. I have the following queries and would like to know the answers of them.
    1. How mutual exclusion is satisfied in case of counting semaphores ?
    2. Is there any difference between mutex and semaphore. Explain in detail, if any.
    3. If S=1, p1 enters. P2,p3,p4 will be -1,-2,-3. And if p1 is moved out of Critical section with exit code. Semaphore value becomes -2, in such a case; the critical section is left idle as the CS is not utilised by any process. ? Can you explain this state in detail.

    • @veerrajuannamdevula9939
      @veerrajuannamdevula9939 2 роки тому

      Counting semaphores doesn't satisfy mutual exclusion

    • @veerrajuannamdevula9939
      @veerrajuannamdevula9939 2 роки тому

      ua-cam.com/video/DvF3AsTglUU/v-deo.html --- check this out to understand difference between semaphore and mutex

  • @YasirAli-ow5zt
    @YasirAli-ow5zt 5 років тому +4

    our teachers even suggests us ur videos here in pakistann ... lOv u sir

  • @anujpathak8036
    @anujpathak8036 5 років тому

    awesome explation.....topic cleared

  • @muhsinmohamed7338
    @muhsinmohamed7338 3 роки тому +2

    You are truly a saviour ❤️

  • @devanshmesson2777
    @devanshmesson2777 2 роки тому +6

    I have a doubt, If S=3, which means, Critical section is capable of having 3 processes inside.
    Now, 5 processes executes the wait() operation, Now, S = -2, and 3 processes (P1,P2,P3) are already inside the CS.
    Now, as we know, critical section is capable of having 3 processes, so if P1 exits the CS (Now, S= -1), there are currently 2 processes in the CS, which means, One
    process must enter the CS, but because S=-1 it cannot enter.
    So, In order to make P4 enter the CS, one more process should exit the CS, so that S is positive, which is something illogical.Suppose P2 also exits CS. Now S=0.
    Now if P4 enters the CS, P5 cannot enter the CS now because S becomes -1 after P4 entered. CS has a space of one process but p5 cannot enter.
    I am not able to understand Counting Semaphore concept!
    Can anybody explain?

    • @niranjansaha5135
      @niranjansaha5135 Рік тому +3

      As per my understanding the process would resume after waking up from sleep so they won't run the Down() function again, they shall enter to the critical section only when the Semaphore value is greater than 1,, there would be a infinite while sloop kind scenery ig,,,,,,,, I came up with this explanation myself just to statisfy my thrust to meet the inconsistency in the video,,, please correct me if you find more suitable ans ..

    • @adityasankhla1433
      @adityasankhla1433 Рік тому +5

      @@niranjansaha5135 Yep, I too think that should be it. It is very weird how only a handful on comments are pointing out this obvious mistake.

    • @rushabhlegion2560
      @rushabhlegion2560 Рік тому +2

      Damn, same doubt. There are hundreds of students hailing this video but not able to get this doubt. Can you tell me from where to understand this concept?

    • @satwikjain6455
      @satwikjain6455 11 місяців тому

      @@adityasankhla1433 ++

  • @kunjk23
    @kunjk23 3 роки тому +7

    One question here, won't decrementing or incrementing S in Down and Up result in race conditions as explained in previous videos? Which will lead to inconsistent value for S

    • @shabir301
      @shabir301 2 роки тому +2

      Yes , i have also same confusion.
      Semaphore is also using critical section type code. This result is indeterministic state of program.
      Let take two process p1,p2.
      1)Both performing down code , while sValue =1; means only one program can enter in CS.
      2) process 1 : fetch sValue , decrement operation 1-1=0, but not store in ram , process preempted.
      3) process 2: fetch (sValue ie 1),
      Decrement operation 1-1=0, and save to ram, and check s

    • @hemiacetal1331
      @hemiacetal1331 2 роки тому +1

      Incrementing/Decrementing are atomic operations i.e., they either execute fully or don't execute at all. So, when more than 1 process will try to update the value of "s" then ultimately "s" will either be equal to 0 or 1.

  • @shrimatkapoor2200
    @shrimatkapoor2200 3 роки тому

    Very well explained conceptually!

  • @rosejimmy2552
    @rosejimmy2552 4 роки тому +1

    Thank you sir. You are an amazing teacher sir......

  • @silajitsaha3369
    @silajitsaha3369 5 років тому +13

    Sir, suppose initially s=1. Then p1 enter in CS(s=0) and then p2, p3 and p4 tries to enter in CS(s=-3) and then p1 exit(s=-2) now the CS is empty but still p2 cannot enter in CS why?????

    • @yogesh8275
      @yogesh8275 3 роки тому

      Iska answer mila kya bhai ?

    • @roshan84ya99
      @roshan84ya99 3 роки тому

      @@yogesh8275 same question

    • @pratyushkumar3829
      @pratyushkumar3829 3 роки тому +1

      I guess because p2, p3 and p4 are in the waiting state (block state) and can only enter when s>0

    • @yogesh8275
      @yogesh8275 3 роки тому

      There will be deadlock
      Coz we r try to awake the process which is not actually in sleep condition
      (for set the value of semaphore greater than one)

    • @sharmiladevi4012
      @sharmiladevi4012 3 роки тому

      As s value is less then 0 and when value is less than 0 its goes in sleep mode

  • @soumyajitdey5720
    @soumyajitdey5720 5 років тому +9

    What is the utility of counting semaphore if it does not follow mutual exclusion?

    • @palakgupta6804
      @palakgupta6804 5 років тому +1

      Yes please clear this

    • @naveetakharb7647
      @naveetakharb7647 4 роки тому +1

      I think....counting semaphore is used for synchronisation and binary semaphore is used for mutual exclusion.

    • @saptarshidas6971
      @saptarshidas6971 4 роки тому +2

      @@naveetakharb7647 if you are using the word synchronisation then under synchronisation their is a condition Mutual exclusion
      According to you one is following synchronisation and other mutual exclusion is kind of absurd type of answer because if any algorithm is synchronised for multi processing that means that it is also following mutual exclusion because to achieve synchronisation you must achieve mutual exclusion as it is primary goal to obtain a synchronised algorithm for multi processing

  • @sameenqamar6978
    @sameenqamar6978 4 роки тому +1

    Thank u Sir... You are great.. All doubts clear.. lots of love from
    Pakistan

  • @ninjasmotivation
    @ninjasmotivation 2 місяці тому +1

    very helpful video sir great work

  • @AyushMo
    @AyushMo 3 роки тому +9

    Reposting a comment from 9 months ago that went unanswered:
    "sir in 18:23 p4 try karta hi enter karane ke liye then s.value -1 hoti hi ...assume karo wo dobara suspend ho jata hi aur p3 exit code chalata hi to uske baad s. value =0 hogi ..phir iske baad to koi process critical section mei ni hoga ...aur koi next process agar aata hi to s. value negative hoti jayegi , aise case mei to koi andar ni jaa payegaa, humeshaa suspend hote rahengey..pls provide solution"
    Another comment in English:
    "what if value of S = 1 and one process entered in CS, value of S becomes 0, Now 50 process try to enter but they get blocked, Now value of S becomes -50, one process which was in CS now come out of CS, value of S becomes -49, now how another process entered in CS"
    I have the same doubt.
    From what I've understood, there a couple of things that are therefore incorrect.
    First off, whenever a process comes back from block list, it doesn't restart its execution of Down(), it would rather resume where it left off from, ie last line of if block.
    So secondly, this means that the code should actually be 'return;' instead of ' else { return; } ' so that it can actually resume its execution and enter into the critical state.
    Do correct me if I'm wrong @Gate Smashers

    • @sanyatayal6933
      @sanyatayal6933 3 роки тому +1

      Understood now. This is actually helpful.. have been trying to find this out for a long time actually. Thanks!

    • @AyushMo
      @AyushMo 3 роки тому +2

      glad it helps.

    • @suryasikharej8116
      @suryasikharej8116 3 роки тому

      no a process can never directly go to the running state. The long term scheduler will decide which process to put from the new queue to the ready queue.

    • @AyushMo
      @AyushMo 3 роки тому +2

      No-one talked about 'directly going to the running state'..
      It was a comment on the point of resumption of execution of a process when it comes back from the block list.

    • @AyushMo
      @AyushMo 3 роки тому +2

      Actually, I'm watching this again 4 months later. Perhaps you don't need to make the code change. The code is perhaps right, the explanation was wrong. So yes, whenever a process comes back from block list, it doesn't restart its execution of Down() like I said earlier. It continues from where it left indeed. And it left at a place where there's nothing left to execute(There's nothing after if else), so it's done executing Down() and can now enter the critical section. So the code as it is right now is correct, just the explanation that went with it was a little flawed.

  • @reshmajannu1755
    @reshmajannu1755 5 років тому +16

    sir, how can a critical section handle more than one process(p1,p2,p3).it is supposed to run only one program at a time right?

    • @navagharkiran5769
      @navagharkiran5769 4 роки тому +1

      its for an example when multiple process occurs at a time in general its one but in computer without ur knowledge a lot of processor at background work

    • @soumyapawar8125
      @soumyapawar8125 4 роки тому

      There are some resources which can allow more than one processes to run it at a time

    • @neharaj3324
      @neharaj3324 3 роки тому

      Is it supporting mutual exclusion?

  • @shivampatil2554
    @shivampatil2554 4 роки тому +2

    Thank you very much sir for this information 🤗🤗

  • @alokpant9328
    @alokpant9328 5 років тому

    best teacher i have ever seen on youtube

  • @nikeshprasad5559
    @nikeshprasad5559 5 років тому +8

    Sir, when S = 3, 3 processes can enter Critical Section and other processes running the wait() are put to block list. Now when a process exits the CS why can't we simply let a suspended process to enter critical section if it can allow 3 process?

    • @saravpreetsikka8152
      @saravpreetsikka8152 4 роки тому +1

      Yes you are right, we will directly add that process from suspended list to critical section
      Sir explained it wrong, according to sir's explanation if at anytime 4 processes reached in the suspended list then no process can enter in critical section as semaphore value will be -4 and exit code of 3 processes can make it -1 which is less than 0, so no process can enter in the critical section

    • @sensei249
      @sensei249 4 роки тому

      @@AshishKumar-zs3nk BHAI LOG KYA PUCH RHE VO TO PADH.