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

Segmentation and paging concept

Blog banner

Multiple processor scheduling

Blog banner

Philadelphia Experiment : Was it real?

Blog banner

Wiretapping

Blog banner

Memory Management

Blog banner

BIRYANI ! The history you never knew about

Blog banner

MODERN OPERATING SYSTEM

Blog banner

GIS Mapping

Blog banner

Survey of Which Movies Types people are Prefer to Watch in India.

Blog banner

IP ADDRESS

Blog banner

Kafka - A Framework

Blog banner

What your Favorite colour says about You?

Blog banner

Cloud Security: Trends and Innovations

Blog banner

Social Media.

Blog banner

DURGA POOJA

Blog banner

Paid Email

Blog banner

The khan mehtab transforming the modular switches company

Blog banner

Basic Security For SOAP Services

Blog banner

Deadlock and Starvation

Blog banner

Business Intelligence v/s Big Data

Blog banner

Question

Blog banner

You Get Everyone, But No One Gets You: The Lonely Side of High Emotional Intelligence

Blog banner

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

Blog banner

" THE ANSWERS THAT LED INDIAN BEAUTIES TO THE MISS UNIVERSE HISTORIC WIN. "

Blog banner

Getting into Anime

Blog banner

Embracing the power of Modern Machine UNIX

Blog banner

american greatines

Blog banner

Cyber Crime Investigation In The Era Of Big Data

Blog banner

Os assignment

Blog banner

Objectives and functions of Operating System...

Blog banner

Veg/Non-veg/Egg Tiffin Meals That Are Nutritious and Filling

Blog banner

PERSONAL STORIES

Blog banner

Hubspot

Blog banner

Buffer Overflow

Blog banner

Bit Coins

Blog banner

TRIGGERS IN DATABASE

Blog banner

Corporate Discipline.

Blog banner

IT RISK

Blog banner

Expressing and Measuring Risk (Risk Management)

Blog banner

How To Invest in Indian Stock Market For Beginners. ~ Tutorial 2 (NSDL And CSDL) Continued...

Blog banner

Number Guessing game --lisp

Blog banner

The Impact of Tolerances and Wall Thickness on Pipeline Integrity

Blog banner