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

Career v/s Job : Choose your passion

Blog banner

Four Stalls Every Vegetarian Needs To Eat At Outside Vile Parle Station

Blog banner

Google App Engine

Blog banner

Predicting Student Performance with Data Science

Blog banner

Self defence

Blog banner

Introduction to Virtual Memory - 080

Blog banner

How GIS in Agriculture Eliminates Guesswork

Blog banner

MEMORY MANAGEMENT (techniques)

Blog banner

Interesting fact about kangaroo.

Blog banner

Cyber Security in Data Breaching

Blog banner

GIS in Mapping and landslide alert in Bangladesh

Blog banner

A book review

Blog banner

Os assignment

Blog banner

India Digital Personal Data Protection Act, 2023

Blog banner

History of Money

Blog banner

Cloud Security: Trends and Innovations

Blog banner

Online Games

Blog banner

Linux Threads:

Blog banner

Bharat Maps

Blog banner

Cache memory

Blog banner

Cache memory

Blog banner

Solitary Play Activities for Preschoolers: Types and Benefits

Blog banner

Threats To Computer System

Blog banner

Logical and physical address

Blog banner

DURGA POOJA

Blog banner

What is Email? Uses of Emails

Blog banner

When Is the Right Time to Enrol My Toddler Into Preschool? NEP

Blog banner

Real time scheduling

Blog banner

10 Reasons to date your best friend

Blog banner

Cache memory

Blog banner

SECURITY TOOLS

Blog banner

Outlook.com

Blog banner

Study of Sniffing Tools

Blog banner

Creating Digitally Signed Document

Blog banner

What is Internet

Blog banner

38_Exploring The Honeynet Project

Blog banner

How to tie a Tie

Blog banner

What is Virtual Memory

Blog banner

Malware

Blog banner

Boxing

Blog banner

Introduction to GIS

Blog banner

What is OS Fingerprinting?

Blog banner