序一
Foreword
The Windows Operating System has been evolving,along with the PC-based computer.Although systems based on UNIX have dominated in the universities since the 1970s, Windows has completely surpassed UNIX in commercial systems.Yet relatively little information about the internals of Windows-the architecture and code of the kernel-has been available outside of Microsoft.
With the support of Microsoft’s executive management (particularly Rob Short, Jim Allchin, and Bill Gates), my colleagues Arkady Retik, Chris Fagan, and I set out to make the sources for the Windows kernel available to faculty, researchers, and students throughout the world. We wanted them to have the opportunity to examine the internals of the kernel and understand its implementation and thus be able to decide for themselves what is admirable about the Windows kernel - and what is not.
This project became the Windows Research Kernel (WRK), and is part of the Windows Academic Program (WAP www.microsoft.com/WindowsAcademic). The WAP also includes a large amount of teaching materials in the Curriculum Resource Kit (CRK). Effectively the WRK is the Windows kernel in source form, and the CRK is the Windows kernel in PowerPoint (with exercises, experiments, projects, and other learning aids).
All along we knew that the WRK and CRK by themselves would not make the Windows kernel as accessible as we wanted it to be. It would take books like Understanding the Windows Kernel to draw together and organize the ideas in the kernel and explain the source code.
Our intention with the Windows Academic Program has never been to advocate that Windows supplant UNIX in the teaching of operating systems in universities. We believe that both the UNIX and the Windows kernel should be taught, so that it is possible to compare and contrast the architecture and design choices that are evident in both systems.
As you will see from this book, Windows has made some very different choices than UNIX. In large part this is because Windows was developed to target a very different system and user environment than UNIX did when it was created. Windows would run on multiprocessors, so threads are the unit of scheduling rather than processes. The systems would have at least 32 bits of pageable virtual address space, so the Windows kernel had the opportunity to build general purpose mechanisms such as the object manager and stackable I/O. Windows expected to run in a very dynamic environment, so the object name space resides outside the file system and is maintained by the kernel itself. Although not a microkernel, Windows did incorporate the Mach idea of multiple operating system personalities in user-mode “subsystem”processes, initially supporting OS/2, POSIX, and Win32 interfaces.
The internal architecture of the kernel reflects learning from UNIX, Mach and VMS, Digital’s VAX operating system that was also designed by Dave Cutler, the senior architect of the Windows OS. There is a layer within the kernel which abstracts and schedules the CPUs (as threads, interrupts, traps, etc). This “kernel of the kernel” layer is about 5% of the code. The rest of the kernel is in the “executive” layer (including the device drivers, file systems, and network code which run outside of the kernel proper). The executive is implemented as fairly ordinary multithreaded code, which greatly simplifies the expertise required by kernel-mode developers.
For those who learned operating systems by reading and understanding only the ideas in UNIX, learning about Windows creates a great opportunity to evaluate their own assumptions about what an operating system should be. This is important because the nature of computer systems continues to rapidly evolve. UNIX was designed for 16-bit, low-memory, swapping systems. Windows for 32-bit systems with paged virtual addressing and megabytes of physical memory. But contemporary systems are 64-bit with gigabytes of memory, and many new features like virtualization hardware, solid-state disks, and integrated computational and graphics accelerators. Connectivity has evolved from the dial-up modems at UNIX’s birth in 1969 to the 10 Mbps local Ethernet at Windows birth in 1989. And now we have multiple Gbps networks interconnecting computers around the world. Will a new operating system emerge which targets these new hardware environments? Or will existing systems just continue to evolve their capabilities? It is only by having a broader understanding than either just UNIX or just Windows that software engineers will be able to judge for themselves.
Our colleague, Aimin Pan, is one of the bright stars in the new generation of computer scientists teaching and researching some of these important questions about the future of operating systems. His presentation of the Windows kernel will be a great asset for those who want to also participate in the evolving future of operating systems, as well as those who are just simply curious, or want to better understand the software architecture that they are using daily.
Dave Probert, Ph.D.
compsci@microsoft.com
Windows Kernel Architect – Microsoft
Developer of the Windows Research Kernel release
14 February 2010