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
343 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

AI and Data Science: Revolutionizing Industries

Blog banner

Goa Trip With Friends

Blog banner

Navigating the Digital Battlefield: Security Breaches and Effective Countermeasures

Blog banner

File management In Operating System

Blog banner

Bots and Cyber Security

Blog banner

Evolution of Operating Sytems

Blog banner

Unlocking Success: Mastering Google Ads Strategies

Blog banner

Memory management

Blog banner

10 Types of Friends in every friend group

Blog banner

Assignment 2

Blog banner

RAID_142

Blog banner

What is time ? The term which has astonished Scientists

Blog banner

10 Amazing facts about Tokyo Ghoul

Blog banner

Consumer to consumer business mode

Blog banner

World’s rarest passport owned by 500 people.

Blog banner

Data is an asset and it is your responsibility!

Blog banner

SESSION HIJACKING

Blog banner

Brilliant WhatsApp Features Upcoming in 2023

Blog banner

Security Issues and Countermeasures

Blog banner

Layers Of Blockchain

Blog banner

10 Reasons why Monica and Chandler are the best couple ever.!!!

Blog banner

A Survey of Anti-Forensic Techniques: Methods, Challenges, and Countermeasures

Blog banner

Real Time Scheduling

Blog banner

Precision-Recall in Data Science

Blog banner

Evolution of Operating System

Blog banner

Gis in agriculture and farming

Blog banner

COMMUNICATION

Blog banner

MODERN OPERATING SYSTEM

Blog banner

Memory Management Techniques

Blog banner

The Right way of cooking

Blog banner

Process State

Blog banner

Kernel in Operating System

Blog banner

Memory Management

Blog banner

Subnet Masking

Blog banner

What is Brute Force Attack? How to defend against it?

Blog banner

Why Mumbai Professionals Are Switching Back to Home-Style Tiffin Meals

Blog banner

Random Forests

Blog banner

Scheduling

Blog banner

Cyber Forensics in Healthcare: Protecting Patient Data and Preventing Breaches

Blog banner

Memory Management

Blog banner

Compromising Mobile Platforms

Blog banner

Business-to-Business

Blog banner