Semaphore | Counting & Binary | OS | Lec-56 | Bhanu Priya

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi students coming to the next topic in the subject operating system was some of us so the some of us is the one of the important topic in the operating system so now let us see what is this actually some of first is nothing but it is just an integer variable some of us will represent as a s variable this is simply an integer variable Y we are using this integer variable and Y we are calling this as a sum of us so let me explain actually the same office synchronous a ie we call it as a synchronization tool that does not require a busy waiting it doesn't want to maintain a busy waiting it want to execute the processor ok whatever the processor that wants to exist enter into critical section that has to be executed so it doesn't support busy waiting so assam office is a synchronization tool that does not require busy waiting and we are taking s as an individual variable which used for the same office it can be accessed via two indivisible atomic operations so the same office will use two indivisible atomic cooperations wait s signal yes so these are the two atomic operations these two atomic operations are used by this amorphous so what do you mean by wait and what do you mean by the signal why this some office is using this wait and signal to maintain the busy waiting okay so first what this weight is doing whenever you mention that weight some of us first this weight some of us will enter into this while loop while as less than or equal to 0 do no operation semicolon S has to be decremented s is equal to s minus 1 so this is the code for the weight and mix coming to this signal next atomic cooperation is signal which is used by the cemre first variable signal s signal s indicates s is equal to s plus 1 so here weight is doing the operation as a decrement operation and the signal is using the operation as a increment operation so why this semaphore is using these two atomic operations weight and signal okay so we know that whenever this while condition is satisfied it will execute the program okay here there is no program why there is no program because it is ended with semicolon while s less than or equal to zero there is do no operation so whenever the condition is satisfied it doesn't do any operation so it is continually rotating means it is in a loop condition only so whenever this condition is satisfied it has to be in a busy waiting so we have to take care that this condition does not satisfied then only the process will be executed with our busy waiting so that's why we have to make it as a semicolon semicolon means this statement will be ended so we know that the while condition so generally the while means the whenever the while check the condition first it checks the condition means s less than or equal to zero so whenever this condition is true it entered into this statement so it will execute until the statement is true it states the conditions and again it goes for thee and in the checking the another condition again executes the statement so if the condition is false it exits from the loop so this is actually the while operation so here I am saying while as less than or equal to zero okay do no operation means there is no code here so whenever the condition is satisfied there is no to execute for this so just hear what it save I'll check the condition so if the conditional Sat is fine it has to execute the statement but there is no statement here there is no statement so compulsory it has to be exist exit from the loop so that whenever the condition is satisfied it exits from the loop and executes the next statement that is present in the code so that's why we are using this weight operation okay one process is executing without busy waiting so why I am decrementing this s is equal to s plus 1 and I mean using the S is equal to s plus 1 so whenever the same offers value is 1 then only that process will enter into critical section other process will not enter into critical section so after decrementing the value s becomes 0 so next enter process means it saying that it is exit so if another process wants to execute again into the critical section so that's why we are using signal operation s is equal to s plus 1 here it is incrementing the S value as 1 so then next process will enter into critical section so that's the concept of some of us the same of us here we are using that it is a synchronization tool that does not require a busy waiting so without maintaining the busy waiting it is executing the program by using two atomic operations weight and signal now let us see the the some offers general synchronization tool I said the same offers as a general synchronization to let me explain that same office as general synchronization tool that we used in the operating system how it is how we call this as a general synchronization - here we are using the 2 concepts one is accounting some office and another is binary some of us counting some of us means uh whatever the individual value we are taking the integer value can range over a none and unrestricted domain unrestricted domain so that is that you call it as a counting some of us then what about the binary some of us binary some of us means integer value can range over between only two values that is a zero and one which can be simpler to implement so rather than going for the unrestricted don't mind if you are taking the more range of values it's better to take only two range values 0 and 1 so that is a concept of binary some of us binary means only it is using the two values 0 and 1 there is the counting some of us means it can use the integer value that can range over an unrestricted the mine okay so this some of us will use the it mainly provides the mutual exclusion concept first it follows the mutual exclusion concept so let me write at some of us code here do i am writing wait some of us value next critical section signal s reminder section while condition so this everything is about the critical section the main thing here is we have to execute the program which are using the resource same resources that should be entered into critical section so whatever the concepts here we are explaining is completely about process synchronization our main aim is we have to make the process synchronization we have to make the program as a consistent state you have to make the program as it executes the program in consistent state in a consistent state so to maintain that process in synchronization we are using this some office value here so here in some of us we are using two atomic very concept that is a weight atomic cooperations weight and signal so in the previous mutual exclusive exclusion or in the critical section problem I just given that in pre section critical section exit section reminder section but instead of entry section and exit section I am using the two atomic cooperations weight and signal why why I am using this weight and signal instead of entry and exit section let me explain that so here I am saying that weight is starting the S variable that is a some office variable should be initialized with one so whenever the weight s is they that weight program what is that weight is why s less than or equal to zero no operation okay and you have to decrement the S value exit the while loop so whenever I call the weight s first it takes the weight one its takes the weight one so it's checking is 1 less than or equal to 0 1 less than or equal to 0 no it's not 0 so it exists from the while loop and decrements the s value s minus 1 means 1 minus 1 0 now here s becomes 0 so whenever there's become 0 then the processor will enter into critical section so until that s will 1 the processor will enter into critical section and execute the program ok that process p1 enter into critical section here P even it enter into critical section and executing the program ok after that I am calling signal s signal s means just it increments the s value as is equal to s plus 1 means 0 previously s is 0 so it increments this value 0 plus 1 now s becomes 1 so whenever that is s is equal to 1 means it's coming to the starting position next for p2 process will enter into critical section so the PD is waiting until this becomes 1 so that's why we have used thus wait and signal operation where it is decrementing the sum of this value by 1 and where a signal is incrementing the s some of us value by 1 so whenever the s is 1 s is equal to 1 it indicates that no process is there in critical section so then next process will enter into critical section so this is a concept of the same of us thank you
Info
Channel: Education 4u
Views: 143,127
Rating: 4.6002545 out of 5
Keywords: semaphore in os, semaphore operating system, semaphore in operating system in english, semaphore in operating system tutorial, semaphore tutorial, semaphore os tutorial, semaphore os, semaphore operating system tutorial, semaphore explanation, semaphore explained
Id: 93HWqtEUBQw
Channel Id: undefined
Length: 12min 2sec (722 seconds)
Published: Wed May 30 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.