4.13 Producer Consumer Problem | Semaphores | Process Synchronization | OS | Operating System |

Поделиться
HTML-код
  • Опубликовано: 9 ноя 2024

Комментарии • 336

  • @KNOWLEDGEGATE_kg
    @KNOWLEDGEGATE_kg  Год назад +1

    For complete Operating System, check out this video: ruclips.net/video/xw_OuOhjauw/видео.html

  • @apurvutkarsh2622
    @apurvutkarsh2622 8 лет назад +53

    Thanx a lot ... Sir, You got me job today as interviewer asked me to write the code of producer-consumer problem.. & I explained the same way u told & he was very much impressed..Thanx a lot again !!!

    • @payalsagar1808
      @payalsagar1808 4 года назад

      #Apurv Utkarsh can u please mention the company interview in which u were asked for this ?

    • @ManojKumarSur
      @ManojKumarSur 4 года назад +1

      Nice video
      ruclips.net/video/Vn_X6Oi90mw/видео.html

    • @praveenkumarsahu7832
      @praveenkumarsahu7832 4 года назад

      @@ManojKumarSur you are legend

  • @ankitasingh5067
    @ankitasingh5067 7 лет назад +14

    hello sir.. three days ago I came across your videos of dbms and os.after referring many videos available on RUclips. I was amazed the way you teach any topic.. can't take my eyes off the topic.. every video of yours makes my concept of the subject more clear.especially the examples you put from previous years of gate exam. Thank you so much Sir ! 😊
    I also request you to please add more videos on operating system from competitive point of view.

    • @KNOWLEDGEGATE_kg
      @KNOWLEDGEGATE_kg  7 лет назад +7

      Thank you Ankita
      And Surely we will upload more topics and depth full contents
      Subscribe our channel for updates

    • @lovewithyoga
      @lovewithyoga 7 лет назад +2

      KNOWLEDGE GATE I am also agree with Ankita .and want to request please enter some more videos on Operating system .

    • @rs-no1ju
      @rs-no1ju 6 лет назад

      sir please upload solution for all gate o.s. questions ..your videos are very very helpful to me in my gate preparation ..plzz plzz upload solution for gate questions...thanks a lot for explanation...

  • @ayanbora2478
    @ayanbora2478 6 лет назад +60

    finally i feel like i have 2 ears!

  • @mindOVERmatter100000
    @mindOVERmatter100000 6 лет назад +135

    Holy crumbcake this guy starting speaking hindi out of f nowhere

    • @shantanujoshi
      @shantanujoshi 5 лет назад +3

      Haha.. this cracked me up :D

    • @Boom655
      @Boom655 5 лет назад +1

      hahaahahaah

    • @MegaMagicman007
      @MegaMagicman007 5 лет назад +3

      Gotta love Jains

    • @rajat__rg
      @rajat__rg 4 года назад +1

      Haha, u got me focus on different thing other than the topic sir is teaching 😂😂

  • @pankajroy2699
    @pankajroy2699 6 лет назад +3

    ab tak jitna bhi gate lecture dekha sabse achha knowledge ka laga...mza aa gya small to small confusion bhi clear ho gya ..these were the toughest topic i found... but u made these so easy by ur teaching methology,,,,,, thankyou very much sir....

  • @marvellouschandan
    @marvellouschandan 4 года назад +7

    Even though many students have already told how excellent you are, but please let me make it louder.
    You are amazing sir :D

  • @nabhchoudhary7254
    @nabhchoudhary7254 7 лет назад +8

    Hello Sir,
    Awesome videos..great to learn things in very easy manner...I study at one of India's leading engineering college but I can say this undoubtedly that I learn more from you than my professors.:)

  • @kashishnada5916
    @kashishnada5916 8 лет назад +75

    This playlist saved my finals.

  • @lordnk3698
    @lordnk3698 2 года назад +7

    I am not indian, but I understand hindi , thank god , you are a life saver

    • @KNOWLEDGEGATE_kg
      @KNOWLEDGEGATE_kg  2 года назад +1

      Most welcome dear 😍Keep learning & supporting ! Do visit our website www.knowledgegate.in for more amazing courses & contents 👍😊

  • @easyexcel214
    @easyexcel214 6 лет назад +51

    while(T)
    {
    printf ("You are doing great job sir. God bless you.");
    }

  • @nidhinandani1827
    @nidhinandani1827 4 года назад

    Each and every words spoken by you has some meaning and your explanations are always in a systematic manner. Hope I could have learnt COMPUTER ARCHITECTURE too from you.It took me one month for COA but still the concept is not as clear as it should be. Thanks once again!!!!!sir.

  • @sandysharma2858
    @sandysharma2858 8 лет назад +3

    u are just awesome sir...
    u dont know but you are saving careers of many students..
    best teacher ever!!!

    • @Rajakumar-jj9rj
      @Rajakumar-jj9rj 6 лет назад

      he is not only saving careers, but he is also making careers as well :)

  • @abhinavtelukunta2020
    @abhinavtelukunta2020 4 года назад

    perfect explanation! By your explanation I understood why we write wait(E) before wait(S) in producer code. Because when E=0, you need to wait (No item can be produced further). So there is no point in acquiring lock if you cannot produce further

  • @shubhamjain5889
    @shubhamjain5889 6 лет назад

    It's for the very first time that I could understand the producer consumer in a very easy manner. Thanku broder.

  • @shwetalmalviya7229
    @shwetalmalviya7229 8 лет назад

    Producer-Consumer problem explained in the simplest and best possible way!! Like it! Thanks :)

  • @imprakrut
    @imprakrut 6 лет назад

    You are the savior for every engineering student! Thank you for creating this channel and helping all the students!

  • @torishi82
    @torishi82 6 лет назад

    Best and simplest explanation of Producer Consumer problem. Keep producing, we will keep consuming :). Thank you.

  • @ranganatha039
    @ranganatha039 7 лет назад +5

    Very clearly articulated. Thank you!

    • @KNOWLEDGEGATE_kg
      @KNOWLEDGEGATE_kg  7 лет назад

      Hi Ranganatha, we truly appreciate your kind words for our efforts.We upload more topics every week, Please subscribe this channel for best GATE tutorials.

  • @codingbythemoon
    @codingbythemoon 6 лет назад

    These videos are great. Truly grateful for your lectures .
    On the language switch part, I don't mind it. To be honest, it feels like a plus point to me. When I am stuck on a concept, sometimes the hindi phrasing helps me visualize it better.

  • @mohummadrabbani1793
    @mohummadrabbani1793 8 лет назад

    sir the same code has been given in the stalling but i was never able to get how it Worked , Thanx sir, you are just awesome.

  • @yesh3394
    @yesh3394 8 лет назад +5

    awesome! really helpful sir, continue to make more videos it helps many students.

  • @dadiramya278
    @dadiramya278 2 года назад +6

    You have turned such a complex topic so Simple and clear!!!! The concepts are very Clear Now Thank you so Much Sir

    • @dadiramya278
      @dadiramya278 2 года назад +2

      You have gained one Subscriber

    • @KNOWLEDGEGATE_kg
      @KNOWLEDGEGATE_kg  2 года назад +2

      You are most welcome dear 😍 Great that you understood the concept clearly 👍 Keep learning & supporting ! Do visit our website www.knowledgegate.in for more amazing courses & contents 👍😊

  • @rohittechlife6415
    @rohittechlife6415 4 года назад +1

    Great explanation sir ji really u are best when it comes to OS

  • @shubhlaabh6342
    @shubhlaabh6342 4 года назад +3

    void lecture (os)
    {
    while (tutor == Sanchit Jain)
    {
    wait(toughness);
    signal(understanding);
    }
    }

  • @mayankarora6961
    @mayankarora6961 6 лет назад

    Really helps a lot to understand this, mainly gives a clear understanding of how to implement them.

  • @akhileshgangwar394
    @akhileshgangwar394 8 лет назад

    hi sir you are making me able to score the marks in synchronization topic in Gate 2017,thankssss a lot sir.
    please complete synchronization so that no gate question will escape

  • @abhiverma855
    @abhiverma855 8 лет назад

    excellent work sir.. sharing knowledge to others is the best thing a person can do.. going through all your videos on OS

  • @haseeburrehman6013
    @haseeburrehman6013 5 лет назад

    sir you are great ,extrardinary teaching style

  • @meetpanchal8809
    @meetpanchal8809 4 года назад

    Each and every word of write in my exam is only because of you sir. Thankyou

  • @sumitverma9007
    @sumitverma9007 8 лет назад

    thanks to you sir......you have awesome techniques to explain every basing concept. And I am waiting for next topic (page management ). I hope you will make same video clips.
    Thank you again ..... and best of luck for your KNOWLEDGE GATE.

  • @kaichenghu3826
    @kaichenghu3826 5 лет назад +1

    Thank you sir, this is really helpful. But as others have already mentioned, mixing languages in the mid of the sentence is really confusing especially when your viewers don't understand hindi.

  • @pargeetkaur932
    @pargeetkaur932 6 лет назад +1

    superb explaination sir.Really helpful.

  • @arafathussainchowdhury5873
    @arafathussainchowdhury5873 6 лет назад +1

    similar to other videos, this one was also very informative. well done

  • @DanielAngali
    @DanielAngali 8 лет назад

    Fantastic Explanation Sir.

  • @aishwaryas5847
    @aishwaryas5847 7 лет назад +1

    Awesome video sir!!

  • @ankitmehta4133
    @ankitmehta4133 3 года назад

    How can you be so perfect. Thanks KG for my NET

  • @karthikkumar432
    @karthikkumar432 7 лет назад

    loved ur explanation .subscribed just after watching for 1min.very clear and neat explanation.

  • @lovewithyoga
    @lovewithyoga 7 лет назад +2

    Sir I like your videos very much.and learn alot. But want yo request you please add some more videos on Operating system in memory management because in paging and segmentation there are many questions on gate. Please sir as soon as possible.

  • @karandodwani1
    @karandodwani1 6 лет назад

    Please Upload Remaining Topics & Previous Year GATE Questions videos ASAP, Your videos are very helpful.

  • @gembaliamar69
    @gembaliamar69 7 лет назад +1

    thank you so much.....you made it so easy to understand...

  • @sanket7877
    @sanket7877 11 месяцев назад +3

    best explanation ever , tysm sir . Love from Pune

    • @KNOWLEDGEGATE_kg
      @KNOWLEDGEGATE_kg  11 месяцев назад +1

      Thank you so much Sanket! Keep learning & stay connected! You can also check out our website www.knowledgegate.in for more amazing videos & contents👍😊

  • @jayjoshi4580
    @jayjoshi4580 4 года назад

    Thank you Sir, the way you teach is just amazing!!!

  • @priyanka.sarkar
    @priyanka.sarkar 8 лет назад +1

    Great explanation sir. :-)
    But i have a question.
    If after executing wait(E) for producer process we context switch to consumer process den wait(F) will lead to a decrement in the semaphore F by 1 i.e. both E and F will be decremented by 1.Now if producer/consumer process executes then signal(F)/signal(E) will be incremented by 1 which will give us the previous values of E and F again instead of increasing the value of F(in case of producer) or E(in case of consumer) by 1.
    Similarly if after executing wait(S) for producer process we context switch to consumer process den wait(F) will decrease the value of F by 1 but the consumer process will not execute as S now equals 0 and hence consumer process gets trapped so the producer process will continue further and after executing signal(F) F will be incremented to its previous value where it was supposed to be 1 more than its previous value.
    Waiting for your response sir...
    Thank you in advance...

    • @keyar5034
      @keyar5034 8 лет назад

      it seems ur observation and not question. What u said is correct, e/f values be changed but due to wait(s), no issues, I've checked with many context switches

    • @deeproy7292
      @deeproy7292 7 лет назад

      at the end everything will be correct

  • @najla6724
    @najla6724 6 лет назад

    If anybody know, answer this question
    Write the necessary code segments to illustrate producer-consumer problem using a boundedbuffer according to the features given below:
    • Bounded-buffer size is 30 elements
    • Producer will check for the buffer is full and if not, it will produce a single item and insert it to the next free element of the bounded-buffer.
    • Consumer will consume a single item at a time.
    • Consumer will check whether the buffer has sufficient elements to consume it will consume a single item at a time.
    • If the buffer doesn’t have elements, then the consumer doesn’t consume elements.
    You are required to
    1. Define a queue to store items from producer.
    2. Write the producer program to produce items
    3. Write the consumer program to consume items

  • @abdullahkhalid9581
    @abdullahkhalid9581 6 лет назад

    I like the way you teach and specially the way you say "very good"😊

  • @nasrinshaikh6325
    @nasrinshaikh6325 5 лет назад

    so simple explanation....thank u so much...!!!

  • @HassanRaza-ym3uf
    @HassanRaza-ym3uf 8 лет назад +1

    Sir you are a savior

  • @devendrayadav-um3nj
    @devendrayadav-um3nj 8 лет назад

    sir...u are fabulous.... placements are going on... hope we get next important videos soon....specially memory management ,threads, v.m. ,deadlock... plz plz plz... upload soon... thnx in advance...

  • @nikitabhatt2763
    @nikitabhatt2763 7 лет назад +1

    Congratulations for hard work ...... Please add more videos on other topic of OS such as multilevel page table, virtual memory, file system and deadlock

    • @KNOWLEDGEGATE_kg
      @KNOWLEDGEGATE_kg  7 лет назад

      Hi Nikita, Thank you so much for showing your interest, We'll try to cover all the topics as soon as possible. Please subscribe this channel for regular updates. :)

  • @zakibhatkar7237
    @zakibhatkar7237 7 лет назад +1

    Thnx sir plz do a video on counting semaphore......thnx

  • @manugomez7319
    @manugomez7319 7 лет назад

    Sir Good lecture. Just signal(S) has to be placed as last instruction for both producer and consumer. Otherwise without incrementing values of F and E context switch can happen and lead to inconsistency. Am I right sir?

  • @vandanak2218
    @vandanak2218 5 лет назад +1

    Wonderfully explained thankyou so much Sir!❣️

  • @Waleedkhan-mu4db
    @Waleedkhan-mu4db 7 лет назад +1

    your lectures are stunning to much brillent

    • @KNOWLEDGEGATE_kg
      @KNOWLEDGEGATE_kg  7 лет назад

      Hi Waleed, we truly appreciate your kind words for our efforts.We upload more topics every week, Please subscribe this channel for best GATE tutorials.

  • @umairbinali3956
    @umairbinali3956 6 лет назад +1

    Good one very helpful please make a tutorial on memory management

  • @itsmylife69
    @itsmylife69 4 года назад

    great lecture sir .... I am a fan of you

  • @ameen7553
    @ameen7553 8 лет назад +4

    plz make tutorials on deadlocks... thx a lot... this content is very helpful...

  • @rockonyo100
    @rockonyo100 6 лет назад

    Nice explanation.Thanks.

  • @p4s153
    @p4s153 8 лет назад

    thank u sir ....waiting for next video. you cleared all concept very easily.

  • @narendraparmar1631
    @narendraparmar1631 6 лет назад

    Dhanyavad sir ji😆

  • @bishwanath479
    @bishwanath479 6 лет назад +1

    Hello Sir,
    Firstly, I would like to say that your videos are really awesome and comprehensive and helped me a lot. Now coming to the point, I have a doubt regarding the semaphores. How are semaphore variables are shared between processes?
    Thanks and regards,
    Bishwa

    • @raja17
      @raja17 4 года назад

      Consider OS to be like a big program, and processes to be various functions. Semaphores would be like global variables

  • @AdeshPaul
    @AdeshPaul 4 года назад

    thanks for teaching sir.

  • @AnjaliKumari-eo2rb
    @AnjaliKumari-eo2rb 7 лет назад +1

    sir aap jaise padate h waise hi padaya kariye...english ho ya hindi apke padhane k way acha hai...sir os ke aur v video upld kriye pls

  • @adityadevs4956
    @adityadevs4956 4 года назад

    Hi Sir, please guide on how to buy your entire lectures or how to get subscription? Also is there any separate course for NIC Scientist exam ? Thank you. You are an exceptional teacher. Lots of gratitude. Thank you

  • @pranavsaxena4861
    @pranavsaxena4861 7 лет назад +1

    Kudos!! Thanks sir. Very nice explaination. :)

    • @KNOWLEDGEGATE_kg
      @KNOWLEDGEGATE_kg  7 лет назад

      Hi Pranav, we truly appreciate your kind words for our efforts.We upload more topics every week, Please subscribe this channel for best GATE tutorials. :)

  • @niranjanharpale3282
    @niranjanharpale3282 8 лет назад

    thanks for ur efforts!
    ur lectures helped a lot to clear concept and understanding the way to solve the problems in less amount of time in exams like GATE. Thanks!
    BUT i also wonder if u can teach us about memory management(paging, segmentation and virtual memory) and gate problems on that and how to solve them... if u do it will be great help to all students.
    again very very thank you, Sir.

  • @fghgffgvbgh
    @fghgffgvbgh 5 лет назад

    Very great lecture. But I agree with some of the comments that u should use only english. We north Indians can understand it but you will lose tons of worldwide users.

  • @rutujabandawar6911
    @rutujabandawar6911 8 лет назад

    very good explanation I liked this video ...and really it is helpful for m thnk u

  • @AzizMuslimVohraBCI
    @AzizMuslimVohraBCI 7 лет назад

    Your lectures are beauty.

  • @hardikgupta7567
    @hardikgupta7567 8 лет назад

    this explains the concept so easily, thanks for the video.

  • @saileejadhavvines7892
    @saileejadhavvines7892 7 лет назад +1

    thank you very much sir ...this is really very helpful..really great video.

  • @chandnigarg4407
    @chandnigarg4407 6 лет назад

    Simply superb..

  • @divyangkhatri5121
    @divyangkhatri5121 8 лет назад

    Thanks perfect explanation 🙏🙏🙏

  • @ritikadubey3798
    @ritikadubey3798 7 лет назад

    Great job sir ..... Your way of explaining the topic and solving the query is commendable ..... Thank You So much.
    Can you upload videos on Software Engineering? SE is an important subject of UGC NET.
    Once again Thanks a lot.

  • @urvashisangwan6007
    @urvashisangwan6007 8 лет назад

    sir, your lectures are highly beneficial. waiting for your next lecture on memory management

  • @ronnybanerjee6020
    @ronnybanerjee6020 7 лет назад

    Very well explained sir. I have already started recommending this channel to a lot of my friends as they can actually learn something!! It would also be nice if you could explain Dining Philosopher problem :)

  • @revathyn2
    @revathyn2 8 лет назад +1

    great helped me for my exam
    sir please upload paging,segmentation,resource allocation graph etc..

  • @nikitabhatt2763
    @nikitabhatt2763 7 лет назад +1

    Excellent videos

  • @levi-lb6dp
    @levi-lb6dp 4 года назад

    Dhanywad appka

  • @parthkaushik9932
    @parthkaushik9932 7 лет назад +1

    Great video dude hats off!!!

    • @KNOWLEDGEGATE_kg
      @KNOWLEDGEGATE_kg  7 лет назад

      Hi Parth, we truly appreciate your kind words for our efforts.We upload more topics every week, Please subscribe this channel for best GATE tutorials. :)

  • @raviraj8209
    @raviraj8209 6 лет назад

    i think in producer part ,signal (f ) should come before signal(s) ..because if bfor incrementing the F , if consumer tries to access , at starting he will find it empty as F is not incremented ..even though there is an element appended in by producer

  • @tayyabbintahir3005
    @tayyabbintahir3005 8 лет назад

    Best lecture !

  • @yashjain1449
    @yashjain1449 8 лет назад

    well explained sir awesome

  • @yugalsarkaar
    @yugalsarkaar 5 лет назад

    superrrbbbly explained.... Great Effort Brother :-)

  • @sribastavrajguru304
    @sribastavrajguru304 6 лет назад

    I m surprised how can sm1 unlike this kind of an explanation

  • @nitindiwan5601
    @nitindiwan5601 7 лет назад +1

    HI Sanchit, Whats the main difference between Critical section section and Mutex, Previously I was thinking that critical section is used to syncronize the threads within the same process and mutex is used to synchronze the threads between multiple processes, But you told that with critical section we can do context switching, that means even with critical section we can handle synchronization between 2 processes. Please suggest

  • @subhamsen5120
    @subhamsen5120 6 лет назад

    Too many ads.
    Else, excellent content. Possibly this is saving my butt tomorrow

  • @saurabhapte5252
    @saurabhapte5252 8 лет назад

    very clear explanation sir. can you please add a video on dining philosopher problem ??

  • @morningstar357
    @morningstar357 7 лет назад +1

    Very helpful sir thank

  • @ashutoshkushwaha4118
    @ashutoshkushwaha4118 7 лет назад +1

    thanks and have a good day

    • @KNOWLEDGEGATE_kg
      @KNOWLEDGEGATE_kg  7 лет назад +1

      Hi Ashutosh, Thank you so much, would like to hear more from you. We upload more topics every week, Please subscribe this channel for best GATE tutorials.

  • @shreyasi1001
    @shreyasi1001 8 лет назад

    Great video. Concepts explained very clearly. Thank you :)

  • @nikhilparmar9
    @nikhilparmar9 8 лет назад +3

    that's a brilliant explanation. the best explanation ever. hats off Sir. please continue to make the videos, you are helping so so many students. the blend of English and hindi works like a charm. Using hindi in your work is very good idea please don't stop it. waiting for the deadlock series. God will surely bless you for your kind work of educating the masses.
    thanks. Jai Hind.

    • @dews1068
      @dews1068 7 лет назад

      selfish....what of those who don't understand hindi?

  • @sayalidesai11
    @sayalidesai11 5 лет назад

    Thanks sir.very well explanation👌👌

  • @farhanamjad9426
    @farhanamjad9426 7 лет назад +1

    Thanku so much sir :) you saved my Finals :D

  • @riyagoel3635
    @riyagoel3635 6 лет назад +2

    Sir, please upload a video of counting semaphore

  • @alanmiandad289
    @alanmiandad289 6 лет назад

    first of all i would like to thank you so much for ur amazing videos . thank you

  • @prashanthb2068
    @prashanthb2068 8 лет назад

    sir, lectures r awesome!! way of explanation of prbm is fantastic!! watched all ur videos.. thanks to u.. (plz make a video on dinig philosopher problem..)

  • @levi-lb6dp
    @levi-lb6dp 4 года назад +1

    Thanks dev manus

  • @kirtic1119
    @kirtic1119 6 лет назад

    Very nyc video sir..Par aap sleeping barber aur dining problem bhi explain karige na..

  • @ankeshkumarjaiswal7258
    @ankeshkumarjaiswal7258 5 лет назад

    sir can you help me for this problem
    Q1-Consider a producer-consumer situation, where a process P produces an integer using the function produceNext() and sends it to process C. Process C receives the integer from P andconsumes it in the function consumeNext(). After consuming this integer, C must let P know, and P must produce the next integer only after learning that C has consumed the earlier one. Assume that P and C get a pointer to a shared memory segment of 8 bytes, that can store any two 4-byte integer-sized fields, as shown below. Both fields in the shared memory structure are zeroed out initially. P and C can read or write from it, just as they would with any other data object. Briefly describe how you would solve the producer-consumer problem described above,
    using only this shared memory as a means of communication and synchronization between processes P and C. You must not use any other synchronization or communication primitive. You are provided template code below which gets a pointer to the shared memory, and produces/consumes integers. You must write the code for communicating the integer between the processes using the shared memory, with synchronization logic as required.
    struct shmem_structure {
    int field1;
    int field2;
    };
    (a) Producer:
    struct shmem_structure *shptr = get_shared_memory_structure();
    while(1) {
    int produced = produceNext();
    }
    (b) Consumer:
    struct shmem_structure *shptr = get_shared_memory_structure();
    while(1) {
    int consumed; //fill this value from producer
    consumeNext(consumed);
    }