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

virtual memory

Blog banner

Why Should You Schedule Tweets on Twitter?

Blog banner

The Secure Software Development Life Cycle (SDLC)

Blog banner

India Digital Personal Data Protection Act, 2023

Blog banner

A-B-C of Networking: Part-2 (Components)

Blog banner

10 Reasons to Date a South Indian Girl

Blog banner

Direct Memory Access

Blog banner

LTE Technology

Blog banner

Data Mining

Blog banner

Beatbox

Blog banner

Understanding Regression Analysis

Blog banner

DBMS and various career options related to it.

Blog banner

VIRUS

Blog banner

The Role of Cyber Forensics in Criminology

Blog banner

Article on Fresh Book

Blog banner

Deadlock and starvation

Blog banner

Photorec - media recovery tool

Blog banner

Security in Operating Systems

Blog banner

Secure Hypertext transfer protocol

Blog banner

Google classroom

Blog banner

Top 3 Places To Stay In Vienna

Blog banner

Threads

Blog banner

I/O Management and Disk Scheduling

Blog banner

10 Reasons why Monica and Chandler are the best couple ever.!!!

Blog banner

This Windows 11 encryption bug may cause data damage

Blog banner

Deadlocks in operating system

Blog banner

INTERNET

Blog banner

Process in OS

Blog banner

Assignment-3

Blog banner

"Audit" In Data Science

Blog banner

MEMORY MANAGEMENT REQUIREMENT

Blog banner

Brilliant WhatsApp Features Upcoming in 2023

Blog banner

The House ??of Patola Designs: Traditional Weaves with a Modern Twist

Blog banner

Disk Management

Blog banner

Importance of education

Blog banner

OS- Assignnment 1

Blog banner

Introduction to Data Science: Life Cycle & Applications

Blog banner

PODIO

Blog banner

Meshoo

Blog banner

Direct Memory Access

Blog banner

Dal Bafla Recipe

Blog banner

An Overivew Of Cache Memory

Blog banner