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

My Favorite Sportsperson

Blog banner

differentiate thinking humanly and rationally

Blog banner

Facebook marketing

Blog banner

Policies for Service Transition

Blog banner

RAID_142

Blog banner

Exploring the Power of Encase Forensic Tools: Unraveling Digital Mysteries

Blog banner

Password Generator - Lisp

Blog banner

DBMS and various career options related to it.

Blog banner

Hacking of web server and application

Blog banner

Concurrency:Deadlock and Starvation

Blog banner

Deadlock and Starvation

Blog banner

Predicting Student Performance with Data Science

Blog banner

Deadlock and Starvation in an Operating System

Blog banner

Paddle Through Paradise: The Best Kayak Launch Points Near Arcadia

Blog banner

File Management In OS

Blog banner

Impact of social media on the human life

Blog banner

10 Alien Encounters and Abduction Stories

Blog banner

Starvation

Blog banner

Why Friendship at Work is Important

Blog banner

The Dark Web: A Breeding Ground for Cybercriminals – How to Guard Against Threats

Blog banner

Topic: Sessions in Operating system

Blog banner

VIRTUAL MACHINE

Blog banner

LIMITED EDITION

Blog banner

Operating system

Blog banner

HR Automation : Need of the hour

Blog banner

All you need to know about Cassandra

Blog banner

Starvation

Blog banner

How To Invest In Indian Stock Market @ BSE & NSE ~ Tutorial 3

Blog banner

Evolution of the Microprocessor ~ Aditya Pai

Blog banner

Music

Blog banner

Strengthening Active Directory Security

Blog banner

How to Run your First android App

Blog banner

Jamming Attacks in Network Security: Disrupting Communication Signals

Blog banner

Principles of Concurrency

Blog banner

AI and Cyber Security

Blog banner

MOVEMBER

Blog banner

Can a Water Flosser Replace Manual Flossing? Here’s What Dentists Say

Blog banner

Article on Fresh Book

Blog banner

Os(Computer security threats)

Blog banner

Hey Aryan here

Blog banner

Stay Close To Adventure In Arcadia, Florida At Oak Tree Hotel

Blog banner

What's Better : Supervised or Unsupervised Learning

Blog banner