To get a better grasp of how kernel's code is executed, we will look at the kernel as a waiter who must satisfy two types of requests: those issued by customers and those issued by a limited number of different bosses. The policy adopted by the waiter is the following:
If a boss calls while the waiter is idle, the waiter starts servicing the boss.
If a boss calls while the waiter is servicing a customer, the waiter stops servicing the customer and starts servicing the boss.
If a boss calls while the waiter is servicing another boss, the waiter stops servicing the first boss and starts servicing the second one. When he finishes servicing the new boss, he resumes servicing the former one.
One of the bosses may induce the waiter to leave the customer being currently serviced. After servicing the last request of the bosses, the waiter may decide to drop temporarily his customer and to pick up a new one.
The services performed by the waiter correspond to the code executed when the CPU is in Kernel Mode. If the CPU is executing in User Mode, the waiter is considered idle.
Boss requests correspond to interrupts, while customer requests
correspond to system calls or exceptions raised by User Mode processes.
As we shall see in detail in Chapter
10, User Mode processes that want to request a service from the
kernel must issue an appropriate instruction (on the 80×86, an
$0x80 or a
sysenter instruction). Such instructions raise an exception that forces the ...