Critical Sections
- Critical sections are blocks of code that should not be interrupted.
- They are protected by turning interrupts on and off. Big hammer because
they disable all interrupts on the system.
- Quicker then semaphores.
- Okay to use for quick things such as setting globals, updating small
sections.
- Use just around the important parts in a function.
Requirements for critical sections
- Mutual exclusion - safe from interruption.
- Progress - no blocking.
- Bound waiting - quick.
Functions
- OS_ENTER_CRITICAL() - called right before critical code.
- OS_EXIT_CRITICAL() - called rigth after critical code.