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

Shoulders

Blog banner

Virtual memory in Operating System

Blog banner

?Why Does My Breath Still Smell After Brushing?

Blog banner

Street foods

Blog banner

Dental Problems That Start Small But Should Never Be Ignored

Blog banner

MENDELEY

Blog banner

Importance of Network Security Risk

Blog banner

Operation system

Blog banner

RAID

Blog banner

MUTUAL EXCLUSION

Blog banner

How the mobile IP is used in GSM architecture.

Blog banner

Cross site scripting Attack

Blog banner

Boxing

Blog banner

How to Conquer Depression ?

Blog banner

Have You Explored India Yet?

Blog banner

Operating system

Blog banner

What is OS Fingerprinting?

Blog banner

GIS Mapping

Blog banner

Blockchain technology: security risk and prevention

Blog banner

Linux Virtual Machine Process Scheduling

Blog banner

security controls

Blog banner

Importance Of Time

Blog banner

Understanding E-mail Servers

Blog banner

Modern operating system

Blog banner

Does School Infrastructure Really Matter For Learning?

Blog banner

Modern operating systems (OS)

Blog banner

"Geographic Information Systems (GIS) and its Applications in Urban Planning"

Blog banner

Memory Management

Blog banner

Deadlock and Starvation

Blog banner

File management

Blog banner

MEMORY HIERARCHY

Blog banner

Security issues

Blog banner

ADD A SPICE TO YOUR LIFE.

Blog banner

Evolution of Operating System

Blog banner

TAILS OS

Blog banner

Deadlock in operating system

Blog banner

Rules and Regulations of Networking: "Standards and Protocols" - Part 1

Blog banner

Memory Management

Blog banner

Product Discount Calculator

Blog banner

Types of Threads

Blog banner

LEMON PICKLE (NIMBU KA ACHAR)

Blog banner

Search Marketing In 2026: From Keywords To Credibility And User Intent

Blog banner