wisemonkeys logo
FeedNotificationProfileManage Forms
FeedNotificationSearchSign in
wisemonkeys logo

Blogs

semaphores

profile
Khyati Sanghavi
Aug 14, 2024
0 Likes
0 Discussions
50 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

GIS Mapping

Blog banner

Major achievement

Blog banner

Impact of social media on the human life

Blog banner

Deadlock and Starvation

Blog banner

Save Girl Child

Blog banner

10 Reasons to date your best friend

Blog banner

Starvation and Deadlock.

Blog banner

Sniffing: A Cyber Security Threat

Blog banner

Malware Detection Techniques for Mobile Devices

Blog banner

What is a geographic information system (GIS)?

Blog banner

SQL Injection

Blog banner

Virtual memory in os

Blog banner

Microsoft Word

Blog banner

Platonic Solids

Blog banner

Game via listing method

Blog banner

Multiprocessor and Multicore Organization

Blog banner

Modern Operating System

Blog banner

Smartsheet

Blog banner

Data Acquisition in Cyber Forensics

Blog banner

Race Conditions

Blog banner

MODERN OPERATING SYSTEM

Blog banner

Simple Ways of Avoiding Basic Mistakes in Smart Phone Security

Blog banner

Service design process in ITSM

Blog banner

Security Issues

Blog banner

E-learning

Blog banner

Data Lakes: A Key to Modern Data Management

Blog banner

IOT Hacking Techniques

Blog banner

clock

Blog banner

memory management

Blog banner

Concurrency management in operating systems

Blog banner

Evolution of Operating System

Blog banner

E-Cash (Electronic Cash)

Blog banner

Study of Sniffing Tools

Blog banner

Decoding the Weave — How to Identify Original Patola Art on a Fabric

Blog banner

Steps to create an Ubuntu EC2 Instance with GUI in AWS

Blog banner

Traveling

Blog banner

How to kiss

Blog banner

Theads

Blog banner

Anomaly Detection in Behavioral Data Using Machine Learning

Blog banner

Different types of scam frauds

Blog banner

Deadlock

Blog banner

Riddhi Miyani 53003220140

Blog banner