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

Fun Christmas Activities For Toddlers & Kids

Blog banner

SPEM

Blog banner

Kafka - A Framework

Blog banner

Security issues

Blog banner

Modern Operating System

Blog banner

Title: Network Sniffing Techniques: Uncovering the Secrets of Data Transfer

Blog banner

The Power of Teamwork: Learning Collaboration Through Everyday Activities

Blog banner

OS DESIGN CONSIDERATIONS FOR MULTIPROCESSOR

Blog banner

Indian Food

Blog banner

6 Digital Marketing Trends You Must Watch Out For In 2022

Blog banner

TRIGGERS IN DATABASE

Blog banner

MySQL

Blog banner

Craziness of dream 11 and how it impacts on our life

Blog banner

Direct Memory Access

Blog banner

Decrypting Cryptocurrency: Tracing Transactions in Cyber Investigations

Blog banner

Blockchain uses and use cases

Blog banner

The khan mehtab transforming the modular switches company

Blog banner

Traveling

Blog banner

Decision Tree: A Diagram Model

Blog banner

Cache memory

Blog banner

Fitness

Blog banner

Sagar Parikrama

Blog banner

Short-Form Video Marketing: Why It's Dominating the Internet

Blog banner

Mumbai local ......

Blog banner

Modern operating system

Blog banner

E-learning in today's world

Blog banner

Pipedrive

Blog banner

File management in os

Blog banner

Virtual Memory

Blog banner

Beauty of indian railway

Blog banner

Direct Memory Access

Blog banner

Social Media Sentiment Analysis

Blog banner

Internet of Things and cyber security

Blog banner

Explaining Buffer Overflow with Example

Blog banner

Operating Systems

Blog banner

Understanding the 4 Types of Learning Methods in Early Childhood

Blog banner

Improving defences Proxy Device(defense in depth)

Blog banner

The Sunny Side of Instagram

Blog banner

Child labour

Blog banner

Palm Vein Biometric Technology; Contactless vein authentication

Blog banner

Deadlock and Starvation in an Operating System

Blog banner

Tea, Coffee, Red Wine, and Teeth: A Stain Survival Guide

Blog banner