if (balance - withdrawl >= 0) balance = balance - withdrawl; else error("Can't withdraw that much!");
if (balance - withdrawl >= 0) balance = balance - withdrawl;
for (ever) { loop while (turn != 0); /* Wait */ /* != 1, != 2, != 3 etc */ criticalsection(); turn= 1; /* =2, =3, =0 etc */ other stuff; }
enterregion: tsl register, flag /* Copy the flag to the register, and set flag to 1 */ cmp register, 0 /* Was flag zero? */ bnz enterregion /* No, loop until it is */ leaveregion: mov flag, 0; /* Set the flag to zero */ ret /* and return */
entersection(); /* Critical section stuff */ leaveregion();
acquire(sem) { if (sem.count == 0) block process; sem.count=0; /* When reawakened, lower count back to 0 */ } release(sem) { sem.count=1; /* Raise semaphore's value to 1 */ if (any process blocked waiting for sem) unblock one; }
acquire(sem); /* Critical section stuff */ release(sem);
loop forever { get web page request from client check page exists and client has permissions transmit web page back to the client }
loop forever { get web page request from client check page exists and client has permissions make a clone of the server original server goes back to `get web page' clone server transmits web page back to the client }