wisemonkeys logo
FeedNotificationProfileManage Forms
FeedNotificationSearchSign in
wisemonkeys logo

Blogs

semaphores in os

profile
Dia Jha
Aug 15, 2024
0 Likes
0 Discussions
73 Reads

In Operating Systems: Semaphores


Semaphors are one of the most important concepts in OS,it is mainly used to synchronise and control access on any concurrent process or threads. They protect against race conditions and make sure that multi-process environment uses resources effectively, and safely.


 1. Definition and Types


 A semaphore is a synchronization tool,that uses an integer value for controlling access to any shared resource. The semaphore can work after adjustment of its value by two atomic operations


– Wait (P of Proberen): Decreases the semaphore value. Is the value goes below 0 then until it becomes positive again, that process will be on hold.


- Signal (V or Verhogen): This processes signals increase the value of semaphore. if value is less then calls up blocked process.


There are two kind of semaphores:-


Binary Semaphore (Mutex): This can only take two values 0 and 1. It is used to do compliant access on one resource.


- Counting Semaphore: can yield any integer value and they are used to control access of a finite number of instances for a resource.


 2. Usage


Some of the scenarios using semaphores are as follows:


Mutex: mutual exclusion, which allows only a single process or thread to enter the critical section of the code.


- Resource Sharing: It manages access to a pool of identical resources—such as database connections.


Process Synchronization- It controls running of the processes in a certain order, it allows only specific operations to conduct at some time.


3. Implementation and Challenges


This signal is generally created in the kernel of an operating system and makes use of specific functions. Semaphores come with a few challenges out of the box:


On the other hand, Deadlocks can occur if processes are waiting indefinitely for a semaphore.


-Priority Inversion: Prevent a high-priority process from moving forward by a low-priorit.


– Starvation: Some processes may never get access to a semaphore if continuous acquisition of it is being done by other processes.


 4. The Pro 's and Con's 


- Advantages:


Simple but efficient synchronization mechanism.


Allows control over the execution of processes and access to resources.


- Disadvantages:


 Disadvantages- Difficult to implement correctly (deadlocks, priority inversion).


Semaphores are difficult to be debugged


Summary


Semaphores are used to synchronize or coordinate execution of process among themselves and helps lot in maintaining access / modification order of shared resources. Appropriate use of semaphores Improves the performance and reliability in multi-process environment.


Comments ()


Sign in

Read Next

Landslide Hazard

Blog banner

VPN

Blog banner

Kernel in Operating System

Blog banner

IP Address

Blog banner

Bitcoin sent using radio waves! No internet!

Blog banner

The Power of Forensic Watermarking in the Fight Against Content Piracy

Blog banner

5 People who claimed to have Time Traveled

Blog banner

How covid-19 impacted Social media ad spend forecast globally

Blog banner

Functions of Operating System

Blog banner

Fun Christmas Activities For Toddlers & Kids

Blog banner

Smitten Kitchen Keepers

Blog banner

Deadlock

Blog banner

Financial Fraud Detection

Blog banner

What is OS Fingerprinting?

Blog banner

Teamwork

Blog banner

Deadlock in Operating System

Blog banner

Blog on Smartsheet.

Blog banner

indian premier league

Blog banner

Sniffing: A Cyber Security Threat

Blog banner

Security issues

Blog banner

Why Kanye West (Now Ye) is the GOAT: A Legacy Beyond Music

Blog banner

Operating system

Blog banner

SQL Injection

Blog banner

Is Pursuing a Dance Career in India Worth it?

Blog banner

Deadlock

Blog banner

Open Source Project By Google

Blog banner

Linux Virtual Machine Process Scheduling

Blog banner

Privacy in Social Media and Online Services

Blog banner

Tracking Emails & Email Crimes

Blog banner

Service Operations Principles

Blog banner

Everything You Need for a Perfect Stay in Arcadia, Florida, USA.

Blog banner

Data Storytelling: Turning Analysis into Business Action

Blog banner

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

Blog banner

Explain Kernel in OS

Blog banner

**THE MUJAWARR: Transforming the Logistics Industry**

Blog banner

Does School Infrastructure Really Matter For Learning?

Blog banner

MEMORY MANAGEMENT (techniques)

Blog banner

WHAT IS TWITTER AND HOW DOES IT WORK

Blog banner

Importance of education

Blog banner

Electronic data interchange

Blog banner

Full Disk Encryption on Digital Forensics

Blog banner

5 Powerful Mindset Shifts To Make 2026 Your Breakthrough Year

Blog banner