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

File management

Blog banner

Crypto tax evasion

Blog banner

Direct Memory Access

Blog banner

Time Series Analysis

Blog banner

Concurrency and memory

Blog banner

Never give up

Blog banner

Go Daddy

Blog banner

Malware

Blog banner

Sweet and Sour Mango Pickle (Gol Keri)

Blog banner

SQL Injection

Blog banner

What do you mean by online marketing and why do you need to know about it

Blog banner

What is OS and its overview

Blog banner

Advanced Persistent Threats (APTs)

Blog banner

Business-to-Business

Blog banner

DEVELOPMENTS LEADING TO MODERN OPERATING SYSTEMS

Blog banner

Python as a tool for data analysis

Blog banner

"Audit" In Data Science

Blog banner

Instagram

Blog banner

Types of OS

Blog banner

Tracking Emails & Email Crimes

Blog banner

Deadlock

Blog banner

How to insert contacts in zoho crm using php

Blog banner

Exploring the Power of Encase Forensic Tools: Unraveling Digital Mysteries

Blog banner

A BLOG ON MYSQL

Blog banner

Booting Process In Operating System

Blog banner

10 Reasons Why Guy BestFriends are the Must in Every Girl's Life

Blog banner

What's Better : Supervised or Unsupervised Learning

Blog banner

Google classroom

Blog banner

Interrupts in OS

Blog banner

Modern operating system

Blog banner

The Art of Slow Fashion: Why Patola Defines Sustainable Luxury

Blog banner

To-Do List In LISP

Blog banner

Fault Tolerance

Blog banner

My favourite food

Blog banner

Layers Of Blockchain

Blog banner

It's all about our Brain.- The Brain Metaphor

Blog banner

Data Science in Healthcare: Predicting Diseases

Blog banner

Social Media Sentiment Analysis

Blog banner

Teamwork

Blog banner

Software Piracy & Online Data Protection in Digital World

Blog banner

Jira Software

Blog banner

Human factor, a critical weak point in the information security of an organization’s IOT

Blog banner