Writing Device Drivers

Multiprocessing Changes Since the SunOS 4.1 System

Here is a simplified view of how the earlier releases of the SunOS kernel ran on multiprocessors. Only one processor could run kernel code at any one time, and this was enforced by using a master lock around the entire kernel. When a processor needed to execute kernel code, it acquired the master lock, blocking other processors from accessing kernel code. It released the lock on exiting the kernel.

Figure 4-2 SunOS 4.1 Kernels on a Multiprocessor


In Figure 4-2 CPU1 executes kernel code. All other processors are locked out of the kernel; the other processors could, however, run user code.

In the SunOS 5.7 system, instead of one master lock, there are many locks that protect smaller regions of code or data. In the example shown in Figure 4-3, there is a kernel lock that controls access to data structure A, and another that controls access to data structure B. Using these locks, only one processor at a time can be executing code dealing with data structure A, but another could be accessing data within structure B. This allows a greater degree of concurrency.

Figure 4-3 SunOS 5.7 on a Multiprocessor


In Figure 4-3, CPU1 and CPU3 are executing kernel code simultaneously.