It is used often when data stream must be arranged between threads or processes, maybe even between a process and a hardware. For example, the bounded bounded buffer data structure is very popular in audio programming. In audio programming, it is usually called "ring buffer". The implementation of such ring buffers is usually different from textbook solutions because at least one party is a real-time thread and should not block (can't wait). Audio programmers usually use "lock-free" solutions based on atomics. For the discussion of specific use cases, check the following cool presentation from CPPCon. The speaker talks about bounded buffer usage. ua-cam.com/video/boPEO2auJj4/v-deo.htmlm53s Also, here is a couple of links to the Audacity code. Files RingBuffer.h and RingBuffer.cpp contain the real-life implementation of the bounded buffer. github.com/audacity/audacity/blob/master/src/RingBuffer.h github.com/audacity/audacity/blob/master/src/RingBuffer.cpp
Basically any limited resources which is shared between processes (by processes I mean an abstract process, it could be thread, a file descriptor etc.).
This video was so well made and clearly understandable that I just purchased a subscription. (The price also was right and so it was a no-brainer.) Thank you!
Nice and clear explanation! I am wondering, is it really needed ot have 2 semaphores? You could just use one non-binary semaphore and increment and decrement it accordingly based on which process does which operation.
More complex synchronization is needed. You got to handle not only producer-consumer synchronization but also make sure that multiple producers or multiple consumers don't conflict between themselves.
You can make it work, though it wouldn't be so elegant. Semaphores are the solution from one of the most popular college textbooks on Operating Systems. If you want to use something like mutexes, you can but don't try to lock the whole buffer with it. It would be very inefficient.
Thank you. The rest is a part of the online "course" that can be found at binary-wisdom.teachable.com/p/quick-explanations-for-the-operating-systems-course/
All the necessary synchronization is in place here. You don't need any special mutexes for this version of the problem (single producer and single consumer). Try to come up with a scenario that causes a mistake and you'll see how it works like that.
what is the example in real life?
It is used often when data stream must be arranged between threads or processes, maybe even between a process and a hardware.
For example, the bounded bounded buffer data structure is very popular in audio programming. In audio programming, it is usually called "ring buffer". The implementation of such ring buffers is usually different from textbook solutions because at least one party is a real-time thread and should not block (can't wait). Audio programmers usually use "lock-free" solutions based on atomics.
For the discussion of specific use cases, check the following cool presentation from CPPCon. The speaker talks about bounded buffer usage.
ua-cam.com/video/boPEO2auJj4/v-deo.htmlm53s
Also, here is a couple of links to the Audacity code. Files RingBuffer.h and RingBuffer.cpp contain the real-life implementation of the bounded buffer.
github.com/audacity/audacity/blob/master/src/RingBuffer.h
github.com/audacity/audacity/blob/master/src/RingBuffer.cpp
Basically any limited resources which is shared between processes (by processes I mean an abstract process, it could be thread, a file descriptor etc.).
It's people like you that make it possible for me to pass my exams without a tutor. Thank you so much.
You are welcome!
This video was so well made and clearly understandable that I just purchased a subscription. (The price also was right and so it was a no-brainer.) Thank you!
Thank you for your kind words and hope it will be helpful.
the best EXPLANATION EVER!
Thank you!
This was the best explanation that I've come across! Thank you!!
Thank you!
Great video. I need to study for an exam and my teacher's course is unclear and full of mistakes. Your video was most useful.
Underrated channel. Thank you, I subscribed.
thank you so much
Nice and clear explanation! I am wondering, is it really needed ot have 2 semaphores? You could just use one non-binary semaphore and increment and decrement it accordingly based on which process does which operation.
Good Explanation, Hope to see some more videos on operating system topic. :)
you are a legend sir
What a great explanation!!!
the semiphors video, where can I find it?
Thank u.... Great video ...nice explaination
I'm glad it was helpful.
May you explain other problems of synchronization, it would be really great!
Excellent explaination
What's the difference between using only one producer and several producers?
More complex synchronization is needed. You got to handle not only producer-consumer synchronization but also make sure that multiple producers or multiple consumers don't conflict between themselves.
Can somebody explain why using mutual exclusion will not work in the Producers & Consumers problem?
You can make it work, though it wouldn't be so elegant. Semaphores are the solution from one of the most popular college textbooks on Operating Systems. If you want to use something like mutexes, you can but don't try to lock the whole buffer with it. It would be very inefficient.
Thank you very much! Appreciate!
I really liked it. Good!
You Are Good!
Many thanks.
Great explanation!
Thank you
great videos! can you please make a video about semaphore? thanks!
Thank you. The rest is a part of the online "course" that can be found at
binary-wisdom.teachable.com/p/quick-explanations-for-the-operating-systems-course/
thank you a lot prof.
good explanation
Thank you
Good Video
Use a deque and there's no full condition.
You did not include the necessary mutex to ensure mutual exclusion between the consumer and the producer. This is not a complete explanation.
All the necessary synchronization is in place here. You don't need any special mutexes for this version of the problem (single producer and single consumer). Try to come up with a scenario that causes a mistake and you'll see how it works like that.