wisemonkeys logo
FeedNotificationProfileManage Forms
FeedNotificationSearchSign in
wisemonkeys logo

Blogs

What is semaphore in operating system?

profile
Khushi Joshi
Jul 11, 2023
2 Likes
0 Discussions
344 Reads

In operating systems, a semaphore is used to control access to shared resources. It is a variable or an abstract data type that is used to solve the critical section problem, which arises when multiple processes or threads need to access a shared resource simultaneously.

 

For example, when there are two person A and B wants to use one computer at the same time then comes the role of semaphore.

 

It indicates that the computer is free or is in use.

 

If it is free, it will set the counter as 1, and if it the counter is set to 0, it means the computer is in use.

 

The semaphore provides two main operations:

Wait (P) operation: When a process/thread wants to access the shared resource, it performs the wait operation on the semaphore. If the counter is greater than zero, the process/thread decrements the counter and continues accessing the resource. If the counter is zero, indicating that all resources are currently being used, the process/thread is put into a waiting state until a resource becomes available.

 

Signal (V) operation: After a process/thread completes its use of the shared resource, it performs the signal operation on the semaphore. This operation increments the counter, indicating that a resource has been released and is now available for other processes/threads to use. If any waiting processes/threads were blocked, one of them is awakened and allowed to proceed.


Comments ()


Sign in

Read Next

The New Dr. Frankenstein who will perform first full head transplant

Blog banner

Deadlock

Blog banner

MEMORY MANAGEMENT (techniques)

Blog banner

Is It Too Late to Straighten My Teeth as an Adult?

Blog banner

MySQL

Blog banner

Interrupts - Types, Working & Importance

Blog banner

Traditional UNIX Scheduling

Blog banner

Rules and Regulations of Networking: "Standards and Protocols" - Part 1

Blog banner

Interrupts

Blog banner

How to Avoid being a Victim of Cybercrime

Blog banner

Memory input output management

Blog banner

Top 4 Places To Stay In Copenhagen

Blog banner

Steganography and Steganalysis

Blog banner

John Titor: The Time Traveler

Blog banner

Webmail

Blog banner

MODERN OPERATING SYSTEM

Blog banner

I/O Buffering

Blog banner

Random Forests

Blog banner

Raid

Blog banner

Full Disk Encryption

Blog banner

The Everyday Parenting Dilemma: Safety Vs Independence

Blog banner

Different types of e-commerce platforms or advantages and disadvantages

Blog banner

Emerging threats in cyber Forensics

Blog banner

Digital marketing spotlight “Dove’s Real Beauty Campaign”

Blog banner

I/O Management and Disk Scheduling

Blog banner

The Impact of Cyber Forensics on Corporate Governance and Compliance

Blog banner

Traditional Unix System

Blog banner

What is M-commerce and how it's work

Blog banner

Security requirements for Safe E-Payments

Blog banner

OS ASSIGNMENT

Blog banner

Objectives and functions of Operating System...

Blog banner

"Audit" In Data Science

Blog banner

CyberSecurity Color Wheel

Blog banner

Not anti-social, but pro-solitude

Blog banner

Deadlock and Starvation

Blog banner

Modern Operating system

Blog banner

About myself

Blog banner

Review on Cyber Forensics and its Analysis Tools

Blog banner

Characteristics of Etherum

Blog banner

Memory Management

Blog banner

Facebook Shut Down an AI Program!!! Facebook AI bots became Terminators???

Blog banner

Top 5 Tech Innovations of 2018

Blog banner