Semaphores<\/strong> are synchronization tools used to manage how processes share resources like memory or data. They enforce mutual exclusion<\/strong> and prevent race conditions<\/strong> by using two operations: wait (P)<\/strong> and signal (V)<\/strong>. A semaphore blocks a process when its value is zero, allowing controlled access to shared resources. Counting semaphores<\/strong> help implement synchronization by coordinating process activities. Understanding semaphores is essential for GATE<\/strong> preparation and mastering process synchronization in operating systems<\/strong>.

For more details, check out the full article: Semaphores in Process Synchronization<\/a>.<\/p>\",\"source\":\"https:\/\/cdnvideos.geeksforgeeks.org\/hls\/2b2b777f47601a2e4368067b40a47e38gfg--20210407--copy--2b2b777f47601a2e4368067b40a47e38gfg-Semaphore.m3u8\",\"category\":[{\"term_id__id\":166,\"term_id__term_name\":\"courses populated\",\"term_id__term_type\":2,\"term_id__slug\":\"courses-populated\"},{\"term_id__id\":167,\"term_id__term_name\":\"Data Structures and Algorithms\",\"term_id__term_type\":1,\"term_id__slug\":\"data-structures-and-algorithms\"}],\"meta\":{\"thumbnail\":\"https:\/\/media.geeksforgeeks.org\/courses\/SemaphoreVideo\/Semaphore20241127175054-small.png\",\"largeThumbnail\":\"https:\/\/media.geeksforgeeks.org\/courses\/SemaphoreVideo\/Semaphore20241127175054.jpg\",\"likes\":0,\"views\":50500,\"isFeatured\":0,\"isPremium\":0,\"isPublic\":1,\"format\":0,\"revision\":{}},\"time\":\"15\/10\/2019\",\"subtitle\":\"https:\/\/cdnvideos.geeksforgeeks.org\/subtitles\/2b2b777f47601a2e4368067b40a47e38gfg--20210407--copy--2b2b777f47601a2e4368067b40a47e38gfg-Semaphore.vtt\",\"duration\":1067,\"course_link\":\"https:\/\/gfgcdn.com\/tu\/U4D\/\",\"video_schema\":{\"@context\":\"https:\/\/schema.org\",\"@type\":\"VideoObject\",\"name\":\"What is Semaphore in Operating System\",\"description\":\"Semaphores are synchronization tools used to manage how processes share resources like memory or data. They enforce mutual exclusion and prevent race conditions by using two operations wait (P) and signal (V). A semaphore blocks a process when its value is zero, allowing controlled access to shared resources. Counting semaphores help implement synchronization by coordinating process activities. Understanding semaphores is essential for GATE preparation and mastering process synchronization in operating systems.For more details, check out the full article Semaphores in Process Synchronization.\",\"thumbnailUrl\":[\"https:\/\/media.geeksforgeeks.org\/courses\/SemaphoreVideo\/Semaphore20241127175054.jpg\",\"https:\/\/media.geeksforgeeks.org\/courses\/SemaphoreVideo\/Semaphore20241127175054-seo.png\",\"https:\/\/media.geeksforgeeks.org\/courses\/SemaphoreVideo\/Semaphore20241127175054-small.png\"],\"uploadDate\":\"2019-10-15T14:18:31Z\",\"duration\":\"PT0H17M47S\",\"contentUrl\":\"https:\/\/www.geeksforgeeks.org\/videos\/semaphore-video-lwsiqu\/\"}},{\"id\":7132,\"title\":\"Semaphores in Operating System\",\"slug\":\"semaphores-in-operating-system\",\"description\":\"

In this video, we will be discussing what is semaphores in operating systems.<\/strong>
Semaphores<\/strong> are used to handle concurrent processes during process synchronization.  It is an integer variable which is shared between processes. Semaphores solve the critical section problem in multiprocessing systems. 

Semaphores are of two types: <\/strong>
1) Binary Semaphores 
2) Counting Semaphores
 
Binary Semaphore:<\/strong> It can take only 2 values: 0 or 1. It is used to implement mutual exclusion among the processes wanting to share the critical section. For this reason, it is also known as a mutex lock. Initially the value of binary semaphore is 1. 

Counting Semaphore:<\/strong> It is used to control sharing of a resource that has multiple instances. The values of a counting semaphore can span an unrestricted range. Only two functions can access and modify the values of semaphores. These are the Wait and Signal<\/strong> operations. 
1) Wait()<\/strong> is also known as Sleep operation or Down operation.<\/strong> 
2) Signal() <\/strong>is also known as Wake-up operation or Up operation. <\/strong>

Both operations are atomic in nature i.e. when any of these two operations is being performed, they cannot be preempted. 
The Critical Section is surrounded by these two operations. 

Semaphore in OS:
https:\/\/www.geeksforgeeks.org\/semaphores-in-process-synchronization\/<\/u><\/span><\/a><\/p>\",\"source\":\"https:\/\/videos.geeksforgeeks.org\/hls\/2c6a9aefbb426d247b1beb53b2b95d61gfg-SemaphoreinOS20221025123220.m3u8\",\"category\":[{\"term_id__id\":102,\"term_id__term_name\":\"OS\",\"term_id__term_type\":2,\"term_id__slug\":\"os\"},{\"term_id__id\":159,\"term_id__term_name\":\"CS-subjects\",\"term_id__term_type\":1,\"term_id__slug\":\"cs-subjects\"}],\"meta\":{\"thumbnail\":\"https:\/\/media.geeksforgeeks.org\/geeksforgeeks\/SemaphoresinOperatingSystem\/Semaphore20221027150958-small.png\",\"largeThumbnail\":\"https:\/\/media.geeksforgeeks.org\/geeksforgeeks\/SemaphoresinOperatingSystem\/Semaphore20221027150958.jpg\",\"likes\":1,\"views\":13480,\"isFeatured\":0,\"isPremium\":0,\"isPublic\":0,\"format\":\"video\/mp4\",\"revision\":{}},\"time\":\"27\/10\/2022\",\"subtitle\":\"https:\/\/videos.geeksforgeeks.org\/subtitles\/SemaphoreinOS20221025123220.vtt\",\"duration\":1421,\"course_link\":null}]"); Semaphores in Process Synchronization - GeeksforGeeks