Synchronization 1: Semaphores
HTML-код
- Опубликовано: 21 окт 2024
- This video presents the first of several synchronization tools: semaphores. Semaphores (specifically, counting semaphores) allow processes to send signals and request access to resources. When a resource is not available, the process waits until a signal is received. Based on content from the book Operating Systems: Internals and Design Principles, by William Stallings.
I have spent the past two weeks struggling to understand how semaphores work for a uni course I'm taking, and you have explained it more clearly in a little over 15 minutes than my course material and teacher could in those two weeks! Thank you so gd much!!
because of you I now unnderstand symaphore, thanks jacob
whoa! what an explanation, pure, simple... loved it
For the semsignal, shouldn't it be "If s >= 0" instead of "If s
this channel with x2 speed is life
lol
@@mostafaelgayar stalkerrrr
Thanks! Greetings from Argentina.
Explained in a simple way 😊 the semaphore count could be the number of database connections we have in pool or other similar limited resource. I am just thinking the logic to decrement, check if negative and if yes then block the process must all be done as a atomic operation yes?
OS has to do a lot of work if critical section does not complete. Is there a way for a process to signal that it is executing a critical section?
Wait! Isn't sem_post() or what you call semSignal() require the semaphore value (s) to be >= 0 to be able to signal (wake) any waiting (sleeping) process or thread? If so, how could you have s=-3 and sill be able to wake (signal) processes that are in the waiting queue?
bounced on my boy's Semaphore to this for hours
before i finish your explanation i want to thank you for it
i finally arrived to understand all the bla bla bla in the univ and other channels about semaphores
We implements a counting semaphore where multiple threads can call sem_wait
and sem_post concurrently.
In addition to the integer value N associated with the Semaphore, the semaphore includes a
waiting list that keeps track of the waiting threads and a mutex lock that protects the shared data
inside the semaphore instance. If two thread gets access to the semi_wait and semi_post if we use lock in semwait and semi post is ti correct implementation?
Really a very clear and apt explanation....
thank you
Do you use a watchdog to determine whether a process has timed out or not?
very interesting and easy to understand. helped me in my project report on semaphores. Thumbs up
why aren't you incrementing S each time the processus ends ?
it should be like this :
s=1
S=1-1=0
A executing
s=0+1=1
it is because of the time out ? i don't know it
semSignal increments s by 1, in this example "A" got interrupted BEFORE finishing its critical section, that means it didnt reach the sesSignal part. Thats the hole point of the semaphore, to not increment s until you are done with you "task", so nobody "messes" with your task , shared data etc.
Wait so A gets to go twice when C didn't even have one turn?
So well explained. Thank you very much !
Excellent video!
Just watch it in 1.25x speed
would each respective semaphore have their own queue of blocked process/threads waiting to use it? Thanks in advance.
Yes, each semaphore maintains its own queue
Great explanation! Thanks.
It's really helpful, thank you!
Great explanation sir! Well done. Thanks.
MAY GOD BLESS YOU !! what a nice explanation. thank you so much _/\_
can you have an interrupt increment s with semSignal without going through semWait?
Hi
I dont understand what you mean by ressource
I'm far too late I'm sure, but: a resource is the object of the synchronization. Say you have a file and several writing threads trying to access it, then clearly you don't want to have them all access it at once. This is the "resource" he speaks of; threads will have to queue up to wait for it.
Great video!
thank you my nigga
very helpful, thanks
הסבר מצויין !!!!! thenk you
wait. Wouldn't be more simple to just use bool instead of this????
If you are suggesting replacing the entire concept of a semaphore with a single boolean variable, then you are overlooking the fact that updates to a boolean variable in memory are not atomic, and thus do not guarantee synchronization. However, there are alternatives to semaphores that are a bit simpler to use.
@@JacobSchrum well yeah, i was trying to understand the differences but i guess i have more reading to do. Thanks for pointing an unobvious thing to me
I googled this video so I could know if I was saying it wrong.
Thank you
Gold blessYou
good
thank you :)
Cheers.
thanks!!!
Thank god, I found an American.
ağzına sağlık