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

Virtualization

Blog banner

Mango Raisin Chutney (sweet mango raisin spread)

Blog banner

Can ChatGPT Answer All My Questions About Life?

Blog banner

Stop Racism

Blog banner

From Freezer to Fryer in Minutes: Quick & Easy Evening Snacks for Unexpected Guests

Blog banner

Pilgrimage at LOC: A privilege and a paradox

Blog banner

Rain

Blog banner

Fossil Hunting 101 at the Peace River, Arcadia, Florida, USA

Blog banner

Memory Management

Blog banner

Traditional Unix System

Blog banner

Latest Email Marketing Techniques

Blog banner

Why Mumbai Professionals Are Switching Back to Home-Style Tiffin Meals

Blog banner

Unlocking the Secrets: Basic Operations of Computer Forensic Laboratories

Blog banner

Why Travellers from Miami & Orlando Are Visiting Arcadia for Weekend Getaways?

Blog banner

All you need to know about “On-page SEO”

Blog banner

IoT Evolution

Blog banner

MEMORY FORENSIC ACQUISITION AND ANALYSISOF MEMORY AND ITS TOOLS COMPARISON

Blog banner

Service Operations in ITSM

Blog banner

Why Should You Schedule Tweets on Twitter?

Blog banner

Evolution of Operating Sytems

Blog banner

BENIFITS OF YOGA

Blog banner

Deadlock and Starvation

Blog banner

Deadlock in operating system

Blog banner

BLOCKCHAIN MACHANISM

Blog banner

How User Data Shapes Personalised Campaigns

Blog banner

What is Vishing?

Blog banner

Bulk E-mail software

Blog banner

Different memory allocation strategies

Blog banner

Wiretapping

Blog banner

Types of Big Data

Blog banner

Data carving - using hex editor

Blog banner

EID UL FITR

Blog banner

How Puppet Shows and Role Play Teach Empathy to Preschoolers

Blog banner

The khan mehtab transforming the modular switches company

Blog banner

To travel is to live

Blog banner

Blockchain uses and use cases

Blog banner

PHISHING

Blog banner

Man VS Nature

Blog banner

Scheduling in Operating Systems

Blog banner

Secure Hypertext transfer protocol

Blog banner

All you need to know about Cassandra

Blog banner

PROCESS CONTROL BLOCK IN OS

Blog banner