Search⌘ K

Controlling Interrupts

Explore the concept of controlling interrupts as an early method to ensure mutual exclusion within critical sections in single-processor operating systems. Understand its simplicity and the significant drawbacks such as privileged operation risks, inability to support multiprocessor systems, potential loss of interrupts, and inefficiency. This lesson helps you grasp when and why interrupt disabling can be used effectively and its limitations in modern concurrency control.

One of the earliest solutions used to provide mutual exclusion was to disable interrupts for critical sections; this solution was invented for single-processor systems. The code would look like this:

C
void lock() {
DisableInterrupts();
}
void unlock() {
EnableInterrupts();
}

Assume you are running on such a single-processor system. By turning off interrupts (using some kind of special hardware instruction) before entering a critical section, you ensure that the code inside the critical section will not be interrupted, and thus will execute as if it were atomic. When you are finished, you re-enable interrupts (again, via a hardware instruction​), and thus the program proceeds as usual.

Positives of interrupts

...