(Advanced Topics in) Operating Systems Winter Term 2009 / 2010 Jun.-Prof. Dr.-Ing. André Brinkmann brinkman@upb.de Universität Paderborn PC 1
Overview Overview of chapter 3: Case Studies 3.1 Windows Architecture.....3 3.2 Unix and Linux Architecture......20
Windows Architecture Modular structure for flexibility All system functions are supported by just one OS component Key system data and all functions can only be accessed through the appropriate interfaces Executes on a variety of hardware platforms Intel x86 and AMD64 for desktop Windows Additionally Intel IA64 for Server OS Windows NT supported DEC Alpha Windows NT has been designed by Dave Cutler, who has also been responsible for DEC s VMS OS Many similarities between VMS and NT Microsoft and DEC handled lawsuit out of court Supports applications written for other operating systems / personalities 16 Bit applications written for MS-DOS or Windows 3.1 3
Windows Architecture 4
Kernel-Mode Components Executive contains base operating system services Memory management (only architecture dependent executive) Process and thread management Security I/O Interprocess communication Kernel consists of the most used components Thread scheduling, trap handlers, interrupts, synchronization objects Division into kernel and executive is reflection of VAX/VMS roots VAX processor has 4 protection layers user, supervisor, executive, kernel Some of NT targets have less protection layers 5
Kernel-Mode Components Hardware abstraction layer (HAL) Abstraction from format of page-table entries, cache, word length, page sizes, in C would lead to severe performance penalties Some operations, like compare&swap, are impossible to port HAL isolates the operating system from platform-specific hardware differences Portability Some of the HW functions the HAL manages HAL does not provide drivers for individual I/O devices 6
Kernel-Mode Components Device drivers Translate user I/O function calls into specific hardware device I/O requests Uses functionalities provided by HAL (e.g. abstraction from accessing HW memory-mapped I/O or I/O ports) Includes DRM, file system, volume manager, TCP/IP stack, devices,... Drivers can be stacked Windowing and graphics systems Implements the graphical user interface (GUI) 7
Windows Executive Each component divided into internal and external data structures and interfaces ALL internal aspects only visible inside component External aspects visible to all components inside executive Drivers can link to external aspects via ntoskrnl.exe as library Runs in the context of calling thread Blocking in executive also blocks calling thread ok, if running for special task of calling thread unfair, if working on housekeeping functionality NT includes some dedicated kernel-mode threads for housekeeping 8
Windows Executive: Object Manager Encapsulation Object consists of one or more data items and one or more procedures Object class and instance Create specified instances of an object Inheritance Supported to some extent in the Executive Polymorphism Can be accessed by user mode processes through handles 9
Implementation of Objects I Structure of an object 10
Implementation of Objects II Some common executive object types managed by the object manager 11
Implementation of Objects III The relationship between handle tables, objects and type objects 12
The Object Name Space Some typical directories in the object name space Each object lives inside NT name space Name space is empty at boot time 13
The Registry I Registry is special file system for config info Organized in volumes called hives Each hive is a file Top level keys and selected subkeys Capitalization has no meaning but follows Microsoft practice. 14
The Registry II Some of the Win32 API calls for using the registry 15
Booting Windows 2000 Processes starting up during boot phase Those above the line are always started Those below are examples of services which could be started 16
Special system processes User-Mode Processes Ex: session manager, authentication subsystem, service manager logon process Service processes Environment subsystems User applications 17
Simplifies the Executive Client/Server Model Possible to construct a variety of APIs Improves reliability Each server runs outside the kernel, protected from other servers Provides a uniform means for applications to communicate via Remote Procedure Calls (RPCs) Provides base for distributed computing 18
Threads and SMP Operating system routines can run on any available processor Multiple threads of execution within a single process may execute on different processors simultaneously Server processes may use multiple threads Share data and resources between process 19
Unix Hardware is surrounded by the operating system software Comes with a number of user services and interfaces Shell Components of the C compiler 20
General UNIX Architecture 21
Traditional UNIX Kernel 22
Traditional UNIX Kernel User programs invoke OS services either directly or through library routines System call interface is boundary to user space Primitive routines that interact directly with the kernel at the other end Two main parts inside the kernel Process control subsystem File System Description valid for systems until 4.3BSD and System V release 3 Designed to run on a single processor Lacks ability to protect access to internal data structures from multiple processor Typically supports single file system, scheduler, executable file format, Code not designed for reuse Bloated and unmodular kernel 23
Modern UNIX Kernel 24
Modern UNIX Systems System V Release 4 (SVR4) Jointly developed by AT&T and Sun Microsystems Developed to provide a uniform platform for commercial Unix Solaris 10 is, e.g., SVR4 based Unix that provides full support for SMP, multi-threaded kernel, BSD Served as basis for many commercial Unix variants 4.4BSD has been the final version released by Berkley Afterwards developed under open source license as FreeBSD Success of FreeBSD has been hindered by lawsuit from AT&T MacOS X is based on FreeBSD 5.0 and Mach Kernel 3.0 25
Linux Does not use a microkernel approach Collection of loadable modules Dynamic linking Stackable modules 26
Linux Kernel Components 27
Linux Kernel Modules 28
Comparison MS Windows vs. Linux Windows / Linux Comparison Windows General Linux A commercial OS, with strong influences from VAX/VMS and requirements for compability with multiple OS personalities, such as DOS/Windows, POSIX, and, originally, OS/2 An open-source implementation of UNIX focused on simplicity and efficiency. Runs on a very large range of processor architectures. Environment which influenced fundamental design decisions 32-Bit program address space 16-bit program address space Mbytes of physical memory Kbytes of physical memory Virtual memory Swapping system with memory mapping Multiprocessor (4-way) Uniprocessor Micro-controller based I/O devices State-machine based I/O devices Client/Server distributed computing Standalone interactive systems Large, diverse user populations Small number of friendly users Compare these with today s environment 64-bit addresses Gbytes of physical memory Virtual memory, Virtual Processors Multiprocessor (64-128) High-speed internet/intranet, Web- Services Single user, but vulnerable to hackers worldwide Although both Windows and Linux have adapted to changes in the environment, the original design environments (i.e. in 1989 and 1973) heavily influenced the design choices. Unit of concurrency: Threads vs. Processes Process creation: Create Process () vs. Fork () I/O: Async vs sync Security: Discretionary Access vs. uid/gid 29