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

Building a Better You: Fitness Tips and Inspiration.

Blog banner

Memory Management in Operating System

Blog banner

Memory Management

Blog banner

Data Science in Everyday Life (like a phone, shopping cart, or social media icons)

Blog banner

Service Transition Process in ITSM

Blog banner

S-Tool : Steganography

Blog banner

Types Of scheduling

Blog banner

Building a Simple Doctor Appointment System in Common Lisp

Blog banner

Women empowerment

Blog banner

Process in OS

Blog banner

Rock, Paper, Scissors Game in Common Lisp

Blog banner

Which Smartphone Company Has the Largest Market Share in India?

Blog banner

Virtual memory

Blog banner

Instagram

Blog banner

Mumbai Metro 3

Blog banner

The most common internet security threats

Blog banner

Data Visualization

Blog banner

Raising Emotionally Intelligent Students: The Classroom Beyond Academics

Blog banner

FIREWALL

Blog banner

Operating system evolution

Blog banner

I/O Management and Disk Scheduling

Blog banner

Blog on Smartsheet.

Blog banner

Understanding Regression Analysis

Blog banner

Landslide Hazard

Blog banner

Memory input output management

Blog banner

Networking 101: How to Build Meaningful Connections in College

Blog banner

The Bold Digital Marketing Moves That Made Durex India’s Second-Largest Condom Brand

Blog banner

How to setup a professional looking business account on Instagram?

Blog banner

Precision-Recall in Data Science

Blog banner

Principal of concurrency

Blog banner

Reclaim Your Bite and Beauty: All About Dental Restorative Treatments

Blog banner

Virtual memory

Blog banner

Quality check in IT services

Blog banner

What is M-commerce and how it's work

Blog banner

Pandas Matrix Applications

Blog banner

virtual machines and virtualization

Blog banner

My Favorite Country

Blog banner

Service Catalogue Management

Blog banner

Process, process creation and process termination

Blog banner

Current Trends in GIS and Remote Sensing(Ocean Applications)

Blog banner

Modern operating system

Blog banner

Mutual exclusion

Blog banner