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

Direct Memory Access

Blog banner

Top 10 Logos and their meanings

Blog banner

Traditional Unix System

Blog banner

Rain

Blog banner

6 Digital Marketing Trends You Must Watch Out For In 2022

Blog banner

Memory Management

Blog banner

Blog on health and fitness

Blog banner

INTRODUCTION

Blog banner

Photorec - media recovery tool

Blog banner

Cyber Forensic in the Banking sector

Blog banner

Answer

Blog banner

1.1 basic elements

Blog banner

Navigating the Digital Battlefield: Security Breaches and Effective Countermeasures

Blog banner

What do you mean by online marketing and why do you need to know about it

Blog banner

Memory Management - operating system

Blog banner

Android Flashlight Application

Blog banner

WAKE UP ITS FOOD o'CLOCK...!!!!!

Blog banner

MAILFENCE

Blog banner

Memory Management

Blog banner

Expert System In AI

Blog banner

Carrot Pickle With Raisins (lagan Nu Achar)

Blog banner

Different Types of Data

Blog banner

A-B-C of Networking: Part-3 (Topology [Ring, Tree, Mesh])

Blog banner

Traveling

Blog banner

Data Storytelling: Turning Analysis into Business Action

Blog banner

What is online marketing and why do you need to know about it ?

Blog banner

MEMORY MANAGEMENT

Blog banner

File management

Blog banner

"Can Lisp do Machine Learning?"

Blog banner

What is thread and alse multithreading

Blog banner

Computer Security

Blog banner

Indian Food

Blog banner

LINUX VSERVER VIRTUAL MACHINE ARCHITECTURE

Blog banner

Understanding Input Based Keylogger Activation Systems: Risks and Mitigation

Blog banner

An Overivew Of Cache Memory

Blog banner

This is my first blog.

Blog banner

A Heartfelt Act of Kindness

Blog banner

38_Exploring The Honeynet Project

Blog banner

MODERN OPERATING SYSTEM

Blog banner

Music

Blog banner

Data Mining

Blog banner

Explain website hacking issues

Blog banner