Page 339 - DCAP103_Principle of operating system
P. 339

Principles of Operating Systems



                   Notes         Another kernel control object is the APC (Asynchronous Procedure Call). APCs are like DPCs
                                 except that they execute in the context of a specific process. When processing a key press, it
                                 does not matter on whose context the DPC runs in because all that is going to happen is that
                                 the key code will be inspected and probably put in a kernel buffer. However, if an interrupt
                                 requires copying a buffer from kernel space to a buffer in some user process address space (e.g.,
                                 as it may on completion of a read from the modem), then the copying procedure needs to run
                                 in the receiver’s context. The receiver’s context is needed so the page table will contain both
                                 the kernel buffer and the user buffer (all processes contain the entire kernel in their address
                                 spaces, as we will see later). For this reason, the kernel distinguishes between DPCs and APCs.
                                 The other kind of kernel objects are dispatcher objects. These include semaphores, mutexes,
                                 events, waitable timers, and other objects that threads can wait on. The reason that these have to
                                 be handled (in part) in the kernel is that they are intimately intertwined with thread scheduling,
                                 which is a kernel task. As a little aside, mutexes are called “mutants” in the code because they
                                 were  required  to  implement  the  OS/2  semantics  of  not  automatically  unlocking  themselves
                                 when a thread holding one exiled, something the Windows 2000 designers considered bizarre.
                                 (The OS/2 semantics are relevant because NT was originally conceived of as a replacement for
                                 OS/2, the operating system shipped on IBM’s PC/2.)
                                 11.1.3 Executive

                                 Above the kernel and device drivers is the upper portion of the operating system, called the
                                 executive, shown as the shaded area in Figure 11.1. The executive is written in C, is architecture
                                 independent, and can be ported to new machines with relatively little effort. It consists of
                                 10 components, each of which is just a collection of procedures that work together to accomplish
                                 some goal. There are no hard boundaries between the pieces and different authors describing
                                 the executive might even group the procedures differently into components. It should be noted
                                 that components on the same level can (and do) call each other extensively.

                                 The object manager manages all objects known to the operating system. These include processes,
                                 threads, files, directories, semaphores, I/O devices, timers, and many others. The object manager
                                 allocates a block of virtual memory from kernel address space when an object is created and
                                 returns it to the free list when the object is deal-located. Its job is to keep track of all the objects.
                                 To avoid any confusion, most of the executive components labeled “manager” in Figure 11.1
                                 are not processes or threads, but merely collections of procedures that other threads can execute
                                 when in kernel mode. A few of them, such as the power manager and plug-and-play manager,
                                 really are independent threads though.
                                 The object manager also manages a name space in which newly created objects may be placed
                                 so they can be referred to later. All other components of the executive use objects heavily to do
                                 their work. Objects are so central to the functioning of Windows 2000 that they will be discussed
                                 in detail in the next section.

                                 The I/O manager provides a framework for managing I/O devices and provides generic I/O
                                 services. It provides the rest of the system with device-independent I/O, calling the appropriate
                                 driver  to  perform  physical  I/O.  It  is  also  home  to  all  the  device  drivers  (indicated  by  D  in
                                 Figure 11.1). The file systems are technically device drivers under control of the I/O manager.
                                 Two different ones are present for the FAT and NTFS file systems, each one independent of
                                 the others and controlling different disk partitions. All the FAT file systems are managed by a
                                 single driver.

                                 The process manager handles processes and threads, including their creation and termination.
                                 It deals with the mechanisms used to manage them, rather than policies about how they are



        332                               LOVELY PROFESSIONAL UNIVERSITY
   334   335   336   337   338   339   340   341   342   343   344