Windows内核原理与实现(潘老师限量签售本)(第一本用真实的源代码剖析Windows操作系统核心原理的原创著作)(china-pub首发)
基本信息
编辑推荐
微软亚洲研究院资深研究员潘爱民老师十年磨一剑之作
用真实的源代码剖析Windows操作系统核心原理
Windows内核专家Dave Probert作序力荐
推荐阅读
内容简介回到顶部↑
书籍
计算机书籍
本书从操作系统原理的角度,详细解析了windows如何实现现代操作系统的各个关键部件,包括进程、线程、物理内存和虚拟内存的管理,windows中的同步和并发性支持,以及windows的i/o模型。在介绍这些关键部件时,本书直接以windows的源代码(wrk, windows research kernel)为参照,因而读者可以了解像windows这样的复杂操作系统是如何在x86处理器上运行的。
在内容选取方面,本书侧重于windows内核中最基本的系统部件,同时也兼顾到作为一个操作系统的完整性,所以,本书也介绍了像存储体系、网络、windows环境子系统等,这些虽然并不位于内核模块但却支撑整个windows运行的重要部件。在本书最后,也介绍了windows server 2003以后的内核发展和变化。
虽然书中有大量关于windows代码实现的描述,但是本书并没有罗列wrk中的代码,即使读者不对照wrk的源代码,也可以从这些章节的描述中理解windows的实现机理。在每一个技术专题的介绍中,本书几乎都提供了一个框架图,并且有关键细节的实现分析,这样做的意图是让读者既能够对一项技术有总体上的把握,也通晓关键的实现细节。
windows操作系统已经有20年历史了,市面上有大量关于windows技术的文档和书籍,但是,真正从源代码来诠释windows底层机理的,本书还是第一次尝试。在本书覆盖的内容中,有相当一部分是第一次以文字形式披露出来的,期望这些内容能消除人们对于windows的神秘感。
写作本书的目的是让对windows有好奇心的人真正了解到windows中的核心机理,让计算机专业的学生和老师,以及系统软件工程师可以快速地领略到windows中先进的系统技术,以及在windows上编写出更加高效的软件。本书也配备了一些小工具,通过这些小工具,读者可以查看内核中的静态或动态的信息,甚至观察系统的行为,可通过internet下载这些工具。
计算机书籍
本书从操作系统原理的角度,详细解析了windows如何实现现代操作系统的各个关键部件,包括进程、线程、物理内存和虚拟内存的管理,windows中的同步和并发性支持,以及windows的i/o模型。在介绍这些关键部件时,本书直接以windows的源代码(wrk, windows research kernel)为参照,因而读者可以了解像windows这样的复杂操作系统是如何在x86处理器上运行的。
在内容选取方面,本书侧重于windows内核中最基本的系统部件,同时也兼顾到作为一个操作系统的完整性,所以,本书也介绍了像存储体系、网络、windows环境子系统等,这些虽然并不位于内核模块但却支撑整个windows运行的重要部件。在本书最后,也介绍了windows server 2003以后的内核发展和变化。
虽然书中有大量关于windows代码实现的描述,但是本书并没有罗列wrk中的代码,即使读者不对照wrk的源代码,也可以从这些章节的描述中理解windows的实现机理。在每一个技术专题的介绍中,本书几乎都提供了一个框架图,并且有关键细节的实现分析,这样做的意图是让读者既能够对一项技术有总体上的把握,也通晓关键的实现细节。
windows操作系统已经有20年历史了,市面上有大量关于windows技术的文档和书籍,但是,真正从源代码来诠释windows底层机理的,本书还是第一次尝试。在本书覆盖的内容中,有相当一部分是第一次以文字形式披露出来的,期望这些内容能消除人们对于windows的神秘感。
写作本书的目的是让对windows有好奇心的人真正了解到windows中的核心机理,让计算机专业的学生和老师,以及系统软件工程师可以快速地领略到windows中先进的系统技术,以及在windows上编写出更加高效的软件。本书也配备了一些小工具,通过这些小工具,读者可以查看内核中的静态或动态的信息,甚至观察系统的行为,可通过internet下载这些工具。
作译者回到顶部↑
本书提供作译者介绍
潘爱民,微软亚洲研究院,研究员。从1994年开始在北京大学计算机研究所从事计算机应用方向的研究和开发工作,2000年破格晋升为副研究员。2002年担任北京大学计算机研究所信息安全研究室主任。2004年加入微软亚洲研究院,从事操作系统与网络安全方向的研究工作。
潘爱民长期从事软件技术的研究和开发工作,撰写了大量软件技术文章,并著译了多部经典计算机图书,包括《COM原理与应用》(1999年出版)、《Visual C++技术内幕》(第4、6版)、《C++ Primer中文版》(第3版)、《计算机网络》(第4版)以及《深入解析W.. << 查看详细
潘爱民长期从事软件技术的研究和开发工作,撰写了大量软件技术文章,并著译了多部经典计算机图书,包括《COM原理与应用》(1999年出版)、《Visual C++技术内幕》(第4、6版)、《C++ Primer中文版》(第3版)、《计算机网络》(第4版)以及《深入解析W.. << 查看详细
目录回到顶部↑
第1章 概述 1
1.1 操作系统基础 2
1.1.1 计算机系统的硬件资源管理 2
1.1.2 为应用程序提供执行环境 5
1.2 学习操作系统之必备知识 7
1.3 windows操作系统发展历史 9
1.4 windows内核的版本 11
1.5 操作系统的研究与发展 13
1.6 本章总结 16
第2章 windows系统总述 17
2.1 现代操作系统的基本结构 17
2.2 windows系统结构 18
2.2.1 windows内核结构 20
2.2.2 windows内核中的关键组件 22
2.2.3 windows子系统 29
2.2.4 系统线程和系统进程 32
2.3 关于windows研究内核 34
2.3.1 wrk包含了什么 35
2.3.2 wrk源代码说明 36
2.3.3 本书对wrk源代码的引用 38
1.1 操作系统基础 2
1.1.1 计算机系统的硬件资源管理 2
1.1.2 为应用程序提供执行环境 5
1.2 学习操作系统之必备知识 7
1.3 windows操作系统发展历史 9
1.4 windows内核的版本 11
1.5 操作系统的研究与发展 13
1.6 本章总结 16
第2章 windows系统总述 17
2.1 现代操作系统的基本结构 17
2.2 windows系统结构 18
2.2.1 windows内核结构 20
2.2.2 windows内核中的关键组件 22
2.2.3 windows子系统 29
2.2.4 系统线程和系统进程 32
2.3 关于windows研究内核 34
2.3.1 wrk包含了什么 35
2.3.2 wrk源代码说明 36
2.3.3 本书对wrk源代码的引用 38
前言回到顶部↑
《Windows内核原理与实现》是一本讲述Windows内核机理,并配合Windows的源代码来解释其实现细节的学习用书。全书从操作系统原理的角度来组织内容。本书适合于已经有了操作系统基本概念的读者进一步理解Windows操作系统。通过学习本书的内容,读者不仅可以掌握Windows的核心机制,也可以理解像Windows这样的现代操作系统是如何构建起来的。因此,这是一本学习Windows操作系统内核的书,而不是一本指导在Windows平台上进行软件开发的用书。
对于绝大多数IT从业人员以及高校学生来说,Windows是一个熟悉得不能再熟悉的操作系统了,而且也有相当多人能够熟练地开发各种类型的Windows应用程序,然而,真正熟悉Windows内部机理的人却少而又少。究其根源,很多人将这归咎于Windows是一个闭源操作系统,也就是说,除了Microsoft内部的员工以外,人们接触不到Windows的源代码。这样的解释只能说是部分正确的,因为从历史发展来看,UNIX类操作系统确实有广泛的群众基础,很多人得益于阅读各种UNIX版本的源代码(包括Linux和FreeBSD)。但对于Windows操作系统,这似乎并非一个合理的解释,因为事实上,有相当多人在过去三四年间已经获得了Windows的源代码,但是在代码阐释和核心深入理解方面却并未表现出拥有源代码而带来的优势。反倒是在过去几年间基于逆向工程而获得的Windows核心知识要深刻得多。
这么说并非指Windows源代码没有帮助,而是间接地揭示了一个事实:Windows的源代码不是那么容易读的,Windows的核心也不是那么好理解的。本书作者在过去几年间,与国内高校的操作系统课程的老师和学生有广泛的接触和了解,真切地理解到,要想在操作系统课程中完全融入Windows的内容,迫切需要一本按照操作系统基本概念和理论来阐释Windows实现机理的书籍。基于这样的动机,本书力图让学习操作系统的读者能够理解Windows中的核心机制,而且还可以近距离地观察到Windows内核中的实现细节。
本书针对的读者
对Windows内核有好奇心的读者,无论您是操作系统课程的学生,或是正在从事系统软件开发的软件工程师,或是有技术背景的Windows系统管理员,都可以从本书中找到很多问题的答案。虽然本书中描述的大多数细节是以WRK(Windows Research Kernel)的代码为基础,但是,对于各种核心机制的介绍却是通用的,并不限于WRK内核,甚至适用于各种版本的Windows,包括最新的Windows Vista和Windows 7。
对于有资格获得WRK的读者(包括高校老师和学生),本书可以是配套的学习参考用书。本书正文部分列出了WRK中一些关键的数据结构定义,而在介绍各种核心机制时,明确地指出了源代码中的函数调用关系、关键数据的含义和用途,甚至在有些地方指明了WRK中对应的代码片断。因此,配合WRK代码来阅读本书是最理想的阅读方式,就如同本书作者在写作过程中经常查看WRK代码一样。
然而,对于因某些原因而无法获得WRK的读者,本书仍然有指导意义。首先,本书在讲解Windows内核的核心机制时,几乎都以文字或图形的方式描述了这些机制的总体结构,并指出了关键的数据结构或函数。即使没有WRK代码的参照,读者也可以想象出这些函数的功能实现。如果读者善用windbg,并设置Microsoft提供的公共符号服务(参考本书附录A),则可以在内核调试环境中查看到很多实现细节。书中描述的绝大多数核心机制不仅适用于Windows Server 2003 SP1(即WRK内核适用的系统),也适用于其他的Windows版本,包括Windows XP、Windows Vista、Windows Server 2008和Windows 7。
本书不是一本轻松的入门书籍,无论读者是否拥有WRK,最好在阅读以前先有操作系统的基本知识,以及较为熟练的编程能力,起码能够轻松地阅读C代码。硬件系统结构、汇编语言和编译原理等知识虽然不是必要的,但是有了这些知识,可以让您更加深入地理解各种系统机制。
本书内容组织
本书的内容并没有覆盖Windows内核的方方面面,而是从现代操作系统的概念模型出发,重点讨论了进程、线程和内存管理的基本概念以及在Windows中的实现细节,也讨论了Windows中的并发性和同步处理机制。作为一个对各种硬件设备有广泛兼容性的桌面操作系统,Windows的I/O模型是提供这种兼容能力的基础,因此,Windows中的I/O处理也是本书重点讨论的内容之一。在此基础上,本书还讲述了Windows的存储体系结构,它把Windows系统中众多的内核组件,包括缓存管理器、文件系统、磁盘管理驱动程序等,纳入到一个统一的框架中。
这些内容构成了本书的主体。然而,仅仅这些还不足以形成一个完整的操作系统,Windows内核中还有其他一些不可或缺的机制,比如内核中的对象管理、配置管理(即注册表服务)、系统事件追踪、安全性管理、系统服务管理、LPC(Local Procedure Call,本地过程调用),以及网络和Windows子系统等,本书也给出了足够详尽的描述,以使读者能够透彻地理解Windows操作系统的全貌。另外,Windows内核的初始化过程也是本书的覆盖范围。
在描述以上这些内核机制时,本书以WRK为主要的参照系统。WRK支持AMD64和Intel x86两种体系结构,本书选择Intel x86作为目标平台,而完全忽略在其他体系结构上的差异。Windows XP (x64)和Windows Server 2003 SP1 (x86)分别代表了客户端操作系统和服务器端操作系统,它们使用了同样的内核,所以,本书讨论的内容以Windows Server 2003 SP1为基准系统,但同样适用于客户端操作系统。
本书讨论的范围显然超越了WRK中源代码的范围,对于在WRK中未提供源代码的话题,比如即插即用管理器、Windows子系统和网络等,本书参考了Microsoft提供的各种文档,以及通过其他途径提供的源代码,例如Windows DDK文档和例子驱动程序。此外,Mark Russinovich和David Solomon合著的《Windows Internals》(第4、5版,中文版书名为《深入解析Windows操作系统》)也是重要的参考材料。本书在讲解各个话题时注明了所引用材料的出处,对于Microsoft提供的参考材料,包括Windows DDK文档,本书在文献引用条目中注明了这些内容在MSDN网站上的超链接。
本书内容简介
本书共包括9章正文内容和两个附录。内容介绍如下:
第1章介绍了操作系统的基础概念、Windows操作系统的发展历史、Windows内核的发展,以及学习操作系统的一些前提知识,最后还介绍了操作系统的研究进展。
第2章从总体上介绍了Windows操作系统。首先讨论现代操作系统的基本模型,以及一些重要部件的职责;然后讨论Windows的总体结构,以及有关WRK和相应源代码的一些说明。为了让读者对Windows内核有一个初步的认识,这一章还介绍了内核中的一些基本概念,包括进程、线程、内存管理、中断、异常、同步等,然后细致地讨论了Windows内核中的公共管理设施,包括对象管理器、配置管理器、事件追踪(ETW)和安全性管理。之所以在这一章中介绍这些公共设施,是为了让读者在学习本书后面章节中的核心概念和机制时,可以方便地直接引用这些管理设施中的功能。这一章的最后还介绍了Windows引导过程,包括内核初始化和用户会话建立过程。
第3章讨论了Windows中的进程和线程管理。首先讨论了进程和线程的基本概念,然后描述了Windows中有关进程和线程的重要数据结构,列出了这些数据结构的定义并解释了其中域的含义。接下来介绍了Windows进程中的句柄表结构、进程和线程的创建过程和结束处理,以及系统的初始进程和线程。这一章后面还介绍了Windows中的线程调度,包括时限管理、环境切换、线程状态转移等内容。
第4章介绍了Windows中的内存管理。首先介绍了一般性的内存管理知识,包括页式内存管理和段式内存管理。然后介绍了Windows的系统内存管理,涉及系统地址空间初始化、换页内存池和非换页内存池的管理算法,以及系统PTE区域的管理算法。紧接着介绍了进程虚拟地址空间的内存管理,包括地址空间的创建和初始化、虚拟内存的管理数据结构,以及虚拟内存中的内存区对象(section object)。然后讨论了Windows的页面交换机制和物理内存的管理,最后讨论了Windows的工作集(working set)管理。
第5章讨论了Windows中的并发和同步机制。这一章首先介绍了有关进程和线程同步的基础知识,然后介绍了Windows中的中断和异常处理机制,包括IRQL(中断请求级别)和中断对象、DPC(延迟过程调用)和定时器管理、APC(异步过程调用),以及异常分发过程。接下来分别介绍了两种类型的同步机制:高IRQL时的同步处理,以及基于线程调度的同步机制。Windows支持大量的同步语义,而且很多同步语义被导出成系统服务,可供应用程序使用。
对于绝大多数IT从业人员以及高校学生来说,Windows是一个熟悉得不能再熟悉的操作系统了,而且也有相当多人能够熟练地开发各种类型的Windows应用程序,然而,真正熟悉Windows内部机理的人却少而又少。究其根源,很多人将这归咎于Windows是一个闭源操作系统,也就是说,除了Microsoft内部的员工以外,人们接触不到Windows的源代码。这样的解释只能说是部分正确的,因为从历史发展来看,UNIX类操作系统确实有广泛的群众基础,很多人得益于阅读各种UNIX版本的源代码(包括Linux和FreeBSD)。但对于Windows操作系统,这似乎并非一个合理的解释,因为事实上,有相当多人在过去三四年间已经获得了Windows的源代码,但是在代码阐释和核心深入理解方面却并未表现出拥有源代码而带来的优势。反倒是在过去几年间基于逆向工程而获得的Windows核心知识要深刻得多。
这么说并非指Windows源代码没有帮助,而是间接地揭示了一个事实:Windows的源代码不是那么容易读的,Windows的核心也不是那么好理解的。本书作者在过去几年间,与国内高校的操作系统课程的老师和学生有广泛的接触和了解,真切地理解到,要想在操作系统课程中完全融入Windows的内容,迫切需要一本按照操作系统基本概念和理论来阐释Windows实现机理的书籍。基于这样的动机,本书力图让学习操作系统的读者能够理解Windows中的核心机制,而且还可以近距离地观察到Windows内核中的实现细节。
本书针对的读者
对Windows内核有好奇心的读者,无论您是操作系统课程的学生,或是正在从事系统软件开发的软件工程师,或是有技术背景的Windows系统管理员,都可以从本书中找到很多问题的答案。虽然本书中描述的大多数细节是以WRK(Windows Research Kernel)的代码为基础,但是,对于各种核心机制的介绍却是通用的,并不限于WRK内核,甚至适用于各种版本的Windows,包括最新的Windows Vista和Windows 7。
对于有资格获得WRK的读者(包括高校老师和学生),本书可以是配套的学习参考用书。本书正文部分列出了WRK中一些关键的数据结构定义,而在介绍各种核心机制时,明确地指出了源代码中的函数调用关系、关键数据的含义和用途,甚至在有些地方指明了WRK中对应的代码片断。因此,配合WRK代码来阅读本书是最理想的阅读方式,就如同本书作者在写作过程中经常查看WRK代码一样。
然而,对于因某些原因而无法获得WRK的读者,本书仍然有指导意义。首先,本书在讲解Windows内核的核心机制时,几乎都以文字或图形的方式描述了这些机制的总体结构,并指出了关键的数据结构或函数。即使没有WRK代码的参照,读者也可以想象出这些函数的功能实现。如果读者善用windbg,并设置Microsoft提供的公共符号服务(参考本书附录A),则可以在内核调试环境中查看到很多实现细节。书中描述的绝大多数核心机制不仅适用于Windows Server 2003 SP1(即WRK内核适用的系统),也适用于其他的Windows版本,包括Windows XP、Windows Vista、Windows Server 2008和Windows 7。
本书不是一本轻松的入门书籍,无论读者是否拥有WRK,最好在阅读以前先有操作系统的基本知识,以及较为熟练的编程能力,起码能够轻松地阅读C代码。硬件系统结构、汇编语言和编译原理等知识虽然不是必要的,但是有了这些知识,可以让您更加深入地理解各种系统机制。
本书内容组织
本书的内容并没有覆盖Windows内核的方方面面,而是从现代操作系统的概念模型出发,重点讨论了进程、线程和内存管理的基本概念以及在Windows中的实现细节,也讨论了Windows中的并发性和同步处理机制。作为一个对各种硬件设备有广泛兼容性的桌面操作系统,Windows的I/O模型是提供这种兼容能力的基础,因此,Windows中的I/O处理也是本书重点讨论的内容之一。在此基础上,本书还讲述了Windows的存储体系结构,它把Windows系统中众多的内核组件,包括缓存管理器、文件系统、磁盘管理驱动程序等,纳入到一个统一的框架中。
这些内容构成了本书的主体。然而,仅仅这些还不足以形成一个完整的操作系统,Windows内核中还有其他一些不可或缺的机制,比如内核中的对象管理、配置管理(即注册表服务)、系统事件追踪、安全性管理、系统服务管理、LPC(Local Procedure Call,本地过程调用),以及网络和Windows子系统等,本书也给出了足够详尽的描述,以使读者能够透彻地理解Windows操作系统的全貌。另外,Windows内核的初始化过程也是本书的覆盖范围。
在描述以上这些内核机制时,本书以WRK为主要的参照系统。WRK支持AMD64和Intel x86两种体系结构,本书选择Intel x86作为目标平台,而完全忽略在其他体系结构上的差异。Windows XP (x64)和Windows Server 2003 SP1 (x86)分别代表了客户端操作系统和服务器端操作系统,它们使用了同样的内核,所以,本书讨论的内容以Windows Server 2003 SP1为基准系统,但同样适用于客户端操作系统。
本书讨论的范围显然超越了WRK中源代码的范围,对于在WRK中未提供源代码的话题,比如即插即用管理器、Windows子系统和网络等,本书参考了Microsoft提供的各种文档,以及通过其他途径提供的源代码,例如Windows DDK文档和例子驱动程序。此外,Mark Russinovich和David Solomon合著的《Windows Internals》(第4、5版,中文版书名为《深入解析Windows操作系统》)也是重要的参考材料。本书在讲解各个话题时注明了所引用材料的出处,对于Microsoft提供的参考材料,包括Windows DDK文档,本书在文献引用条目中注明了这些内容在MSDN网站上的超链接。
本书内容简介
本书共包括9章正文内容和两个附录。内容介绍如下:
第1章介绍了操作系统的基础概念、Windows操作系统的发展历史、Windows内核的发展,以及学习操作系统的一些前提知识,最后还介绍了操作系统的研究进展。
第2章从总体上介绍了Windows操作系统。首先讨论现代操作系统的基本模型,以及一些重要部件的职责;然后讨论Windows的总体结构,以及有关WRK和相应源代码的一些说明。为了让读者对Windows内核有一个初步的认识,这一章还介绍了内核中的一些基本概念,包括进程、线程、内存管理、中断、异常、同步等,然后细致地讨论了Windows内核中的公共管理设施,包括对象管理器、配置管理器、事件追踪(ETW)和安全性管理。之所以在这一章中介绍这些公共设施,是为了让读者在学习本书后面章节中的核心概念和机制时,可以方便地直接引用这些管理设施中的功能。这一章的最后还介绍了Windows引导过程,包括内核初始化和用户会话建立过程。
第3章讨论了Windows中的进程和线程管理。首先讨论了进程和线程的基本概念,然后描述了Windows中有关进程和线程的重要数据结构,列出了这些数据结构的定义并解释了其中域的含义。接下来介绍了Windows进程中的句柄表结构、进程和线程的创建过程和结束处理,以及系统的初始进程和线程。这一章后面还介绍了Windows中的线程调度,包括时限管理、环境切换、线程状态转移等内容。
第4章介绍了Windows中的内存管理。首先介绍了一般性的内存管理知识,包括页式内存管理和段式内存管理。然后介绍了Windows的系统内存管理,涉及系统地址空间初始化、换页内存池和非换页内存池的管理算法,以及系统PTE区域的管理算法。紧接着介绍了进程虚拟地址空间的内存管理,包括地址空间的创建和初始化、虚拟内存的管理数据结构,以及虚拟内存中的内存区对象(section object)。然后讨论了Windows的页面交换机制和物理内存的管理,最后讨论了Windows的工作集(working set)管理。
第5章讨论了Windows中的并发和同步机制。这一章首先介绍了有关进程和线程同步的基础知识,然后介绍了Windows中的中断和异常处理机制,包括IRQL(中断请求级别)和中断对象、DPC(延迟过程调用)和定时器管理、APC(异步过程调用),以及异常分发过程。接下来分别介绍了两种类型的同步机制:高IRQL时的同步处理,以及基于线程调度的同步机制。Windows支持大量的同步语义,而且很多同步语义被导出成系统服务,可供应用程序使用。
序言回到顶部↑
推荐序一
序一
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
推荐序二
序二
序一
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
推荐序二
序二
【插图】








点击看大图







加载中...
