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

Deadlock and starvation in operating system

Blog banner

Different types of e-commerce platforms or advantages and disadvantages

Blog banner

Deadlock and Starvation

Blog banner

Memory heirchy

Blog banner

5 Stages of Digital Marketing

Blog banner

"Mahakali cave"

Blog banner

Solving Problems with AI: The Power of Search Algorithms

Blog banner

Threads

Blog banner

HubSpot

Blog banner

How to Prepare Your Child for Their First Day of School?

Blog banner

**THE MUJAWARR: Transforming the Logistics Industry**

Blog banner

Exploring Virtual Machines and Computer Forensic Validation Tools

Blog banner

26/11 The Black Day Of Mumbai

Blog banner

Modern Operating System

Blog banner

How covid-19 impacted Social media ad spend forecast globally

Blog banner

Chicken Dum Biryani

Blog banner

VIRTUAL MACHINES

Blog banner

Fitness

Blog banner

File system implementation

Blog banner

Tiranga - Abbas Haveliwala

Blog banner

The Joy of Giving: How Festivals Teach Children Empathy and Gratitude

Blog banner

New Horizon Europe project ‘EvoLand’ sets off to develop new prototype services.

Blog banner

Multicore and Multithreading

Blog banner

History of ITIL

Blog banner

Data Visualization – Importance and tools (Tableau, Power BI)

Blog banner

Types of Hackers

Blog banner

Operating System

Blog banner

IOT Hacking Techniques

Blog banner

Internet of Things

Blog banner

Different types of scam Fraud

Blog banner

The functions of operating system

Blog banner

Processes : Process description and control

Blog banner

MYNTRA

Blog banner

Deadlock in Operating systems

Blog banner

Domain Name System

Blog banner

HUBSPOT

Blog banner

COMFORT IS ALL ABOUT FASHION

Blog banner

Career v/s Job : Choose your passion

Blog banner

Penetration Testing

Blog banner

What is OS and its overview

Blog banner

You'll get to know about Pankaj Negi

Blog banner

Image Steganography: Hiding Secrets in Plain Sight

Blog banner