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

Unlocking the Secrets: Basic Operations of Computer Forensic Laboratories

Blog banner

How Does Preschool Help Children Become Better Decision Makers?

Blog banner

Article on IT development trends

Blog banner

Harsh Rathod

Blog banner

Digital Marketing Ethics Transparency Trust And Brand Reputation digital

Blog banner

CoWIN

Blog banner

Secure Hypertext transfer protocol

Blog banner

Types of Threads

Blog banner

The Art Of Getting What You Want In Life....

Blog banner

The Evolution of Operating Systems

Blog banner

MEMORY MANAGEMENT

Blog banner

Indian Food

Blog banner

Cache memory

Blog banner

LIFEHACKER

Blog banner

A-B-C of Networking: Part-1 (Basics)

Blog banner

Linux Virtual Machine Process Scheduling

Blog banner

Cyber Security Standards

Blog banner

Number Guessing game --lisp

Blog banner

MD5 Collisions and the impact on computer forensics

Blog banner

Continual service improvement vs maintenance phase in IT

Blog banner

Deadlock

Blog banner

Raid

Blog banner

Semaphores

Blog banner

Interesting fact about kangaroo.

Blog banner

Kernel Memory Allocation In Linux.

Blog banner

Article on Fresh Book

Blog banner

How International Schools Build Global-Minded Students through Curriculum & Activities

Blog banner

Meal Maharaj — 3 CP, 5 CP, 8 CP. Same Love, Different Portions

Blog banner

Im Photographer

Blog banner

Types of Malware in Cyber Security

Blog banner

Explain website hacking issues

Blog banner

The Chapped Lips and Dry Mouth Trap: The Sneaky Reason Cavities Spike in Winter

Blog banner

India Digital Personal Data Protection Act, 2023

Blog banner

Understanding Portion Control: How Much Food Do You Really Need?

Blog banner

Modern OS

Blog banner

WHAT IS TWITTER AND HOW DOES IT WORK

Blog banner

Instagram Features in 2023 That Will Leave You Stunned!

Blog banner

Security Issues

Blog banner

INDIAN CHEAPEST COSMETICS BRAND

Blog banner

Scheduling

Blog banner

Automating OSINT tasks for efficient Cyber Forensics Investigations

Blog banner

Delhi city

Blog banner