This channel is a blessing. During my undergrad, I used to refer to your videos to clear out my doubts. Now doing the same in my postgrad. Why on earth teachers can not teach like this.
Cause they want to complete the portion.... they too want to make the students clear. ..but some can't because they dont know.. and many can't because they dont have much time.. they can give you only a outline...what to do???. Its out fate.. 😅😅😇😊😉
The point of mutex is to lock a critical section so that it is thread safe but the call for P() itself is not, right? If two processes each read the check for S they will both see that S > 0 and continue to both run S--. How is this accounted for? I dont think the video talked about this specific scenario?
But what is the different between locks / semaphores and the other algorithms that we have seen like FCFS, RR and SJF , because all of them are synchronize and arrange the prosses.
In counting semaphores, if S is set to 4, then 4 processes enter the critical section at the same point of time, how it's possible because only one process can access the critical section. And what do you mean by an instance of a resource? Any example with c++ 20 code using counting semaphores.
You didn't need to repeat "enter the critical section or use the resource" a hundred times, it was extremely disturbing, just pick one of them. But thank you, I finally understood the concept after I failed to in 2 different subjects at the uni.
But as the critical section can only be accessed by one process at a time so how two processes are entering the critical section at the same time and using it in counting semaphore?
Counting semaphores are a generalisation of binary semaphores, whereas binary allows a maximum of 1 process to enter the critical section, counting allows up to n where n is a positive integer
What if s=1, hence both P and V execute simultaneously and during s++ and s-- we face the original producer consumer problem and instead of s being 1, takes value 0 or 2?
To prevent/protect a shared resource from being accessed by multiple processes at the same time we use Semaphore S, and wait() and signal() operations. But for wait() and signal(), again, the Semaphore is shared resource and they have critical section in them, so we have to again implement mutex for Semaphore S and so on. So, If you got what I just said, to solve a problem of mutex, we are generating another problem of mutex and that will recursively generate another and so on... So how do you solve this problem or where exactly did I go wrong?
You are correct that using a semaphore to protect a shared resource can introduce its own synchronization issues, particularly if multiple threads or processes need to access the semaphore itself. This can lead to a problem known as "semaphore contention," where threads or processes contend for the semaphore itself, rather than the shared resource it is protecting. To address this issue, it is important to carefully design the critical sections for the semaphore and ensure that they are as small and simple as possible. In particular, the critical section for the semaphore should be limited to the code that directly modifies the semaphore's value, such as the wait() and signal() operations. One common approach to minimizing semaphore contention is to use a variant of the semaphore known as a "spinlock." A spinlock is a type of lock that repeatedly checks the value of the semaphore in a loop until it becomes available, rather than blocking the thread or process. This can reduce the overhead of context switching and thread synchronization, particularly in high-concurrency environments. Another approach to reducing semaphore contention is to use techniques such as "reader-writer locks" or "lock-free algorithms," which are designed to allow multiple threads or processes to access a shared resource in a more fine-grained and efficient manner, without relying on traditional locks or semaphores.
S never exceeds one in binary semaphore , because to access the critical section wait operation is done. And after accessing signal operation is used . As signal and wait operations are used indivisibly , Semaphore value doesn't overflow , it remains between 0 and 1.
Why is it possible for different processes to be in the critical section for counting semaphores? I thought you sad we only want one process at a time in the critical section. Did I misunderstood something?
It's because they're atomic. I guess they're internally atomized using test_and_set or compare_and_set, and my faculty told test_and_set and compare_and_set cannot be called at the same time, there for you can't really call them at the same time (Don't know if the "cannot be altered part" is correct though).
If anyone is confused from the word Semaphore know that in Greek the word Σημαφόρος (Semaphoros) means Signal-bearer. Hope that helps.
we call traffic lights "semaforos" in Spanish lol
@@omardumet120 lol
Thanks, this opened up lot more meaning to this concept
in italian "SEMAFORO"
@@omardumet120 Yeah, my language is Spanish and when I heard the concept it was rather logical to know what it does
This channel is a blessing. During my undergrad, I used to refer to your videos to clear out my doubts. Now doing the same in my postgrad. Why on earth teachers can not teach like this.
Some teachers just try to talk for how long a lecture lasts...
Capitalized Education 👍
Cause they want to complete the portion.... they too want to make the students clear. ..but some can't because they dont know.. and many can't because they dont have much time.. they can give you only a outline...what to do???. Its out fate.. 😅😅😇😊😉
NESO academy really be pulling through. Thank you so much sir!
This perfect mini-course is better than my college's 10 hours course
Hahahah yep ,it's useful for the cs students
True bro 😂
This presentation is too good.
Understood it perfectly. Thank you so much sir❣️
Best explaintion of semaphoros on the entire Internet. Thank you so much sir
Thank you so much the idea is clear now, I cannot express how much you helped me
The session is too good. and precise Helps to understand very clearly. Thank you
Wow a new video on OS, finally I can continue my learning on OS that has begun since 2018 LOL
😂😂
😂😂
So u took 3 years to learn os huh
@@invinciblegirl4386😊😊
@@invinciblegirl4386😊😊😊😊😊
Became a fan of this channel, it saved my degree 🙏🙏💙💙
You are a master,sir!Great job!
One an only king for Operating Systems🔥🔥🙏🙏
Outstanding, makes it so easy and the way it s presented is great
Best explanation on TH-cam.
what an amazing explanation thankyou so much neso academy it is very heplfull !! thankyou again
Legendary explanation .., thank you champ
Djiktra himself explaining the Semaphore. Thanks
Best explanation ever.
thx dawg, gotta exam this morning. this really helped
very well explained sir.Thank you so much
Wow what a explanation sir .I am very cleared about this topic after watching your video thank you so much for such a valuable information sir
this is absolutely better than my university's course
it is now clear to me, thank you so much!
Thank you!
Great explanation ❤
one of the best explanation.
saviors for engineering students
well explained.
neso, you are saviour🙌
was really helpful. thank you very much.
Great video🙂
Nicely Explained 👌👌
Thank you
Thanks a lot for your clear explanation , Is there any
video for MUTUX?
instead of using var S u use mutex
Mutex locks are basically binary semaphores
very good explanation
You're the best!!
Excellent and crisp explanation. Thank you.
Thank you Neso
really awesome.
always the best
Thank you sir. explained very well.
Great Content
very valuable lacture for us thanks you 🤩
i really appreciate you
God level explanation💥👌
Thanks for this valuable video 💗
SIR YOU ARE GREAT
Amazing Explanation Sir..
Thank you so much 💓💓🥰🥰
The session is too good. Helps to understand very clearly. Thank you
ive learnt more things from neso academy (and other youtube tutorials ) than in UNI
And it is no joke
The point of mutex is to lock a critical section so that it is thread safe but the call for P() itself is not, right? If two processes each read the check for S they will both see that S > 0 and continue to both run S--. How is this accounted for? I dont think the video talked about this specific scenario?
The atomicity of P() ensures that race conditions do not occur when multiple processes/threads attempt to decrement the semaphore simultaneously.
Thanks!
Sir, please upload remaining videos in youtube. We can't be able to take screenshots of the lectures in neso app to revise them whenever we want...
But what is the different between locks / semaphores and the other algorithms that we have seen like FCFS, RR and SJF , because all of them are synchronize and arrange the prosses.
Best way to cover syllabus in less time is to watch your videos.
All the videos are great, only the lacking thing is coding part.
Thank you sir , that's the explanation i was looking for 🌹
In counting semaphores, if S is set to 4, then 4 processes enter the critical section at the same point of time, how it's possible because only one process can access the critical section. And what do you mean by an instance of a resource? Any example with c++ 20 code using counting semaphores.
Same doubt .if you know plz explain
S is set to 4 means there are 4 instances of the resource so 4 processes can enter in critical section at once.
does that violate Mutual Exclusion principle?@@apurvkumar1808
Damn! THANK YOU!
You guys always help me!
IN COUNTING SEMAPHORE :
Two processes goes to critical section at same time then it disobey mutual exclusion.
How it is a solution
You didn't need to repeat "enter the critical section or use the resource" a hundred times, it was extremely disturbing, just pick one of them. But thank you, I finally understood the concept after I failed to in 2 different subjects at the uni.
it wasnt disturbing for me. it helped me to understand thoroughly.
Truly thanks from an OS final headache person
sir you are the best
But as the critical section can only be accessed by one process at a time so how two processes are entering the critical section at the same time and using it in counting semaphore?
Counting semaphores are a generalisation of binary semaphores, whereas binary allows a maximum of 1 process to enter the critical section, counting allows up to n where n is a positive integer
Counting semaphores are used when processes need to access a resource which has n instances, so N processes can access that resource.
Really it's awesome
Best explanation ever🤌🤌
so amazing
Please send memory management in you tube not only in neso fuel please release in u tube
Very very amazing thank you
Thank you so much !!
very nicely explained. Thanks
Thanks
Thank you so much for this video.
Well elaborated
What if s=1, hence both P and V execute simultaneously and during s++ and s-- we face the original producer consumer problem and instead of s being 1, takes value 0 or 2?
To prevent/protect a shared resource from being accessed by multiple processes at the same time we use Semaphore S, and wait() and signal() operations. But for wait() and signal(), again, the Semaphore is shared resource and they have critical section in them, so we have to again implement mutex for Semaphore S and so on. So, If you got what I just said, to solve a problem of mutex, we are generating another problem of mutex and that will recursively generate another and so on... So how do you solve this problem or where exactly did I go wrong?
You are correct that using a semaphore to protect a shared resource can introduce its own synchronization issues, particularly if multiple threads or processes need to access the semaphore itself. This can lead to a problem known as "semaphore contention," where threads or processes contend for the semaphore itself, rather than the shared resource it is protecting.
To address this issue, it is important to carefully design the critical sections for the semaphore and ensure that they are as small and simple as possible. In particular, the critical section for the semaphore should be limited to the code that directly modifies the semaphore's value, such as the wait() and signal() operations.
One common approach to minimizing semaphore contention is to use a variant of the semaphore known as a "spinlock." A spinlock is a type of lock that repeatedly checks the value of the semaphore in a loop until it becomes available, rather than blocking the thread or process. This can reduce the overhead of context switching and thread synchronization, particularly in high-concurrency environments.
Another approach to reducing semaphore contention is to use techniques such as "reader-writer locks" or "lock-free algorithms," which are designed to allow multiple threads or processes to access a shared resource in a more fine-grained and efficient manner, without relying on traditional locks or semaphores.
@@Mehraj_IITKGP Thank You very much for taking time to resolve my doubt !!!
@@Mehraj_IITKGP wow , wrote an long ass para for solving a strangers doubt
Hats off boss!!!❤
Thank You :)
Worthy video
Why is there no while loop in signal's def. i mean if it's a binary semaphore and is already 1 won't it overflow ?
S never exceeds one in binary semaphore , because to access the critical section wait operation is done. And after accessing signal operation is used . As signal and wait operations are used indivisibly , Semaphore value doesn't overflow , it remains between 0 and 1.
Nice 😊☺️👍👍
Plz upload all lectures on youTube 🙏
I luv u dude 💙
why test and lock is a hardware solution? we also used a variable Lock, whereas semaphore is software solution
Why is it possible for different processes to be in the critical section for counting semaphores? I thought you sad we only want one process at a time in the critical section. Did I misunderstood something?
Just perfect!!!!
I think the definition of wait() is
Wait(S){
while s>= 0;
s--;
}
in the video it is
Wait(s){
while s
s
You missed the concept i would say
🙂 hi.. holaaa... Good to be here again 😇
Thank you sir..
In counting semephore..mutual exclusion is not followed..then how is it solving critical section problem?
How could we ensure that S will never be altered from different sources simultaneously?
It's because they're atomic. I guess they're internally atomized using test_and_set or compare_and_set, and my faculty told test_and_set and compare_and_set cannot be called at the same time, there for you can't really call them at the same time (Don't know if the "cannot be altered part" is correct though).
@@raaj7256 Thank you for your answer!! I have to learn how atomic works.
Is there any platform to get the notes of the lectures?
How can a Resource have multiple instances?! What kind of Resources are you talking about?
12:09 thank you))
Are sem_signal and sem_post the same thing? I’m a bit confused
good
What problem is there in critical section problem?
I'm watching this video for tomorrow my os exam lol
damn, my professor literally took months to explain this simple concept