wisemonkeys logo
FeedNotificationProfileManage Forms
FeedNotificationSearchSign in
wisemonkeys logo

Blogs

semaphores in os

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

PHONE TECHNOLOGY

Blog banner

Cache Memory(142)

Blog banner

Concurrency:Deadlock and Starvation

Blog banner

What are Virtual Machines

Blog banner

PROCESS STATES OF OPERATING SYSTEM

Blog banner

The Essential Guide to Dynamic Arrays vs. Linked Lists: Which to Use and When ?

Blog banner

Session Hijacking

Blog banner

CSI and Organizational Change

Blog banner

Why Festivals Are the Best Classrooms for Young Minds?

Blog banner

Festive Ethnic Wear Guide: Patola-Inspired Looks for Every Celebration

Blog banner

Is it important to follow all the trends that come up on social media?

Blog banner

Raid

Blog banner

MAHAKAL LOK UJJAIN

Blog banner

Microsoft Windows Overview

Blog banner

Title: Network Sniffing Techniques: Uncovering the Secrets of Data Transfer

Blog banner

Virtual machine and virtualizing

Blog banner

BUFFER OVERFLOW_142

Blog banner

Fitness regime by Deepesh

Blog banner

Emotional Suppression: The Hidden Costs Of Unfelt Feelings

Blog banner

File and File System Structure

Blog banner

Cyber-crime Investigation and Future Directions

Blog banner

Privacy LAWs in IT

Blog banner

MEMORY HIERARCHY

Blog banner

Semaphores

Blog banner

The Role of cryptography in cyber security

Blog banner

Virtual memory in windows

Blog banner

Video games

Blog banner

ODOO

Blog banner

Why Data Privacy Is Changing Online Advertising

Blog banner

ACHIEVEMENTS IN OPERATING SYSTEMS

Blog banner

“Shot on iPhone” : A campaign by Apple that turned into a prodigy

Blog banner

How India made the GIS its Own, and its Use in Infrastructural Developments

Blog banner

undefined

Blog banner

"The Benefits of Using GIS in Agriculture"

Blog banner

WINDOWS I/ O

Blog banner

Safe Learning Spaces: Why Preschool Environment Matters More Than Ever Today

Blog banner

Memory Management

Blog banner

"Life as a Part-time Student"

Blog banner

The Features of Blockchain

Blog banner

Memory Management

Blog banner

Stories Woven in Silk: The Meaning Behind Patola Motifs

Blog banner

Ubiquitous Computing

Blog banner