OS Semaphore.pptx

39 views 10 slides Jul 06, 2023
Slide 1
Slide 1 of 10
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10

About This Presentation

Study of Operating system on semaphore


Slide Content

Operating System Concepts Instructor Name: Muhammad Asif 1

Quick Recap of Previous Lecture Critical Section Problem Condition for the Solution to the Critical Section Problem Race Condition Peterson’s Solution 2

Today’s Outlines Software solution to the Critical Section Problem Semaphore Wait ( ) Signal ( ) Types of Semaphore Counting semaphore Binary semaphore Advantages of semaphore 3

Semaphore Semaphore is an integer variables that are used to solve the critical section problem by using two atomic operations, That are used for process synchronization: Wait() Signal () Always initialize the variable with 1 if solving the Critical Section Problem: int S = 1; 4

Semaphore d o { wait ( S ); // ftn call // critical section // enter in its critical section Signal ( S ); // ftn call // termination section }while(true); 5

Semaphore Where int S = 1; d o{ wait ( S ); // ftn call // critical section // enter in its critical section Signal ( S ); // ftn call // termination section }while(true); 6

Types of Semaphores There are two main types of semaphores i.e. counting semaphores and binary semaphores. Details about these are given as follows: Counting Semaphores Binary Semaphores 7

Semaphore Binary Semaphores The binary semaphores are like counting semaphores but their value is restricted to 0 and 1. The wait operation only works when the semaphore is 1 and the signal operation succeeds when semaphore is 0. It is sometimes easier to implement binary semaphores than counting semaphores. Counting Semaphores: These are integer value semaphores and have an unrestricted value domain. These semaphores are used to coordinate the resource access, where the semaphore count is the number of available resources. If the resources are added, semaphore count automatically incremented and if the resources are removed, the count is decremented. 8

Advantages of Semaphores Semaphore is used to solve different problems like: Critical Section Problem Order of execution among the processes Resource Management 9

Any Questions? 10
Tags