wisemonkeys logo
FeedNotificationProfileManage Forms
FeedNotificationSearchSign in
wisemonkeys logo

Blogs

semaphores in os

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

Smartsheet

Blog banner

Image Steganography: Hiding Secrets in Plain Sight

Blog banner

Sleep Matters: The Science Behind Toddler Naps

Blog banner

Why Extreme Opinions Are Rising: Psychological Insights into Society’s Divides

Blog banner

Network Forensics

Blog banner

Daycare Centres Help Children Transition into Structured Learning

Blog banner

Types of Threads

Blog banner

Tiranga - Abbas Haveliwala

Blog banner

SECURITY VULNERABILITIES COUNTERMEASURES IN A SMART SHIP SYSTEM

Blog banner

Cache memory

Blog banner

Smart Eating Habits for Office Professionals to Stay Healthy

Blog banner

This Windows 11 encryption bug may cause data damage

Blog banner

File and File System Structure

Blog banner

Process State

Blog banner

Introduction to Solidity Programming for Blockchain Development

Blog banner

Deadlock in operating system

Blog banner

Cyber Forensics in Healthcare: Protecting Patient Data and Preventing Breaches

Blog banner

Child labour

Blog banner

Paralysis/Paralysis Stroke

Blog banner

Tableau

Blog banner

Subnet Masking

Blog banner

Process, process creation and process termination

Blog banner

Operating System

Blog banner

Incorporating Automation into Digital Forensics.

Blog banner

S-Tool : Steganography

Blog banner

Virtual Memory

Blog banner

Service transistion under difficult conditions

Blog banner

A BLOG ON MYSQL

Blog banner

Platonic Solids

Blog banner

SECURITY RISKS OF REMOTE WORKING

Blog banner

The Rich Heritage Of Patola Sarees: Gujarat’s Timeless Weaving Art

Blog banner

Which Smartphone Company Has the Largest Market Share in India?

Blog banner

The Importance of Data Quality Management in Data Science

Blog banner

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

Blog banner

Modern operating system

Blog banner

The Power of Forensic Watermarking in the Fight Against Content Piracy

Blog banner

The Future of Patola Weaving in a Sustainable Fashion World

Blog banner

5 Common Faults In Construction Tenders

Blog banner

IOT Hacking Techniques

Blog banner

Race condition

Blog banner

Deadlock

Blog banner

Os(Computer security threats)

Blog banner