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

Operating System Objectives and Functions

Blog banner

Virtual Machine

Blog banner

Street foods

Blog banner

INTERNET SECURITY

Blog banner

DURGA POOJA

Blog banner

First-Order Logic (FOL): The Foundation of Modern Logic

Blog banner

File Management system

Blog banner

Deadlock and Starvation

Blog banner

How to write a cover letter

Blog banner

38_Network Sniffing Techniques_SBC

Blog banner

Respondo Launches Revolutionary Video Discussion App

Blog banner

Working with Sniffers for monitoring network communication

Blog banner

OS Assignment 3

Blog banner

Corporate Discipline.

Blog banner

Cyber Forensics in Healthcare: Protecting Patient Data and Preventing Breaches

Blog banner

Teenagers of Today

Blog banner

Memory Management

Blog banner

virtual memory

Blog banner

Virtual memory in os

Blog banner

IT Service Continuity Management

Blog banner

Paging

Blog banner

What is Virtual Memory

Blog banner

Explain Multiprocessors

Blog banner

Traveling

Blog banner

Importance Of Yoga.

Blog banner

Guidelines for a Low sodium Diet.

Blog banner

Computer security techniques

Blog banner

Man VS Nature

Blog banner

Deadlock

Blog banner

Network Forensics Tools and Techniques

Blog banner

Exploring Arcadia’s Cowboy Culture, Peace River & Hidden Attractions

Blog banner

10 Reasons Why Guy BestFriends are the Must in Every Girl's Life

Blog banner

Why Users Leave Your Website in 5 Seconds (And How UI/UX Fixes It)

Blog banner

Memory Management in Operating System

Blog banner

THE LEGAL ISSUES OF COMPUTER FORENSICS IN INDIA

Blog banner

Policies for Service Transition

Blog banner

Dental Problems That Start Small But Should Never Be Ignored

Blog banner

Disk scheduling

Blog banner

Online Education

Blog banner

Uniprocessor Scheduling

Blog banner

Linux Virtual Machine Process Scheduling

Blog banner

Eating Well With Meal Maharaj on Busy Workdays Without Cooking

Blog banner