Back to Browse

BINARY SEMAPHORE | OPERATING SYSTEM | GATE CSE LECTURES

540 views
May 14, 2021
17:17

In this video, I have discussed binary semaphore 00:00 - Introduction 00:46 - Overview about counting semaphore 04:22 - Binary semaphore 05:31 - Working process of binary semaphore #binarysemaphore #operatingsystems #parnikatutorials Instagram: https://www.instagram.com/parnikatutorials/ Website: www.parnikatutorials.in Email id: [email protected] To get the regular updates: Telegram link: https://t.me/Parnikatutorials Facebook: https://m.facebook.com/profile.php?id=109245950811428&ref=content_filter Linkedin: https://www.linkedin.com/in/parnika-tutorials-a8a9831b2/ Pinterest: https://in.pinterest.com/parnikatutorials0892/ GATE Video Resources: Digital Logic: https://www.youtube.com/watch?v=iJN9q01OWtw&list=PL4x0v29DZ2pA2ZmL3dclnA-HfHkFAy0GI Computer Organization and Architecture: https://www.youtube.com/watch?v=iJN9q01OWtw&list=PL4x0v29DZ2pBRd8bChJJFtTn6ClJhKzfZ C Programming: https://www.youtube.com/watch?v=h9LtX_R-7uA&list=PL4x0v29DZ2pAIQdtRr-1zaYnqGiD_fU0M Data Structures: https://www.youtube.com/watch?v=m51BGPXdPAQ&list=PL4x0v29DZ2pCtKml6NNoBhYK4K_QnsCA_ Theory of Computation: https://www.youtube.com/watch?v=iJN9q01OWtw&list=PL4x0v29DZ2pDq-5SI9KlYxPDKdYCcmgJm Compiler Design: https://www.youtube.com/watch?v=iJN9q01OWtw&list=PL4x0v29DZ2pBsF-lPUHQ_8uRy-LbDSHIH Operating Systems: https://www.youtube.com/watch?v=vCCmq8hTC8Y&list=PL4x0v29DZ2pD6MzSQMIDSawLSKUZTFfxE Databases: https://www.youtube.com/watch?v=iJN9q01OWtw&list=PL4x0v29DZ2pCYEa9s3r5zWrFYIxGivlEC Computer Networks: https://www.youtube.com/watch?v=iJN9q01OWtw&list=PL4x0v29DZ2pBBOq-QsHtCuA53IlRxIQNm For GATE PYQs and much more explore: https://www.youtube.com/c/ParnikaTutorials/playlists Semaphore was proposed by Dijkstra in 1965 which is a very significant technique to manage concurrent processes by using a simple integer value, which is known as a semaphore. Semaphore is simply an integer variable that is shared between threads. This variable is used to solve the critical section problem and to achieve process synchronization in the multiprocessing environment. Semaphores are of two types: Binary Semaphore – This is also known as mutex lock. It can have only two values – 0 and 1. Its value is initialized to 1. It is used to implement the solution of critical section problems with multiple processes. Counting Semaphore – Its value can range over an unrestricted domain. It is used to control access to a resource that has multiple instances. Some point regarding P and V operation P operation is also called wait, sleep, or down operation, and V operation is also called signal, wake-up, or up operation. Both operations are atomic and semaphore(s) is always initialized to one. Here atomic means that variable on which read, modify and update happens at the same time/moment with no pre-emption i.e. in-between read, modify and update no other operation is performed that may change the variable. A critical section is surrounded by both operations to implement process synchronization. See the below image. The critical section of Process P is in between P and V operation. Limitations : One of the biggest limitations of semaphore is priority inversion. Deadlock, suppose a process is trying to wake up another process which is not in a sleep state. Therefore, a deadlock may block indefinitely. The operating system has to keep track of all calls to wait and to signal the semaphore. Problem in this implementation of semaphore : The main problem with semaphores is that they require busy waiting, If a process is in the critical section, then other processes trying to enter critical section will be waiting until the critical section is not occupied by any process. Whenever any process waits then it continuously checks for semaphore value (look at this line while (s==0); in P operation) and waste CPU cycle. There is also a chance of “spinlock” as the processes keep on spins while waiting for the lock. To avoid this another implementation is provided below.

Download

1 formats

Video Formats

360pmp441.8 MB

Right-click 'Download' and select 'Save Link As' if the file opens in a new tab.

BINARY SEMAPHORE | OPERATING SYSTEM | GATE CSE LECTURES | NatokHD