[cs33211] Re: Homework 2 question

Mikhail Nesterenko mikhail at cs.kent.edu
Sun Mar 15 15:31:20 EDT 2009


The code for the two process semaphore synchronization solution uses
binary semaphores. In your modification, you are free to use either
counting or binary semaphores. Make sure that you specify which ones
you are using.

Thanks,
--
Mikhail


> For number 2, are we dealing with counting semaphores? Or Binary Semaphores?
> I noticed that the code:
> Semaphore B1(0), B2(0)
> Process1(){
> signal(B1);
> wait(B2); //B2 is 0 here so when it waits() it is decremented to -1
> 
> process2(){
> signal(B2); //B2 is -1 so when it increments it's 0 which will infinite loop
> in wait()
> wait(B1);
> }
> 
> signal(s)(){S++}
> 
> wait(S){
> while(S<=0)
>    ;//nothing
> S--;
> }
> 
> 
> will give you a -1 for B2 and B2 will never go above negative 1, yet this is
> the example of the code we are given to modify? This doesn't seem like it'd
> work unless the semaphores are Binary. Any ideas?


More information about the cs33211 mailing list