Це відео не доступне.
Перепрошуємо.
L-3.6: Test and Set Instruction in OS | Process Synchronization
Вставка
- Опубліковано 8 сер 2024
- 👉Subscribe to our new channel: / @varunainashots
Test and set algorithm uses a boolean variable 'lock' which is initially initialized to false. This lock variable determines the entry of the process inside the critical section of the code.
0:00 - Introduction
2:46 - "Test & Set" Instruction
►Operating System (Complete Playlist):
• Operating System (Comp...
Other subject-wise playlist Links:
--------------------------------------------------------------------------------------------------------------------------------------
►Design and Analysis of algorithms (DAA):
• Design and Analysis of...
►Database Management System:
• DBMS (Database Managem...
► Theory of Computation
• TOC(Theory of Computat...
►Artificial Intelligence:
• Artificial Intelligenc...
►Computer Networks (Complete Playlist):
• Computer Networks (Com...
►Computer Architecture (Complete Playlist):
• Computer Organization ...
►Structured Query Language (SQL):
• Structured Query Langu...
►Discrete Mathematics:
• Discrete Mathematics
►Compiler Design:
• Compiler Design (Compl...
►Number System:
• Number system
►Cloud Computing & BIG Data:
• Cloud Computing & BIG ...
►Software Engineering:
• Software Engineering
►Data Structure:
• Data Structure
►Graph Theory:
• Graph Theory
►Programming in C:
• C Programming
►Digital Logic:
• Digital Logic (Complet...
---------------------------------------------------------------------------------------------------------------------------------------
Our social media Links:
► Subscribe to us on UA-cam: / gatesmashers
►Subscribe to our new channel: / @varunainashots
► Like our page on Facebook: / gatesmashers
► Follow us on Instagram: / gate.smashers
► Follow us on Instagram: / varunainashots
► Follow us on Telegram: t.me/gatesmashersofficial
► Follow us on Threads: www.threads.net/@gate.smashers
--------------------------------------------------------------------------------------------------------------------------------------
►For Any Query, Suggestion or notes contribution:
Email us at: gatesmashers2018@gmail.com
Coming here to refer this video after watching my faculty's lecture recordings 5 times, clearly shows the one who isn't charging a penny is here to guide us and the one who is are there to confuse us. Sir, we your virtual students can't thank you enough for what you already are doing for us. An utmost respect to you and your efforts in spreading your knowledge in such an eloquent manner.
Some people are confused about how test_and_set helps at all because the same problem arises if we preempt after executing just the 1st line of test_and_set().
I agree, and I think the answer is that test_and_set is a special instruction, as he mentioned earlier in the video. So with the help of hardware, it is implemented in such a way that the entire function is atomic, so it will not preempt after the 1st line.
(The hardware implementation has to do something with DPRAM, Wikipedia has more details).
In other words, it's guaranteed that if a process is currently performing a test-and-set, no other process may begin another test-and-set until the first process's test-and-set is finished.
Ofcourse if the user wrote his own test_and_set function, then it fails because of reasons discussed already, so I guess that's why it requires the operating system to support test-and-set instruction.
And I guess that's why it works.
I have same doubt. Thanks for explanation.🙂
@@shubhambairagi4357 glad it helps
true. actually, he did not discussed about that. even semaphores and further stuff are also related to atomic instructions.
@@KunwarPratapSingh41951 Yup, that's right.
Thank u so much , i was also quite confused on this
One of the best teachers I have seen..Literally!...Hands down!! Sir makes us learn complex things in such an easy way....That's impeccable! Thankyou sir for all ur efforts..Big fan!!!!!!!
Sir can't thank you enough for what you already are doing for us. An utmost respect to you and your efforts in spreading your knowledge in such an eloquent manner.
You are a true teacher. You just made it so simple by your story telling skill.
Finally my phobia about test and set lock from this video over. Thank you for creating such cc explaination
Awesome lecture.....I have understood the whole concept easily.
you really have clear understanding of these topics ... thanks for choosing to make videos to help students.
One of the great teacher i had ever seen thank u so much sir🙏🙏🙏🙏
I am not understand concept of test and set instruction in college but yours simple explanation I am understand well,Thank you sir
Greatly Explained sir❤️... Thank You So Much ❤️❤️🙏
Thank you so much sir...
You're cleared my doubt...
Awesome lecture
Well explained sir👏👏👏👌
It works! Thanks a lot.
Yes yess getting the point 👍🏻
Example Of Washroom be like : permanent hu sir 😆😆. Thankyou sir for providing us easiest way to understand everything in os ❤️
DPRAM test-and-set instructions. Dual-ported RAM (DPRAM) is a type of random-access memory that allows multiple reads or writes to occur at the same time, or nearly the same time, unlike single-ported RAM which allows only one access at a time.
Thank You❤
tomorrow is my exam and today I am here , completing the playlist
thankyou sir explaining this topic very simply thankyouu sirrr
what if pre emption occurs when running second instruction of test_and_set()?
test_and_set() is not a software solution, it is a hardware solution, so it will execute as a single instruction only. the function call for test_and_set() that he showed is just a software implementation to know how it actually works, but in reality it is not implemented as a software. A dedicated processor opcode is made for this purpose. like for example intel processor (x86) have 86 instruction set right, like that one of the instruction is a test_and_set() operation. Intel's 'xchg' instruction is the one used for this purpose.
@@madhusudhanan9278 Thanks, that cleared it. I had the same doubt as Jay.
@@madhusudhanan9278 Thanks for clearing the doubt.
@@madhusudhanan9278 my doubt is cleared, thanks!!!!
Thanks bro for clearly explaining
Dear Mr Sir welcome to my comment....i requested you to include Computer Graphics also ..
very clear explaintion😍
Simple to understand
Thank you sir!
What an explanation.
while + Test and set also called spin lock(kernel/driver code). Atomic work on the same at Hardware abstraction layer.
Please make placement series
Thanks Sir 😊
sir you are great
For loop mein lock ki value ko vahin par 1 bhi set kar sakte hain. Is tarah se mutual exclusion satisfied hoga.
Nice sir
The reason for selecting default value as false in the function definition is because initially the critical section will be empty and if any of the the processes calls the function then function will return false at first (i.e for first process) and later that process will set the value of *target to true resulting infinite looping for processes which are trying to interrupt
thank you
Pre-emption can happen even inside the Test_and_Set function? In that case that will be behave similar to the 2 instructions where I1: while(lock == 1);, I2: lock = 1
Thanks
Thank u sooo muchhhhhhhhhhh
RBR SIR---> VARUN SIR (GOD OF COMPUTER SCIENCE) as era changes the believes also changes. This is my personal opinion. Lots of love Varun sir ❤️
8:19 Sir Aapka Ye Wala Dialogue Iss Series Mein Missing Tha ( ◜‿◝ )♡
I do have a problem i.e. even if we assume the initial value of lock is false then after the first instruction -
while(test_and_set(&lock)) -> inside while it will always be true(because inside the function we are making it true) even if the initial the value of lock is false and the process will get stuck in the infinite loop making the critical section inaccessible.
isn't ??????
But still how, test and set instruction achieve mutual exclusion on a multiprocessor system. On multiple cores, test and set instruction can be executed in parallel by two different processes, and so both processes could enter C.S simultaneously. The explanation in the video explains how test and set can help achieve mutual exclusion for uniprocessor systems. test and set inst is hardware solution and is atomic instruction, yet multiple processes can execute them on different cores in parallalel.
EXCELLENTLY EXCELLENTLY EXCELLENTLY EXPLAINED 🙂
Great explanation... But the subtitle is coming in the way.... Can hardly see the function code on the board... Please help
Love ❤️
😍
👍👍💯💯💯
If we put true in processor p1 then we return true in test and set always or not..?
bestest♥♥♥♥
*Hello Sir, Would you please be able to tell the result date of SBI SO(systems,IT) written exam!*
lekin agar sir critical situation ke baad prempt ho jaye mtlb load=false execute na ho paye then there is no mutual exclusion
mst!
sir, can interrupt occur while executing the test_and_set definition?
but in case while test_and_set method is executing is there any probabililty that after setting r the process will be preempted
Watched this video 2 times as first time got distracted by your hairs and was trying to understand the pattern. 😋
Sir I have 1 doubt,
Agar hm p1 pre - empt ho gya test and ser function keandar after bool r = * target, r=0 ho gya uske bad pre empt hoke p2 ke pas chla gya and p2 ab critical section m ghus skta h kyonki abhi tak hmne *target =true nhi kiya tha p1 m lekin jab ab p2 pre empt hoga critical section m and p1 wapis ayega to ab r 0 hi return krega to yahan p mutual exclusiveness break ho gya.
Sir process p2 to poora execute hoga na..uske baad hi to priority process p1 ke paas wapas jaayegi?? kyunki aapke example ke hisaab se process p2 me context switching nahi ho rahi
👌👌👌👌👌
sir I have a doubt if the preemption of process will happen in the 2nd line of function then what happen. that if p1 execute the line boolean r= *target and then go for bathroom and p2 execute the all line of the test_and_set (&lock) method then what will happen, then the mutule exclusion stay in the program. please reply me
❤️❤️
sir what if we set that if the code is preempt between 1 and 2 then it must start from 1 again.
👍
Can preemption happen before *target=True in test_and_set function for process 1
can u explain if P1 preempts after executing " boolean r = *target " line and then P2 comes in ?
I think in this situation it will be same as lock variable code.
yeh ni samajhaya jayega yaha.
nice doubt btw
I wrote this in another comment so I'll just paste it here in case you're still struggling.
Some people are confused about how test_and_set helps at all because the same problem arises if we preempt after executing just the 1st line of test_and_set().
I agree, and I think the answer is that test_and_set is a special instruction, as he mentioned earlier in the video. So with the help of hardware, it is implemented in such a way that the entire function is atomic, so it will not preempt after the 1st line.
(The hardware implementation has to do something with DPRAM, Wikipedia has more details).
In other words, it's guaranteed that if a process is currently performing a test-and-set, no other process may begin another test-and-set until the first process's test-and-set is finished.
Ofcourse if the user wrote his own test_and_set function, then it fails because of reasons discussed already, so I guess that's why it requires the operating system to support test-and-set instruction.
And I guess that's why it works.
@@AyushMo thum hi ho mata ja pita tumhi ho
@@goldenshower8210 haha nahi nahi
Sir please make playlist on iwt
Yai course kb complete hoga?
I think preempting would still make this process incapable of mutual exclusion. What if first process's test_and_set function stopped after assigning r = *target. Now second process's test_and_set function would still think that it can enter critical section. And so would first process's test_and_set function.
Test_and_set will not be preemted as it is made to work like that,after it get called the cpu can't preemt the process until test_and_set is completed
he did not discuss about that. ma'am actually test_and_set is hardware based solution. the function will be non-pre-emptive. this is a special function inbuilt.
@@KunwarPratapSingh41951well this is the most important point that the video didn’t tell
Thank you for the clarification
Aging algorithm????
Why cant be there preemption in the test_and_set function. It's a 3 line code in itself.
I wrote this in another comment so I'll just paste it here in case you're still struggling.
Some people are confused about how test_and_set helps at all because the same problem arises if we preempt after executing just the 1st line of test_and_set().
I agree, and I think the answer is that test_and_set is a special instruction, as he mentioned earlier in the video. So with the help of hardware, it is implemented in such a way that the entire function is atomic, so it will not preempt after the 1st line.
(The hardware implementation has to do something with DPRAM, Wikipedia has more details).
In other words, it's guaranteed that if a process is currently performing a test-and-set, no other process may begin another test-and-set until the first process's test-and-set is finished.
Ofcourse if the user wrote his own test_and_set function, then it fails because of reasons discussed already, so I guess that's why it requires the operating system to support test-and-set instruction.
And I guess that's why it works.
I think Progress will not work here when if p1,p2 preempt before return r; instruction
Just like there is prob. that P1 can pre-emept after while() and before lock=1; It can pre-emept in that test_and_set() as well. Now what ?
Sir P2 kab aayega CS mai ,kyuki while toh humesha hi true hoga........????
8:59 💯💯
First See than Read 👍
It's humble request
sir jab test_and_set() function chal rha hoga tab bhi toh beech mein preempt ho skta h, dusra process critical section mein aa skta h!!?? Please correct me if I'm wrong.
no. test_and_set operation is an atomic operation here! these instructions are always executed as a whole. they rely on hardware support. here the code is not complete (sir has used simple code for understanding), in real life we use certain keywords that guarantee the atomicity of certain processes. you can search for them.
I thought the solution should not be hardware dependent . Which is the 4th condition of solving critical section problem .. can someone shine a little light on this .. To sum up testAndSet is hardware solution .. but we studied that hardware solution are not acceptable .. where am i wrong here ?
BHAI MONITORS PR VIDEO BNADO MAI NASS KATLUNGA FAIL HO JAUNGA MARR JAUNGA PROPERTY BECHNI PAD JAEGI
Sir there is a problem. Mutual exclusion will not be achieved if the process is preempted during execution of the test_set function after line 1. r will have the previous value of lock variable and the while loop will let it go to the critical state if that happens.
Plz tell if I am getting something wrong 🙏
its the hardware functionality
@@fashionvella730 can u plz explain in details? I am a noob
@@ayanjit9196 test_and_set() is not a software solution, it is a hardware solution, so it will execute as a single instruction only. the function call for test_and_set() that he showed is just a software implementation to know how it actually works, but in reality it is not implemented as a software. A dedicated processor opcode is made for this purpose. like for example intel processor (x86) have 86 instruction set right, like that one of the instruction is a test_and_set() operation. Intel's 'xchg' instruction is the one used for this purpose.
@@madhusudhanan9278 oh. I see. This was bugging me for a long time. 😁
@@madhusudhanan9278 That was extremely helpful. Thanks :)
can any one tell what if preamption occur in the line between test_and_set function that is if line one of the function is executed and the the process is preamptered??
test_and_set() is not a software solution, it is a hardware solution, so it will execute as a single instruction only. the function call for test_and_set() that he showed is just a software implementation to know how it actually works, but in reality it is not implemented as a software. A dedicated processor opcode is made for this purpose. like for example intel processor (x86) have 86 instruction set right, like that one of the instruction is a test_and_set() operation. Intel's 'xchg' instruction is the one used for this purpose.
Hi ☺️
If you want to write before watching video 03:24
I tried so much to write in Hindi...?
Sir please make playlist on : 1. Internet Technologies ,
2. Digital Image Processing ,
3. Numerical Methods,
4. Machine Learning,
6. Software Engineering,
7. Computer Graphics,
8. System programming,
9. Introduction to Data Science.
Please 🥺 sir make playlist
College change karwa le bhaiii
@@__sagar_shah__591 🤣🤣
@@X40Gaming 😂😂🤗
anyone have written the notes...plz help me out?
ok
Sir even in this code mutual exclusion is not achieved.
Suppose P1 gets the processor first and it executes only first line of function ie (r=*target), now r receives false and CPU preempt .
And value of lock is still false. (Remember when p1 again gets CPU it will start it's execution from 2nd line of the function). Now p2 gets the CPU and it starts the execution of function . Since the value of lock was not updated to true, r receives false in it and suppose it executes the whole function and function returns false( becoz r is false), and p2 enters the critical section. Now again CPU preempt and P1 gets the CPU. Now value stored in r was false. And when it returns the r ie it will return false and P1 will also get into the critical section.
..............
Plz sir have a look at this and plz notify me if I am correct.🙏🙏😊
I agree, and I think the answer is that test_and_set is a special instruction, like he mentioned earlier in the video. So with the help of hardware it is implemented in such a way that the entire function is atomic, so it will not preempt after the 1st line. If the user wrote his own test_and_set function, then it fails because of reasons you mentioned above, so I guess that's why it requires the operating system to support test-and-set instruction.
@@AyushMo yes the the functions p(), v(), up(),down()etc have a special property that CPU cannot pre-empt unless it fully executes them.
@@amangupta3342 yup, after reading more, I discovered the hardware implementation has to do with something with DPRAM. And so it's guaranteed that if a process is currently performing a test-and-set, no other process may begin another test-and-set until the first process's test-and-set is finished. So, it works :D
@@AyushMo 👍👍
Scene-01:
Process P0 arrives.
It executes the test-and-set(Lock) instruction.
Since lock value is set to 0, so it returns value 0 to the while loop and sets the lock value to 1.
The returned value 0 breaks the while loop condition.
Process P0 enters the critical section and executes.
Now, even if process P0 gets preempted in the middle, no other process can enter the critical section.
Any other process can enter only after process P0 completes and sets the lock value to 0.
Scene-02:
Another process P1 arrives.
It executes the test-and-set(Lock) instruction.
Since lock value is now 1, so it returns value 1 to the while loop and sets the lock value to 1.
The returned value 1 does not break the while loop condition.
The process P1 is trapped inside an infinite while loop.
The while loop keeps the process P1 busy until the lock value becomes 0 and its condition breaks.
Scene-03:
Process P0 comes out of the critical section and sets the lock value to 0.
The while loop condition breaks.
Now, process P1 waiting for the critical section enters the critical section.
Now, even if process P1 gets preempted in the middle, no other process can enter the critical section.
Any other process can enter only after process P1 completes and sets the lock value to 0.
P2 washroom gia ta😂
Please make videos on DES and AES algorithms in network security
If not here then u can refer 5 min engineering's channel for that
Test_and_set method should be synchronized.
Ye Hamray Sir hai,
Ye reply wapas nahi karahy hai .
Sir hum phir say yahan comment karahy hai...🤣.
1000th view at 2 am❤️
Why are these videos never in english?
depends on the teacher , but ya i can say as i can understand he is the best teacher for this subject .
P1 washroom gaya tha Line Number 1 execute krne ke baad😅
Let me give a analogy.
Two man want to use a washroom, but since processor is one, only one man can stay conscious at a time and other asleep.
Now, person A goes to washroom, finds lock open, enters it and before he locks the door, he falls asleep.
Now person B awakes, he goes to washroom and finds the lock open, so he thinks no one is inside, and enters and locks the door and starts using the washroom.
Now, person B falls asleep while using washroom, person A awakes. He resumes and locks the locked door, and
and BANG!
Now, HOW TEST_AND_SET solves the issue?
When person A goes to washroom, he first checks if the door is open. If it is open, , then he enters it. (May be through space between door and floor).
Now, It cannot happen he entered, and door stays open right?
This dude being teached by college faculties......
Le GateSmashers:
Nigga whaaaa........ you got it wrong there buddy ...... please take a seat I will clear your misconceptions.....!!!!!
Getting the point?
😂
P2 ko diarrhea hai XD
Bro speak in English... Pls 🥺
I can't concentrate on both vd n subtitles 🥴😭
Very tough video bouncer ball not good lecture