wisemonkeys logo
FeedNotificationProfileManage Forms
FeedNotificationSearchSign in
wisemonkeys logo

Blogs

semaphores in os

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

The Benefits of Mixed Learning Activities for Preschoolers

Blog banner

PERSONAL STORIES

Blog banner

Blog name

Blog banner

The Role of Cyber Forensics in Criminology

Blog banner

Software

Blog banner

COMMUNICATION

Blog banner

The Role of Summer Camps in Early Childhood Development

Blog banner

PPC Advertising and its Impressive Benefits

Blog banner

Method of Evaluating Information Security Level in an Organization

Blog banner

Impacts of Data Breach On Companies Challenges and Prevention

Blog banner

Memory management

Blog banner

Real-Time Operating Systems (RTOS) Deep Explanation

Blog banner

Threat management

Blog banner

Delhi city

Blog banner

POSITIVE ATTITUDE IN LIFE

Blog banner

Developments in Modern Operating Systems

Blog banner

Data Lake

Blog banner

Buffer overflow

Blog banner

Linux -V Server Virtual Machine

Blog banner

Blockchain Transactions

Blog banner

Google classroom

Blog banner

Digital black market or dark net poses a national security threat?

Blog banner

Fitness

Blog banner

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

Blog banner

Precision-Recall in Data Science

Blog banner

Importance of education

Blog banner

Modern operating system

Blog banner

An Overview of Virtual Machines

Blog banner

Computer Security

Blog banner

Operating System Objectives and Functions

Blog banner

Interrupts

Blog banner

Firewall in Computer Network

Blog banner

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

Blog banner

Data is an asset and it is your responsibility!

Blog banner

The Rise of Polo Tourism in the USA: How Travellers Are Blending Luxury Stays with Elite Sports

Blog banner

Memory Management of Operating System(OS)

Blog banner

BIRYANI ! The history you never knew about

Blog banner

Operating system

Blog banner

Fossil Hunting 101 at the Peace River, Arcadia, Florida, USA

Blog banner

virtual machine

Blog banner

MEMORY FORENSIC ACQUISITION AND ANALYSISOF MEMORY AND ITS TOOLS COMPARISON

Blog banner

Teenagers of Today

Blog banner