answersLogoWhite

0


Best Answer

In semaphores there is no spinning, hence no waste of resources due to no busy waiting. That is because threads intending to access the critical section are queued. And could access the priority section when the are de-queued, which is done by the semaphore implementation itself, hence, unnecessary CPU time is not spent on checking if a condition is satisfied to allow the thread to access the critical section.

Semaphores permit more than one thread to access the critical section, in contrast to alternative solution of synchronization like monitors, which follow the mutual exclusion principle strictly. Hence, semaphores allow flexible resource management.

Finally, semaphores are machine independent, as they are implemented in the machine independent code of the microkernel services.

Disadvantages

Problem 1: Programming using Semaphores makes life harder as utmost care must be taken to ensure Ps and Vs are inserted correspondingly and in the correct order so that mutual exclusion and deadlocks are prevented. In addition, it is difficult to produce a structured layout for a program as the Ps and Vs are scattered all over the place. So the modularity is lost. Semaphores are quite impractical when it comes to large scale use.

Problem 2: Semaphores involve a queue in its implementation. For a FIFO queue, there is a high probability for a priority inversion to take place wherein a high priority process which came a bit later might just have to wait when a low priority one is in the critical section. For example, consider a case when a new smoker joins and is desperate to smoke. What if the agent who handles the distribution of the ingredients follows a FIFO queue (wherein the desperate smoker is last according to FIFO) and chooses the ingredients apt for another smoker who would rather wait some more time for a next puff?

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What are disadvantages of semaphore?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What are the advantages and disadvantages of semaphore?

advantage small code ais busy waiting


Advantages and disadvantages of semaphore in os?

Advantage of semaphore is simplicity. Disadvantage of semaphore is more prone to programmer error. It does not guarantee that if programmer misplace the P and V then it will also work correctly. It may occur deadlock or violation of mutual exclusion due to programmer error.


How many semaphore flag methods are there?

there are 28 semaphore flag methods.


What is the initial value of semaphore?

The initial value of a semaphore is typically set by the programmer when the semaphore is initialized. This value determines the number of concurrent threads or processes that can access a shared resource protected by the semaphore at the same time.


When was Semaphore - album - created?

Semaphore - album - was created on 1998-03-16.


When did Semaphore railway line end?

Semaphore railway line ended in 1978.


When was Semaphore railway line created?

Semaphore railway line was created in 1882.


When was Smartlogic Semaphore Limited created?

Smartlogic Semaphore Limited was created in 2007.


How do you make semaphore in a sentence?

Since semaphore means some type of light then you could say, * Around the holidays many neighborhoods create a semaphore with their lights.


When was semaphore flags invented?

The original use of semaphore was invented around 1792 by Claude Chappe. The use of semaphore flags was brought about during the 1800's on ships at sea.


What is difference between counting and binary semaphore in os?

Binary semaphore is a semaphore with the integer value ranges over 0 and 1 whereas the counting semaphore's integer value ranges over unrestricted domain. Binary semaphores are easier to implement comparing with the counting semaphore. Binary semaphore allows only one thread to access the resource at a time. But counting semaphore allows N accesses at a time. The 2 operations that are defined for binary semaphores are take and release. The 2 operations that are defined for counting semaphores are wait and signal


How do you use semaphore in a sentence?

Multiple threads must not initialize the same semaphore simultaneously.Upper Quadrant Signal A semaphore signal in which the arm was raised to indicate ' off ' or ' clear ' .If you don't have any proper semaphore flags, then you could make some.This view of Canterbury East signal box from the 1970s reveals both semaphore signal arms still in use.We have as yet no Semaphores on our coasts.