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

What is M-commerce and how it's work

Blog banner

Data Visualization in Decision-Making

Blog banner

Operating Systems

Blog banner

TRELLO

Blog banner

The Joy of Giving: How Festivals Teach Children Empathy and Gratitude

Blog banner

Vikrant’s first blog

Blog banner

Memory Management

Blog banner

Virtual Machine

Blog banner

Buffer Overflow

Blog banner

What are Tenders its various types

Blog banner

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

Blog banner

Mumbaicha Dabbawalla

Blog banner

Email Privacy

Blog banner

Mango Raisin Chutney (sweet mango raisin spread)

Blog banner

From Procrastinator to Performer: How to Beat the Last-Minute Rush

Blog banner

DEVELOPMENTS LEADING TO MODERN OPERATING SYSTEMS

Blog banner

Security requirements for Safe E-Payments

Blog banner

Evolution of the Microprocessor ~ Aditya Pai

Blog banner

Virtual Memory

Blog banner

Functions Of Operating Systems

Blog banner

Virtual Machine

Blog banner

SAVE TREES

Blog banner

Malicious softwares

Blog banner

Is Your Password Complex Enough?

Blog banner

Deadlock and Starvation

Blog banner

Elegant fashion style

Blog banner

Smitten Kitchen Keepers

Blog banner

Balance

Blog banner

The War With Cold On Earth

Blog banner

AutoML: The Future of Automated Data Science

Blog banner

Jira service Management

Blog banner

Esri India launches Policy Maps.

Blog banner

Culture Of Ladakh

Blog banner

Domain Name System

Blog banner

RAID - LEVELS OF RAID

Blog banner

Partnership in Learning: How Parent Involvement Shapes a Child’s Early Education

Blog banner

Instagram Features in 2023 That Will Leave You Stunned!

Blog banner

Music

Blog banner

The IT Service Lifecycle

Blog banner

The Lunchbox That Came Back Untouched — How to Handle a Fussy Eater at Preschool Age

Blog banner

SQL Injection Techniques

Blog banner

Therapy Myths That Need to End in 2025

Blog banner