/* ****************BLOCK.C******** Jonathan W. Valvano Feb 26, 1997 Blocking semaphores ***needs to be modified to make it blocking**** */ void Wait(sema4Ptr semaphore){ asm(" sei"); /* Test and set is atomic */ PORTC|=0x10; while((semaphore->value)<=0){ /* disabled */ asm(" cli\n" /* disabled */ " nop\n" /* enabled */ " sei");} /* enabled */ (semaphore->value)--; /* disabled */ PORTC&=0xEF; asm(" cli"); /* disabled */ } /* enabled */ void Signal(sema4Ptr semaphore){ asm(" sei"); /* increment is atomic */ PORTC|=0x20; (semaphore->value)++; PORTC&=0xDF; asm(" cli"); }