wisemonkeys logo
FeedNotificationProfileManage Forms
FeedNotificationSearchSign in
wisemonkeys logo

Blogs

semaphores

profile
Khyati Sanghavi
Aug 14, 2024
0 Likes
0 Discussions
52 Reads

Khyati sanghavi ,53003230018

Semaphores

A semaphore is an integer variable used for signalling among processes. It has three atomic operations:

  1. Initialisation: The semaphore is initialised with a non-negative integer value, which represents the number of available slots or resources.
  2. Decrement (semWait): When a process wants to access a shared resource, it decrements the semaphore value. If the resulting value is non-negative, the process can proceed. If the value becomes negative, the process is blocked and added to a waiting queue.
  3. Increment (semSignal): When a process releases a shared resource, it increments the semaphore value. If there are processes waiting in the queue, one of them is awakened and allowed to proceed.

How Semaphores Work

The value of a semaphore determines how many processes can proceed without blocking. When a process decrements the semaphore and the value becomes negative, it means that there are no more available slots or resources. The process is then blocked, waiting for another process to release a resource and increment the semaphore.

When a process increments the semaphore, it signals that a resource has been released. If there are processes waiting in the queue, one of them is awakened and allowed to proceed. This process can then decrement the semaphore and access the shared resource.

Advantages of Semaphores

  • Supports coordination between multiple processes
  • Provides a flexible and robust way to manage shared resources.
  • It can be used to implement critical sections in a program.
  • It can be used to avoid race conditions.

Disadvantages of Semaphores

  • It Can lead to performance degradation due to overhead associated with wait and signal operations.
  • Can result in deadlock if used incorrectly.
  • It can cause performance issues in a program if not used properly.
  • It can be difficult to debug and maintain.
  • It can be vulnerable to certain types of attacks, such as denial of service attacks.

Comments ()


Sign in

Read Next

Apple

Blog banner

Getting started with Android Studio

Blog banner

Importance of self defence for girls

Blog banner

Service Transition Process in ITSM

Blog banner

Virtual Memory

Blog banner

Dekkers Algorithm : Ensuring Safe Process Synchronization

Blog banner

Perfect Moments to Wear a Rich Patola Design Outfit

Blog banner

DURGA POOJA

Blog banner

Deadlock

Blog banner

FIREWALL

Blog banner

Go Daddy

Blog banner

THE ROLE OF CYBER FORENSICS IN CRIMINOLOGY

Blog banner

The Truth Behind Viral DIY Dental Hacks

Blog banner

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

Blog banner

File management

Blog banner

What Is Experiential Learning and Why Does It Work Better Than Rote Learning?

Blog banner

Modern Operating System

Blog banner

Virtualisation

Blog banner

INSTAGRAM

Blog banner

Having passion in life

Blog banner

File Allocation Methods

Blog banner

Hubspot

Blog banner

Concurrency and memory

Blog banner

Real-Time Operating Systems (RTOS) Deep Explanation

Blog banner

The evolution of OS

Blog banner

Mesh Topology

Blog banner

File management

Blog banner

Microsoft Windows Overview

Blog banner

Steganography

Blog banner

Virtual Machine

Blog banner

The Right way of cooking

Blog banner

Deadlock and Starvation

Blog banner

Threats To Computer System

Blog banner

Malicious softwares

Blog banner

MailChimp

Blog banner

Computer security techniques

Blog banner

Deadlock

Blog banner

GIS Applications: How Different Industries are Leveraging Geospatial Data

Blog banner

Revolutionary AI Tool: ChatGPT

Blog banner

DMZ: Your Secret Weapon for Data Security

Blog banner

What is Virtual Memory

Blog banner

DBMS and various career options related to it.

Blog banner