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

Embaded operating system

Blog banner

My First Trek - Sondai, Karjat - Shoaib Malik

Blog banner

Trello ( management software)

Blog banner

Automating OSINT tasks for efficient Cyber Forensics Investigations

Blog banner

Multiprocessor

Blog banner

Why Kanye West (Now Ye) is the GOAT: A Legacy Beyond Music

Blog banner

Meal Maharaj — 3 CP, 5 CP, 8 CP. Same Love, Different Portions

Blog banner

Top Career Paths After a B.Com Degree in Mumbai: What’s Next for You?

Blog banner

OS- Assignnment 1

Blog banner

File Systems in OS.

Blog banner

Assignment-3

Blog banner

Evolution of Operating system

Blog banner

Basic Security For SOAP Services

Blog banner

Anomaly Detection in Behavioral Data Using Machine Learning

Blog banner

Short note on expert system

Blog banner

MEMORY MANAGEMENT (techniques)

Blog banner

ProofHub

Blog banner

"Geographic Information Systems (GIS) and its Applications in Urban Planning"

Blog banner

DATA BREACH CAUSES CHALLENGES PREVENTION AND FUTURE DIRECTIONS

Blog banner

MD5 Collisions and the impact on computer forensics

Blog banner

BUSINESS MODELS OF E COMMERCE

Blog banner

Quality check in IT services

Blog banner

Toothache Causes: Common Tooth Pain Reasons & When to See a Dentist

Blog banner

Direct Memory Access

Blog banner

TAILS OS

Blog banner

Drawing tips for a beginner

Blog banner

MYNTRA

Blog banner

CSI and Organizational Change

Blog banner

Diwali

Blog banner

Healthy Indian Dinner Ideas for Better Digestion and Sleep

Blog banner

Malware Detection Techniques for Mobile Devices

Blog banner

A Short History of GIS

Blog banner

The Art Of Getting What You Want In Life....

Blog banner

Virtual Memory

Blog banner

What is OS and its overview

Blog banner

Policies for Service Transition

Blog banner

Zomato's Secret Digital Marketing Techniques!

Blog banner

The role of artificial intelligence in automating digital forensic analysis.

Blog banner

How to Find the Right Therapist For Me?

Blog banner

HUBSPOT

Blog banner

PROCESS STATE:

Blog banner

Deadlock

Blog banner