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

Trello ( management software)

Blog banner

Dekkers Algorithm

Blog banner

RACI model in IT services

Blog banner

Google classroom

Blog banner

GIS Bharat Maps

Blog banner

Multiprocessor and scheduling

Blog banner

Fashion marketing in india

Blog banner

An Approach To Spyware Detection And Removal

Blog banner

The Power of Forensic Watermarking in the Fight Against Content Piracy

Blog banner

DIGITAL ECONOMY

Blog banner

VIRTUAL MEMORY

Blog banner

ART AND CULTURE OF VRINDAVAN

Blog banner

virtual machine

Blog banner

Multithreading in Operating System

Blog banner

Virtual Memory

Blog banner

Service Strategy In ITSM

Blog banner

How to use GIT & GITHUB

Blog banner

10 Types of Friends in every friend group

Blog banner

PHISHING

Blog banner

An Overview of Virtual Machines

Blog banner

Use case of K-means clustering

Blog banner

AI and Cyber Security

Blog banner

Microsoft Windows Overview

Blog banner

Defining youtubr

Blog banner

Depression

Blog banner

Virtual memory

Blog banner

Risk mitigation and management

Blog banner

Uniprocessor Scheduling

Blog banner

Platonic Solids

Blog banner

Benefits of Yoga

Blog banner

Cache memory

Blog banner

RAID

Blog banner

"Games and the future"

Blog banner

Monday. com App

Blog banner

Hello World

Blog banner

Steps to create an Ubuntu EC2 Instance with GUI in AWS

Blog banner

Threads Concurrency: Mutual Exclusion and Synchronization

Blog banner

ODOO

Blog banner

Travelling blog

Blog banner

Data Structures

Blog banner

Logical and physical address

Blog banner

MySQL

Blog banner