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

INTERNET SECURITY

Blog banner

ART AND CULTURE OF VRINDAVAN

Blog banner

Challenges and risks in service operations

Blog banner

Data Mapping

Blog banner

Deadlock

Blog banner

BharatPe

Blog banner

virtual machine

Blog banner

Emailing the merger document

Blog banner

Understanding E-mail Servers

Blog banner

What is OS Fingerprinting?

Blog banner

DATA SCIENCE IN BUSINESS AND MARKETING

Blog banner

Memory Management

Blog banner

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

Blog banner

Software

Blog banner

IO Buffers

Blog banner

INDIAN CHEAPEST COSMETICS BRAND

Blog banner

Fitness

Blog banner

The Power of Forensic Watermarking in the Fight Against Content Piracy

Blog banner

BEAUTY IS IN THE EYE OF THE BEHOLDER

Blog banner

File Organization and Access

Blog banner

Threat from Inside: Educating the Employees Against Cyber Threats

Blog banner

DBMS and various career options related to it.

Blog banner

Fitness regime by Deepesh

Blog banner

Nature’s Brush on Silk: The Secret Behind Patola Colours

Blog banner

PROCESS CONTROL BLOCK IN OS

Blog banner

I/O Buffering

Blog banner

Some web vulnerabilities

Blog banner

Zomato's Secret Digital Marketing Techniques!

Blog banner

Getting into Anime

Blog banner

Types of Viruses

Blog banner

Honeypot in cyber security

Blog banner

What is Password Cracking ? and it's Techniques.

Blog banner

Kernel Modes: User Mode vs. Kernel Mode - 80

Blog banner

Stop Racism

Blog banner

How to Conquer Depression ?

Blog banner

Classification Algorithms (Decision trees, SVM, Logistic regreession)

Blog banner

Process and Threading

Blog banner

Why Should You Schedule Tweets on Twitter?

Blog banner

Smartsheet

Blog banner

New Ransomware Encrypts Your Android And Then Changes PIN Lock

Blog banner

Concurrency and Deadlocks

Blog banner

Virtual memory

Blog banner