int x; void AccessXThread() { int oldIPL; oldIPL = setIPL(IHLevel); x = x + 1; setIPL(oldIPL); } void AccessXInterrupt() { ... x = x + 1; ... }
For preemptive kernel, synchronization is more complicated.