shared variables initializations: westblocked = 0 westcount = 0 eastblocked = 0 eastcount = 0 semaphores: semaphore wp(1) : for protection of the west monkey shared stuff semaphore ep(1) : for protection of the east monkey shared stuff semaphore west(0) : blocks west monkeys semaphore east(0) : blocks east monkeys WEST: if (eastcount>0){ wp.wait(); westblocked++; wp.signal(); west.wait(); } wp.wait(); westcount++; wp.signal(); //CROSSING CODE wp.wait(); westcount--; wp.signal(); if(westcount==0){ for(int x = 0; x0){ ep.wait(); eastblocked++; ep.signal(); east.wait(); } ep.wait(); eastcount++; ep.signal(); //CROSS CODE ep.wait(); eastcount--; ep.signal(); if(eastcount==0){ for(int x = 0; x