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

Electronic data interchange

Blog banner

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

Blog banner

The role of artificial intelligence in automating digital forensic analysis.

Blog banner

IT RISK

Blog banner

Service Strategy principles

Blog banner

Data Lake

Blog banner

Getting into anime My anime suggestions

Blog banner

Technological Advancement

Blog banner

STARVATION

Blog banner

The War With Cold On Earth

Blog banner

ahh wait a min

Blog banner

MailChimp

Blog banner

Data Science in Predictive Analytics: Transforming Business Decision-Making

Blog banner

Blockchain Security Technique

Blog banner

Direct Memory Access

Blog banner

Threads

Blog banner

Benefits and drawback of web security.

Blog banner

File management In Operating System

Blog banner

Memory Management

Blog banner

Buffering

Blog banner

Life of an army person

Blog banner

Service Strategy In ITSM

Blog banner

SECURITY VULNERABILITIES COUNTERMEASURES IN A SMART SHIP SYSTEM

Blog banner

Paginng In OS

Blog banner

Deadlock and Starvation

Blog banner

CYBER FORENCIS: PAST, PRESENT AND FUTURE.

Blog banner

Cache memory

Blog banner

Threads

Blog banner

Hosting basics

Blog banner

What is Virtual Memory

Blog banner

Smart Shoephone: Is that technology overdose!?

Blog banner

A buffer overflow

Blog banner

I/O Buffering

Blog banner

10 Types of Friends in every friend group

Blog banner

SPAM

Blog banner

Old age lifestyle

Blog banner

Google

Blog banner

Defining youtubr

Blog banner

GIS in Disaster Management

Blog banner

Synchronization

Blog banner

Virtual memory in windows

Blog banner

Spyware

Blog banner