SlideShare a Scribd company logo
6
Most read
7
Most read
9
Most read
Topic:
Semaphore
Contents
• What is Semaphore
• Types of Semaphore
• Counting Semaphore
• Binary Semaphore
• Counting Semaphore vs Binary Semaphore
• Limitations of Semaphore
2
What is Semaphore?
• Semaphores are integer variables, stores the entire wake up calls
• On which read, modify, update happens automatically in kernel mode
• Needs support from OS to be implemented
3
Continue
P(Semaphore s) { s = s - 1;
if (s <= 0) {
// add process to queue
block(); }
}
V(Semaphore s) {
s = s + 1;
if (s <= 0) {
// remove process p from queue
wakeup(p); }
}
4
Types Of Semaphore
According to the demand of the situation
• Counting Semaphore
• Binary Semaphore or Mutex
5
Counting Semaphore
• When we need to execute more than one process in critical section at the same
time.
• The value of counting semaphore at any point of time indicates that the maximum
number of processes that can enter the critical section at the same time.
6
Example:
• A counting semaphore was initialized to 12. then 10P(wait) and 4V
signal operation was computed on this semaphore.
1. S= 12 (initially)
2. 10P wait
3. SS= S-P=2
4. Then signal 4V
5. So Total SS = 4+2 = 6
7
Binary Semaphore
• Strictly provides mutual exclusion.
• Rather than having more than 1 slot, we can only have one process in the critical
section.
• Have only two value 0 and 1
• Extended version of counting semaphore.
8
Counting Semaphore vs Binary Semaphore
Counting Binary
1. No mutual exclusion. 1. Mutual exclusion
2. Any integer value 2. Value is 0 and 1
3. More than one slot 3. Only one slot
4. Provide set of Processes 4. Have mutual exclusion mechanism.
9
Limitations of Semaphore
• Priority Inversion is a big limitation of semaphores.
• Their use is not enforced, but is by convention only.
• With improper use, a process may block indefinitely. Such a situation is
called Deadlock.
10
Thank You
11

More Related Content

PDF
Difference State Actors and Non state Actors
PPTX
Operating system 32 logical versus physical address
PPTX
E-governance Models
PPTX
neural network
PDF
Semaphores
PPT
carry look ahead adder
PPTX
Process scheduling
PPTX
TOCOLYTIC AGENT.pptx
Difference State Actors and Non state Actors
Operating system 32 logical versus physical address
E-governance Models
neural network
Semaphores
carry look ahead adder
Process scheduling
TOCOLYTIC AGENT.pptx

What's hot (20)

PPTX
Deadlock Prevention
PPTX
Semophores and it's types
PPT
Deadlock detection and recovery by saad symbian
PPTX
Deadlock ppt
PPT
Operating Systems - "Chapter 5 Process Synchronization"
PPT
Chapter 6 - Process Synchronization
PPT
Deadlock
PPTX
Pipeline processing and space time diagram
PPTX
Lexical analyzer generator lex
PDF
Memory management
PPTX
contiguous memory allocation.pptx
PPTX
Process synchronization in Operating Systems
PPTX
Inter Process Communication
PPTX
Demand paging
PPT
ch10 Mass Storage Structure .ppt
PPT
Np cooks theorem
PDF
Fault tolerance
PPT
Chapter 13 - I/O Systems
PPTX
Distributed Shared Memory
PDF
Deadlock Avoidance - OS
Deadlock Prevention
Semophores and it's types
Deadlock detection and recovery by saad symbian
Deadlock ppt
Operating Systems - "Chapter 5 Process Synchronization"
Chapter 6 - Process Synchronization
Deadlock
Pipeline processing and space time diagram
Lexical analyzer generator lex
Memory management
contiguous memory allocation.pptx
Process synchronization in Operating Systems
Inter Process Communication
Demand paging
ch10 Mass Storage Structure .ppt
Np cooks theorem
Fault tolerance
Chapter 13 - I/O Systems
Distributed Shared Memory
Deadlock Avoidance - OS
Ad

Similar to Semaphore (20)

PPTX
OS Semaphore.pptx
PPTX
Semaphores SEMAPHORES Semaphores SEMAPHORES
PPT
Inter process communication
PPT
CChapter4.pptCChapter4.pptCChapter4.pptCChapter4.pptCChapter4.ppt
PPTX
B.Tech. Computer Science Engineering OS Notes Unit 2
PPTX
Operating system 24 mutex locks and semaphores
PDF
OPERATING SYSTEM NOTESS ppt Unit 2.1.pdf
PPTX
PPT 123456617829291912192891semaphores.pptx
PPTX
Interprocess Communication important topic in iOS .pptx
PPT
Process Synchronization -1.ppt
PPT
Performance Enhancement with Pipelining
PPT
OS Process Synchronization, semaphore and Monitors
PDF
Ch5 process synchronization
PPT
DOCX
UNIT III Process Synchronization.docx
PPTX
Process management in Operating System_Unit-2
PPTX
Process cooperation and synchronisation
PPT
Lecture18-19 (1).ppt
PPTX
Operating system 27 semaphores
OS Semaphore.pptx
Semaphores SEMAPHORES Semaphores SEMAPHORES
Inter process communication
CChapter4.pptCChapter4.pptCChapter4.pptCChapter4.pptCChapter4.ppt
B.Tech. Computer Science Engineering OS Notes Unit 2
Operating system 24 mutex locks and semaphores
OPERATING SYSTEM NOTESS ppt Unit 2.1.pdf
PPT 123456617829291912192891semaphores.pptx
Interprocess Communication important topic in iOS .pptx
Process Synchronization -1.ppt
Performance Enhancement with Pipelining
OS Process Synchronization, semaphore and Monitors
Ch5 process synchronization
UNIT III Process Synchronization.docx
Process management in Operating System_Unit-2
Process cooperation and synchronisation
Lecture18-19 (1).ppt
Operating system 27 semaphores
Ad

More from Arafat Hossan (20)

PPTX
Data Dictionary in System Analysis and Design
PPTX
Digital Data to Digital Signal Conversion
PPTX
Error and Exception Handling in PHP
PPTX
Bus Interface Unit(BIU) of 8086 Microprocessor
PPTX
Assembly language
PPTX
Web frameworks
PPTX
Cpu scheduling
PPTX
Deadlock
PPTX
Data model
PPT
Mapping cardinalities
PPTX
Sql in dbms
PPTX
Relational algebra in DBMS
PPTX
Divisible rules
PPTX
Processes in Operating System
PPTX
All pair shortest path
PPT
Asymptotic notation
PPTX
Merge sort
PPTX
Job sequencing with deadline
PPTX
Multithreading in java
PPTX
Multithreading in java
Data Dictionary in System Analysis and Design
Digital Data to Digital Signal Conversion
Error and Exception Handling in PHP
Bus Interface Unit(BIU) of 8086 Microprocessor
Assembly language
Web frameworks
Cpu scheduling
Deadlock
Data model
Mapping cardinalities
Sql in dbms
Relational algebra in DBMS
Divisible rules
Processes in Operating System
All pair shortest path
Asymptotic notation
Merge sort
Job sequencing with deadline
Multithreading in java
Multithreading in java

Recently uploaded (20)

PDF
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
PPT
Total quality management ppt for engineering students
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PDF
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
PPT
introduction to datamining and warehousing
PPTX
UNIT - 3 Total quality Management .pptx
PPTX
Fundamentals of Mechanical Engineering.pptx
PDF
86236642-Electric-Loco-Shed.pdf jfkduklg
PDF
Artificial Superintelligence (ASI) Alliance Vision Paper.pdf
PDF
III.4.1.2_The_Space_Environment.p pdffdf
PDF
UNIT no 1 INTRODUCTION TO DBMS NOTES.pdf
PDF
null (2) bgfbg bfgb bfgb fbfg bfbgf b.pdf
PPTX
CURRICULAM DESIGN engineering FOR CSE 2025.pptx
PPT
Introduction, IoT Design Methodology, Case Study on IoT System for Weather Mo...
PDF
COURSE DESCRIPTOR OF SURVEYING R24 SYLLABUS
PPTX
Artificial Intelligence
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PDF
PPT on Performance Review to get promotions
PDF
EXPLORING LEARNING ENGAGEMENT FACTORS INFLUENCING BEHAVIORAL, COGNITIVE, AND ...
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
Total quality management ppt for engineering students
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
introduction to datamining and warehousing
UNIT - 3 Total quality Management .pptx
Fundamentals of Mechanical Engineering.pptx
86236642-Electric-Loco-Shed.pdf jfkduklg
Artificial Superintelligence (ASI) Alliance Vision Paper.pdf
III.4.1.2_The_Space_Environment.p pdffdf
UNIT no 1 INTRODUCTION TO DBMS NOTES.pdf
null (2) bgfbg bfgb bfgb fbfg bfbgf b.pdf
CURRICULAM DESIGN engineering FOR CSE 2025.pptx
Introduction, IoT Design Methodology, Case Study on IoT System for Weather Mo...
COURSE DESCRIPTOR OF SURVEYING R24 SYLLABUS
Artificial Intelligence
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
R24 SURVEYING LAB MANUAL for civil enggi
PPT on Performance Review to get promotions
EXPLORING LEARNING ENGAGEMENT FACTORS INFLUENCING BEHAVIORAL, COGNITIVE, AND ...

Semaphore

  • 2. Contents • What is Semaphore • Types of Semaphore • Counting Semaphore • Binary Semaphore • Counting Semaphore vs Binary Semaphore • Limitations of Semaphore 2
  • 3. What is Semaphore? • Semaphores are integer variables, stores the entire wake up calls • On which read, modify, update happens automatically in kernel mode • Needs support from OS to be implemented 3
  • 4. Continue P(Semaphore s) { s = s - 1; if (s <= 0) { // add process to queue block(); } } V(Semaphore s) { s = s + 1; if (s <= 0) { // remove process p from queue wakeup(p); } } 4
  • 5. Types Of Semaphore According to the demand of the situation • Counting Semaphore • Binary Semaphore or Mutex 5
  • 6. Counting Semaphore • When we need to execute more than one process in critical section at the same time. • The value of counting semaphore at any point of time indicates that the maximum number of processes that can enter the critical section at the same time. 6
  • 7. Example: • A counting semaphore was initialized to 12. then 10P(wait) and 4V signal operation was computed on this semaphore. 1. S= 12 (initially) 2. 10P wait 3. SS= S-P=2 4. Then signal 4V 5. So Total SS = 4+2 = 6 7
  • 8. Binary Semaphore • Strictly provides mutual exclusion. • Rather than having more than 1 slot, we can only have one process in the critical section. • Have only two value 0 and 1 • Extended version of counting semaphore. 8
  • 9. Counting Semaphore vs Binary Semaphore Counting Binary 1. No mutual exclusion. 1. Mutual exclusion 2. Any integer value 2. Value is 0 and 1 3. More than one slot 3. Only one slot 4. Provide set of Processes 4. Have mutual exclusion mechanism. 9
  • 10. Limitations of Semaphore • Priority Inversion is a big limitation of semaphores. • Their use is not enforced, but is by convention only. • With improper use, a process may block indefinitely. Such a situation is called Deadlock. 10