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

Esri India launches Policy Maps.

Blog banner

Environmental Management using GIS

Blog banner

Memory

Blog banner

Decoding Modern Assessment: Why We Look Beyond the Grade Sheet

Blog banner

Predicting Student Performance with Data Science

Blog banner

Uniprocessor scheduling

Blog banner

Virtual Machine

Blog banner

The Sunny Side of Instagram

Blog banner

File Allocation Methods

Blog banner

Question

Blog banner

Introduction to Data Science: Life Cycle & Applications

Blog banner

How return on investment is defined in IT services

Blog banner

Blockchain Transactions

Blog banner

Why Should You Schedule Tweets on Twitter?

Blog banner

GIS Mapping

Blog banner

A book review

Blog banner

HubSpot

Blog banner

Importance Of Time

Blog banner

Memory management

Blog banner

Who decides your overthinking, anyway?

Blog banner

Mental Health

Blog banner

File Systems in OS.

Blog banner

Why Skipping Afternoon Meals Affects More Than Just Your Hunger?

Blog banner

Why we fail after giving 100% ?

Blog banner

operating system

Blog banner

DEVELOPMENTS LEADING TO MODERN OPERATING SYSTEMS

Blog banner

Deadlock

Blog banner

Os(Computer security threats)

Blog banner

Cloud Technology and its Implications for Entrepreneurship

Blog banner

Biometric Authentication and Privacy: Balancing Ethical Concerns

Blog banner

10 Amazing facts about Tokyo Ghoul

Blog banner

Data Analytics in Data Science

Blog banner

ProofHub

Blog banner

Solitary Play Activities for Preschoolers: Types and Benefits

Blog banner

The Role of Cyber Forensics in Addressing Cyber security Challenges in Smart Cities

Blog banner

Survey of Which Movies Types people are Prefer to Watch in India.

Blog banner

Multiprocessor scheduling

Blog banner

Cloud Forensic Tools And Storage :A Review Paper

Blog banner

Multicore and multithreading 171

Blog banner

Virtual Machine

Blog banner

Security Issues and Countermeasures

Blog banner

Different Types of Data

Blog banner