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

Scheduling

Blog banner

Harsh Rathod

Blog banner

BUSINESS MODELS OF E COMMERCE

Blog banner

Evolution of Operating Systems

Blog banner

Linux 94

Blog banner

Career v/s Job : Choose your passion

Blog banner

Man is free by the birth .

Blog banner

ITIL Version 3 and 4 differenciation?

Blog banner

Types of email

Blog banner

The Power of Forensic Watermarking in the Fight Against Content Piracy

Blog banner

COMPUTER FORENSICS AND GRAPHICS

Blog banner

Virtual memory

Blog banner

Data Mining

Blog banner

Vikrant’s first blog

Blog banner

AI and Data Science: Revolutionizing Industries

Blog banner

The Impact of Cyber Forensics on Corporate Governance and Compliance

Blog banner

Indian Culture and Tradition

Blog banner

Deadlock in operating system

Blog banner

MOBILE DEVICE FORENSIC

Blog banner

21ST CENTURY PATRIARCHY

Blog banner

5 Common Faults In Construction Tenders

Blog banner

Semaphores

Blog banner

CYBER FORENCIS: PAST, PRESENT AND FUTURE.

Blog banner

Severe landslides continue to cause concern in Joshimath, Uttarakhand

Blog banner

Memory Management

Blog banner

Bharat Maps

Blog banner

Social Network Analysis: Ek Naya Nazariya Data Science Mein

Blog banner

Steganography and Steganalysis

Blog banner

What your Favorite colour says about You?

Blog banner

Threat from Inside: Educating the Employees Against Cyber Threats

Blog banner

Types of Malware in Cyber Security

Blog banner

Europe Through My Lens

Blog banner

Theads

Blog banner

Major achievement

Blog banner

Stories Woven in Silk: The Meaning Behind Patola Motifs

Blog banner

Memory input output management

Blog banner

Monday. com App

Blog banner

Multicore and multithreading 171

Blog banner

SECURITY VULNERABILITIES COUNTERMEASURES IN A SMART SHIP SYSTEM

Blog banner

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

Blog banner

Unlocking the Secrets: Basic Operations of Computer Forensic Laboratories

Blog banner

A True Friendship

Blog banner