wisemonkeys logo
FeedNotificationProfileManage Forms
FeedNotificationSearchSign in
wisemonkeys logo

Blogs

semaphores

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

MySQL

Blog banner

Deadlock in Operating systems

Blog banner

Getting into Anime

Blog banner

How Cyber Forensics use in AI

Blog banner

Memory management

Blog banner

Deadlock and Starvation

Blog banner

Memory Management

Blog banner

MODERN OPERATING SYSTEM

Blog banner

File Organization and Access

Blog banner

Emerging threats in cyber Forensics

Blog banner

Starvation

Blog banner

OS Assignment 3

Blog banner

Exploring Florida Beyond the Obvious Tourist Trails

Blog banner

note taker app

Blog banner

Hash password! Is it really secured?

Blog banner

The Golden Temple , Amritsar

Blog banner

Service Transition Process in ITSM

Blog banner

Shoulders

Blog banner

Social engineering in cyber security

Blog banner

VIRTUAL MACHINES

Blog banner

Cache Memory(142)

Blog banner

Deadlock Prevention

Blog banner

Service design process in ITSM

Blog banner

Why Progressive Web Apps (PWAs) Are Replacing Traditional Websites

Blog banner

From Airboat Tours to Fossil Hunting: The Ultimate Arcadia Travel Experience

Blog banner

Cache memory

Blog banner

Phishing

Blog banner

What is Internet

Blog banner

Mumbai Metro 3

Blog banner

Phishing Isn't Getting Smarter — You're Just Seeing More of It

Blog banner

Honeypot in cyber security

Blog banner

Digital Marketing

Blog banner

Why Data Privacy Is Changing Online Advertising

Blog banner

(Input/Output) in os

Blog banner

How HRMS, Task Management, and Team Chats Can Improve Workplace Productivity

Blog banner

Metasploit

Blog banner

Functions Of Operating Systems

Blog banner

Security in Cloud Computing Environment using cryptography - Rushabh Modi

Blog banner

The Best Photography Spots in and Around Arcadia, Florida

Blog banner

EVOLUTION OF THE MIRCOPROCESSOR

Blog banner

Scheduling

Blog banner

My Favorite Country

Blog banner