Problem

Consider the following definition of semaphores:void semWait(s){  if (s.count > 0) {   ...

Consider the following definition of semaphores:

void semWait(s)

{

  if (s.count > 0) {

   s.count- -;

 }

 else {

  place this process in s.queue;

  block;

 }

}

void semSignal (s)

{

  if (there is at least one process blocked on semaphore s) {

  remove a process P from s.queue;

  place process P on ready list;

 }

 else

  s.count++;

}

Compare this set of definitions with that of Figure 5.3. Note one difference: With the preceding definition, a semaphore can never take on a negative value. Is there any difference in the effect of the two sets of definitions when used in programs? That is, could you substitute one set for the other without altering the meaning of the program?

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 5