wisemonkeys logo
FeedNotificationProfileManage Forms
FeedNotificationSearchSign in
wisemonkeys logo

Blogs

semaphores in os

profile
Dia Jha
Aug 15, 2024
0 Likes
0 Discussions
75 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

Cyber Security in Data Breaching

Blog banner

What is Minting & Mining

Blog banner

Uniprocessor Scheduling

Blog banner

Web Site

Blog banner

Operating system evolution

Blog banner

File Sharing

Blog banner

Process, process creation and process termination

Blog banner

Digital Marketing - The new way to reach end consumer

Blog banner

Buffers in Operating Systems

Blog banner

The Role of Cyber Forensics in Criminology

Blog banner

Functions Of Operating Systems

Blog banner

Data Mapping

Blog banner

Modern Operating Systems.

Blog banner

Segmentation and paging concept

Blog banner

Title: Modern Operating Systems: Powering the Digital Era

Blog banner

Memory management

Blog banner

What is Brute Force Attack? How to defend against it?

Blog banner

Importance Of Blockchain

Blog banner

Every body is beautiful

Blog banner

Vikrant’s first blog

Blog banner

The Lunchbox That Came Back Untouched — How to Handle a Fussy Eater at Preschool Age

Blog banner

Salt, Sand, and Smiles: Does the Maroubra Lifestyle Affect Your Enamel?

Blog banner

Android Application Components and Activity Lifecycle

Blog banner

Palliative and End — of — Life Care: A Psychological and Holistic Perspective

Blog banner

Mendeley (management software)

Blog banner

RAID and It's Levels

Blog banner

Memory Management - operating system

Blog banner

Direct Memory Access

Blog banner

How to invest in Indian Stock Market ? ~ Tutorial 1

Blog banner

Incident management in ITSM

Blog banner

What Your Child Learns During Free Play (That You Might Not Notice)

Blog banner

Why Should You Schedule Tweets on Twitter?

Blog banner

UniProcessor Scheduling

Blog banner

Race condition

Blog banner

OS PROCESS DESCRIPTION AND CONTROL-SARVAGYA JALAN

Blog banner

Proof-of-Stake (PoS)

Blog banner

Threats To Computer System

Blog banner

Overcoming the bedtime brushing Battle with Dr. Roxanne Irani, Dentist in Maroubra

Blog banner

Loneliness

Blog banner

Multicore CPUs

Blog banner

All you need to know about Cassandra

Blog banner

How to Find the Right Therapist For Me?

Blog banner