Question

In: Computer Science

What is semaphore? List the properties of semaphore variables. Define the wait function wait(s).

What is semaphore? List the properties of semaphore variables. Define the wait function wait(s).

Solutions

Expert Solution

Semaphore :

  1. Semaphore is a variable which contains an integer value that is used to solve the critical section problem
  2. It is a synchronization tool which is used to achieve process synchronization in the multiprocessing environment.
  3. It contains two variables P and V.

Properties of semaphore variables

  1. V called as signal operation always increments the semaphore value and it is always successful on semaphore
  2. P called as wait operation always decrements the semaphore value and it is successful until it becomes 0.
  3. The variable will always hold a nonnegative integer value.
  4. The two most common kinds of semaphores are counting semaphores and binary semaphores.
  5. Counting semaphore can take non-negative integer values and Binary semaphore can take the value 0 & 1. only
  6. They can be implemented using test operations and interrupts. They can also be executed using file descriptors

Wait operation(P) :

  1. wait operation is denoted by variable P.
  2. wait operaiton decrements the semaphore value
  3. It is defined as follows.

wait(S)

{

while(S<=0)

S -- ;

}

Signal operation(V) :

  1. It is denoted using variable V
  2. It increments the semaphore value.
  3. It is defined as follows

signal(S)

{

  while (S>=0);

S++ ;

}


Related Solutions

What is the main difference between semaphore and a CV? A semaphore and a lock?
What is the main difference between semaphore and a CV? A semaphore and a lock?
List the properties of antibodies that determine their effector function. What is the advantage to switching...
List the properties of antibodies that determine their effector function. What is the advantage to switching to an IgG isotope?
List the properties of antibodies that determine their effector function. What is the advantage to switching...
List the properties of antibodies that determine their effector function. What is the advantage to switching to an IgG isotope? I know that igG deals with neonatal immunity by placental transfer but im not sure if thats the advantage/only advantage
List four variables that help to define a menu. What role does a menu play in...
List four variables that help to define a menu. What role does a menu play in relation to a business’s brand? List the two primary tools that help to define a market. What type of information does each one provides? If a chef wants to create a menu that exceeds his staff’s ability, why can’t he just hire new staff? How does a kitchen’s space and work flow impact a menu? Who are the typical stakeholders who contribute to the...
list and define function of the five phyletic characteristics of the Chordata. Then define larval and...
list and define function of the five phyletic characteristics of the Chordata. Then define larval and adult form in regard to the presence of four of the phyletic characteristics in larva vs adult form of the Ascidacea. Define neoteny and the evolutionary origin of the Vertebrata.
Which ones in the following list are properties of a normal density function ? Group of...
Which ones in the following list are properties of a normal density function ? Group of answer choices
Indicate the vibrational partition function of a diatomic molecule. Define the variables uses.
Indicate the vibrational partition function of a diatomic molecule. Define the variables uses.
What are the properties that define a sound wave? Name at least three properties and provide...
What are the properties that define a sound wave? Name at least three properties and provide their definitions. Two of the properties you define may describe may describe the same aspect of the wave, but in different forms.
What are the properties that define a sound wave? Name at least three properties and provide...
What are the properties that define a sound wave? Name at least three properties and provide their definitions. Two of the properties you define may describe the same aspect of the wave, but in different forms.
The design should consist of two things: (1) a list of every semaphore, its purpose, and...
The design should consist of two things: (1) a list of every semaphore, its purpose, and its initial value, and (2) pseudocode for each function. The pseudocode should be similar to the pseudocode shown in the textbook for the barbershop problem. Every wait and signal call must be included in the pseudocode.     Must use Java Threads and Java Semaphores (java.util.concurrent.Semaphore). You may not use the “synchronized” keyword in Java for mutual exclusion. You may not use Java data structures...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT