Kernel Level Critical Sections
Typically, critical sections prevent process and thread migration between processors and the preemption of processes and threads by interrupts and other processes and threads.
Critical sections often allow nesting. Nesting allows multiple critical sections to be entered and exited at little cost.
If the scheduler interrupts the current process or thread in a critical section, the scheduler will either allow the currently executing process or thread to run to completion of the critical section, or it will schedule the process or thread for another complete quantum. The scheduler will not migrate the process or thread to another processor, and it will not schedule another process or thread to run while the current process or thread is in a critical section.
Similarly, if an interrupt occurs in a critical section, the interrupt's information is recorded for future processing, and execution is returned to the process or thread in the critical section. Once the critical section is exited, and in some cases the scheduled quantum completes, the pending interrupt will be executed. The concept of scheduling quantum applies to "Round Robin" and similar scheduling policies.
Since critical sections may execute only on the processor on which they are entered, synchronization is only required within the executing processor. This allows critical sections to be entered and exited at almost zero cost. No interprocessor synchronization is required, only instruction stream synchronization. Most processors provide the required amount of synchronization by the simple act of interrupting the current execution state. This allows critical sections in most cases to be nothing more than a per processor count of critical sections entered.
Performance enhancements include executing pending interrupts at the exit of all critical sections and allowing the scheduler to run at the exit of all critical sections. Furthermore, pending interrupts may be transferred to other processors for execution.
Critical sections should not be used as a long-lived locking primitive. They should be short enough that the critical section will be entered, executed, and exited without any interrupts occurring, neither from hardware much less the scheduler.
Kernel Level Critical Sections are the base of the software lockout issue.
Read more about this topic: Critical Section
Famous quotes containing the words kernel, level, critical and/or sections:
“All true histories contain instruction; though, in some, the treasure may be hard to find, and when found, so trivial in quantity that the dry, shrivelled kernel scarcely compensates for the trouble of cracking the nut.”
—Anne Brontë (18201849)
“The truth is, that common-sense, or thought as it first emerges above the level of the narrowly practical, is deeply imbued with that bad logical quality to which the epithet metaphysical is commonly applied; and nothing can clear it up but a severe course of logic.”
—Charles Sanders Peirce (18391914)
“His misfortune was that he loved youthhe was weak to it, it kindled him. If there was one eager eye, one doubting, critical mind, one lively curiosity in a whole lecture-room full of commonplace boys and girls, he was its servant. That ardour could command him. It hadnt worn out with years, this responsiveness, any more than the magnetic currents wear out; it had nothing to do with Time.”
—Willa Cather (18731947)
“I have a new method of poetry. All you got to do is look over your notebooks ... or lay down on a couch, and think of anything that comes into your head, especially the miseries.... Then arrange in lines of two, three or four words each, dont bother about sentences, in sections of two, three or four lines each.”
—Allen Ginsberg (b. 1926)