中山大学软件学院操作系统概念上课课件第22章.ppt
Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionChapter 22:Windows XP22.2Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionChapter 22:Windows XPnHistorynDesign PrinciplesnSystem ComponentsnEnvironmental Subsystems nFile systemnNetworkingnProgrammer Interface22.3Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionObjectivesnTo explore the principles upon which Windows XP is designed and the specific components involved in the systemnTo understand how Windows XP can run programs designed for other operating systemsnTo provide a detailed explanation of the Windows XP file systemnTo illustrate the networking protocols supported in Windows XPnTo cover the interface available to system and application programmers22.4Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionWindows XP n32-bit preemptive multitasking operating system for Intel microprocessorsnKey goals for the system:lportabilitylsecurity lPOSIX compliance lmultiprocessor support lextensibility linternational support lcompatibility with MS-DOS and MS-Windows applications.nUses a micro-kernel architecturenAvailable in four versions,Professional,Server,Advanced Server,National Server22.5Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionHistorynIn 1988,Microsoft decided to develop a“new technology”(NT)portable operating system that supported both the OS/2 and POSIX APIs.nOriginally,NT was supposed to use the OS/2 API as its native environment but during development NT was changed to use the Win32 API,reflecting the popularity of Windows 3.0.22.6Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionDesign PrinciplesnExtensibility layered architecturelExecutive,which runs in protected mode,provides the basic system serviceslOn top of the executive,several server subsystems operate in user modelModular structure allows additional environmental subsystems to be added without affecting the executivenPortability XP can be moved from on hardware architecture to another with relatively few changeslWritten in C and C+lProcessor-dependent code is isolated in a dynamic link library(DLL)called the“hardware abstraction layer”(HAL)22.7Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionDesign Principles(Cont.)nReliability XP uses hardware protection for virtual memory,and software protection mechanisms for operating system resourcesnCompatibility applications that follow the IEEE 1003.1(POSIX)standard can be complied to run on XP without changing the source codenPerformance XP subsystems can communicate with one another via high-performance message passinglPreemption of low priority threads enables the system to respond quickly to external eventslDesigned for symmetrical multiprocessingnInternational support supports different locales via the national language support(NLS)API22.8Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionXP ArchitecturenLayered system of modulesnProtected mode hardware abstraction layer(HAL),kernel,executivenUser mode collection of subsystemslEnvironmental subsystems emulate different operating systems lProtection subsystems provide security functions22.9Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionDepiction of XP Architecture22.10Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionnFoundation for the executive and the subsystemsnNever paged out of memory;execution is never preemptednFour main responsibilities:lthread schedulinglinterrupt and exception handling llow-level processor synchronizationlrecovery after a power failurenKernel is object-oriented,uses two sets of objectsldispatcher objects control dispatching and synchronization(events,mutants,mutexes,semaphores,threads and timers)lcontrol objects(asynchronous procedure calls,interrupts,power notify,power status,process and profile objects)System Components Kernel22.11Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionKernel Process and ThreadsnThe process has a virtual memory address space,information(such as a base priority),and an affinity for one or more processors.nThreads are the unit of execution scheduled by the kernels dispatcher.nEach thread has its own state,including a priority,processor affinity,and accounting information.nA thread can be one of six states:ready,standby,running,waiting,transition,and terminated.22.12Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionKernel SchedulingnThe dispatcher uses a 32-level priority scheme to determine the order of thread execution.lPriorities are divided into two classes4The real-time class contains threads with priorities ranging from 16 to 314The variable class contains threads having priorities from 0 to 15nCharacteristics of XPs priority strategylTrends to give very good response times to interactive threads that are using the mouse and windowslEnables I/O-bound threads to keep the I/O devices busylComplete-bound threads soak up the spare CPU cycles in the background22.13Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionKernel Scheduling(Cont.)nScheduling can occur when a thread enters the ready or wait state,when a thread terminates,or when an application changes a threads priority or processor affinity.nReal-time threads are given preferential access to the CPU;but XP does not guarantee that a real-time thread will start to execute within any particular time limit.lThis is known as soft realtime.22.14Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionWindows XP Interrupt Request Levels22.15Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionKernel Trap HandlingnThe kernel provides trap handling when exceptions and interrupts are generated by hardware of software.nExceptions that cannot be handled by the trap handler are handled by the kernels exception dispatcher.nThe interrupt dispatcher in the kernel handles interrupts by calling either an interrupt service routine(such as in a device driver)or an internal kernel routine.nThe kernel uses spin locks that reside in global memory to achieve multiprocessor mutual exclusion.22.16Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionExecutive Object ManagernXP uses objects for all its services and entities;the object manger supervises the use of all the objectslGenerates an object handlelChecks securitylKeeps track of which processes are using each objectnObjects are manipulated by a standard set of methods,namely create,open,close,delete,query name,parse and security.22.17Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionExecutive Naming ObjectsnThe XP executive allows any object to be given a name,which may be either permanent or temporary.nObject names are structured like file path names in MS-DOS and UNIX.nXP implements a symbolic link object,which is similar to symbolic links in UNIX that allow multiple nicknames or aliases to refer to the same file.nA process gets an object handle by creating an object by opening an existing one,by receiving a duplicated handle from another process,or by inheriting a handle from a parent process.nEach object is protected by an access control list.22.18Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionExecutive Virtual Memory ManagernThe design of the VM manager assumes that the underlying hardware supports virtual to physical mapping a paging mechanism,transparent cache coherence on multiprocessor systems,and virtual addressing aliasing.nThe VM manager in XP uses a page-based management scheme with a page size of 4 KB.nThe XP VM manager uses a two step process to allocate memorylThe first step reserves a portion of the processs address spacelThe second step commits the allocation by assigning space in the 2000 paging file22.19Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionVirtual-Memory Layout22.20Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionVirtual Memory Manager(Cont.)nThe virtual address translation in XP uses several data structureslEach process has a page directory that contains 1024 page directory entries of size 4 bytes.lEach page directory entry points to a page table which contains 1024 page table entries(PTEs)of size 4 bytes.lEach PTE points to a 4 KB page frame in physical memory.nA 10-bit integer can represent all the values form 0 to 1023,therefore,can select any entry in the page directory,or in a page table.nThis property is used when translating a virtual address pointer to a bye address in physical memory.nA page can be in one of six states:valid,zeroed,free standby,modified and bad.22.21Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionVirtual-to-Physical Address Translationn10 bits for page directory entry,20 bits for page table entry,and 12 bits for byte offset in page22.22Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionPage File Page-Table Entry5 bits for page protection,20 bits for page frame address,4 bits to select a paging file,and 3 bits that describe the page state.V=022.23Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionExecutive Process ManagernProvides services for creating,deleting,and using threads and processesnIssues such as parent/child relationships or process hierarchies are left to the particular environmental subsystem that owns the process.22.24Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionExecutive Local Procedure Call FacilitynThe LPC passes requests and results between client and server processes within a single machine.nIn particular,it is used to request services from the various XP subsystems.nWhen a LPC channel is created,one of three types of message passing techniques must be specified.lFirst type is suitable for small messages,up to 256 bytes;ports message queue is used as intermediate storage,and the messages are copied from one process to the other.lSecond type avoids copying large messages by pointing to a shared memory section object created for the channel.lThird method,called quick LPC was used by graphical display portions of the Win32 subsystem.22.25Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionExecutive I/O ManagernThe I/O manager is responsible for lfile systemslcache management ldevice driverslnetwork driversnKeeps track of which installable file systems are loaded,and manages buffers for I/O requestsnWorks with VM Manager to provide memory-mapped file I/OnControls the XP cache manager,which handles caching for the entire I/O systemnSupports both synchronous and asynchronous operations,provides time outs for drivers,and has mechanisms for one driver to call another22.26Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionFile I/O22.27Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionExecutive Security Reference MonitornThe object-oriented nature of XP enables the use of a uniform mechanism to perform runtime access validation and audit checks for every entity in the system.nWhenever a process opens a handle to an object,the security reference monitor checks the processs security token and the objects access control list to see whether the process has the necessary rights.22.28Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionExecutive Plug-and-Play ManagernPlug-and-Play(PnP)manager is used to recognize and adapt to changes in the hardware configuration.nWhen new devices are added(for example,PCI or USB),the PnP manager loads the appropriate driver.nThe manager also keeps track of the resources used by each device.22.29Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionEnvironmental SubsystemsnUser-mode processes layered over the native XP executive services to enable XP to run programs developed for other operating system.nXP uses the Win32 subsystem as the main operating environment;Win32 is used to start all processes.lIt also provides all the keyboard,mouse and graphical display capabilities.nMS-DOS environment is provided by a Win32 application called the virtual dos machine(VDM),a user-mode process that is paged and dispatched like any other XP thread.22.30Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionEnvironmental Subsystems(Cont.)n16-Bit Windows Environment:lProvided by a VDM that incorporates Windows on WindowslProvides the Windows 3.1 kernel routines and sub routines for window manager and GDI functionsnThe POSIX subsystem is designed to run POSIX applications following the POSIX.1 standard which is based on the UNIX model.22.31Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionEnvironmental Subsystems(Cont.)nOS/2 subsystems runs OS/2 applicationsnLogon and Security Subsystems authenticates users logging on to Windows XP systemslUsers are required to have account names and passwords.lThe authentication package authenticates users whenever they attempt to access an object in the system.lWindows XP uses Kerberos as the default authentication package22.32Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionFile SystemnThe fundamental structure of the XP file system(NTFS)is a volumelCreated by the XP disk administrator utilitylBased on a logical disk partitionlMay occupy a portions of a disk,an entire disk,or span across several disksnAll metadata,such as information about the volume,is stored in a regular filenNTFS uses clusters as the underlying unit of disk allocationlA cluster is a number of disk sectors that is a power of twolBecause the cluster size is smaller than for the 16-bit FAT file system,the amount of internal fragmentation is reduced22.33Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionFile System Internal LayoutnNTFS uses logical cluster numbers(LCNs)as disk addressesnA file in NTFS is not a simple byte stream,as in MS-DOS or UNIX,rather,it is a structured object consisting of attributesnEvery file in NTFS is described by one or more records in an array stored in a special file called the Master File Table(MFT)nEach file on an NTFS volume has a unique ID called a file reference.l64-bit quantity that consists of a 48-bit file number and a 16-bit sequence numberlCan be used to perform internal consistency checksnThe NTFS name space is organized by a hierarchy of directories;the index root contains the top level of the B+tree22.34Silberschatz,Galvin and Gagne 2009Operating System Concepts 8th EditionFile System RecoverynAll file system data structure updates are performed inside transactions that are logged.lBefore a data structure is altered,the transaction writes a log record that contains redo and undo information.lAfter the data structure has been changed,a commit record is written to the log to signify that the transaction succeeded.lAfter a crash,the file system data structures can be