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

Bitcoin sent using radio waves! No internet!

Blog banner

The Future of Cybersecurity: Trends, Challenges, and Strategies

Blog banner

1.1 basic elements

Blog banner

What is thread and alse multithreading

Blog banner

Yoga in INDIA and ABROAD

Blog banner

SECURITY TOOLS

Blog banner

Smartphone Security: Vulnerabilities and Attacks

Blog banner

Race Conditions

Blog banner

Amazon

Blog banner

Why Time Management Is the Secret to College Success (and How to Master It)

Blog banner

Brilliant WhatsApp Features Upcoming in 2023

Blog banner

Memory management

Blog banner

RAID

Blog banner

The Impact of Cyber Forensics on Corporate Governance and Compliance

Blog banner

Artical on FreshBooks

Blog banner

Network Forensics Tools and Techniques

Blog banner

Modern operating system

Blog banner

Deadlock in operating system

Blog banner

Dos (Denial of service) Attack

Blog banner

HR Automation : Need of the hour

Blog banner

BENIFITS OF YOGA

Blog banner

Deadlock

Blog banner

Jio .....A Revolution ?? ??

Blog banner

Memory management

Blog banner

MODERN OPERATING SYSTEMS

Blog banner

Discover The Top 3 Places To Stay in London

Blog banner

FASHION

Blog banner

Mumbai

Blog banner

SAVE TREES

Blog banner

What is the point of living if we can die at any moment of our lives ?

Blog banner

Digital Balance: Keeping Children Mindful in the Screen Age

Blog banner

MailChimp

Blog banner

INTERNET SECURITY

Blog banner

Revolutionary AI Tool: ChatGPT

Blog banner

Why Friendship at Work is Important

Blog banner

OS Assignment-3

Blog banner

Natural Language Processing(NLP)

Blog banner

Cache memory

Blog banner

SQL Injection

Blog banner

Digital marketing spotlight “Dove’s Real Beauty Campaign”

Blog banner

Cache Memory

Blog banner

Types of Hackers.

Blog banner