KERNELFILE SYSTEMDRIVERKERNEL MODEKERNEL MODE1char buf[5];2n = read(fd, buf, 5);FILE SYSTEMCROSSINGS0DRIVERFILE SYSTEMDRIVERhello
Back: kernel mode (kernel core, and in a monolithic kernel the file system and driver)Front: user mode (your program, the counter, and in a microkernel the servers)Tokens: the read request, messages and the bytes crossing the gateBehind the wall marked kernel mode: the kernel, the file system, the disk driver and the disk. In front: the program, a crossings counter, and another program. Monolithic: read() crosses the gate once each way and the file system calls the driver inside the kernel, 2 crossings; a driver bug stops everything. Microkernel: the file system and the driver move out as servers, and the same read() becomes four messages through the kernel, 8 crossings; the same bug ends only the driver. The crossing counts are for this simple model: one read() and the user-mode/kernel-mode switches its messages need. They leave out the disk interrupt and how a user-mode driver reaches its device, which differs between systems.

Monolithic

  1. Programs lean on the kernel for many services: a file system, which turns file names into disk blocks, drivers, the code that talks to each device, plus scheduling and memory. The big design question is which of these run in kernel mode.

Microkernel

Choosing

What happens

;; step 1/11 · services
services the operating system provides:
  file system    file names -> blocks on the disk
  disk driver    code that knows how to work one device
  scheduling     which program runs next
  memory         who may use which memory

kernel mode   full control, no safety net
user mode     limited, must ask the kernel

design question: how much runs in kernel mode?

The crossing counts are for this simple model: one read() and the user-mode/kernel-mode switches its messages need. They leave out the disk interrupt and how a user-mode driver reaches its device, which differs between systems. Many systems sit in between. Linux is monolithic but loads drivers as modules at run time, straight into kernel space (init_module). Some microkernel systems run a few servers in kernel mode for speed.