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

Cloud Computing

Blog banner

John Titor: The Time Traveler

Blog banner

Service Catalogue Management

Blog banner

How To Setup DVWA Using XAMPP on Windows

Blog banner

The khan mehtab transforming the modular switches company

Blog banner

Microsoft Word

Blog banner

Malware Detection Techniques for Mobile Devices

Blog banner

Drawing tips for a beginner

Blog banner

RAID

Blog banner

Virtual memory

Blog banner

Fault Tolerance in an Operating System

Blog banner

Odoo

Blog banner

Amazon

Blog banner

MORDERN UNIX SYSTEM

Blog banner

Risk mitigation and management

Blog banner

How to Encrypt and Decrypt Using GNU PGP

Blog banner

Instagram Features in 2023 That Will Leave You Stunned!

Blog banner

How To Implement Search Engine Marketing (Sem) Strategy Effectively

Blog banner

Introduction my self

Blog banner

Record Blocking

Blog banner

Hubspot

Blog banner

LINUX

Blog banner

1.1 basic elements

Blog banner

Environmental Management using GIS

Blog banner

Jira service Management

Blog banner

Semaphores

Blog banner

Data Science in Mental Health Prediction

Blog banner

Concurrency and Deadlocks

Blog banner

How to make Pancakes

Blog banner

Old age lifestyle

Blog banner

Fitness

Blog banner

Binary Search Tree (BST) in Data Structure

Blog banner

Electronic Funds Transfer

Blog banner

The Future of Cybersecurity: Trends, Challenges, and Strategies

Blog banner

Disk Management

Blog banner

Web Site

Blog banner

Ethical Hacking

Blog banner

Different types of e-commerce platforms or advantages and disadvantages

Blog banner

Internet of Things and cyber security

Blog banner

How to Prepare Your Child for Their First Day of School?

Blog banner

Southern Turkey Earthquake: Causes and Consequences of a Tragic Natural Disaster

Blog banner

Real-Time Operating Systems (RTOS) Deep Explanation

Blog banner