comparing windows XP and Linux
اسلاید 1: Windows Operating System Internals - by David A. Solomon and Mark E. Russinovich with Andreas PolzeCSE 5343/7343 Fall 2006 Case Studies Comparing Windows XP and Linux
اسلاید 2: 2Copyright Notice © 2000-2005 David A. Solomon and Mark RussinovichThese materials are part of the Windows Operating System Internals Curriculum Development Kit, developed by David A. Solomon and Mark E. Russinovich with Andreas PolzeMicrosoft has licensed these materials from David Solomon Expert Seminars, Inc. for distribution to academic organizations solely for use in academic environments (and not for commercial use)
اسلاید 3: Windows Operating System Internals - by David A. Solomon and Mark E. Russinovich with Andreas PolzeBackground Architecture
اسلاید 4: 4Linus and LinuxIn 1991 Linus Torvalds took a college computer science course that used the Minix operating systemMinix is a “toy” UNIX-like OS written by Andrew Tanenbaum as a learning workbenchLinus wanted to make MINIX more usable, but Tanenbaum wanted to keep it ultra-simpleLinus went in his own direction and began working on LinuxIn October 1991 he announced Linux v0.02In March 1994 he released Linux v1.0
اسلاید 5: 5Windows and LinuxBoth Linux and Windows are based on foundations developed in the mid-1970s1970198019902000UNIX bornUNIX publicUNIX V6Linux v1.0v2.0v2.1v2.2v2.3v2.4v2.61970198019902000VMS v1.0Windows NT 3.1 NT 4.0Windows 2000Windows XPServer 2003
اسلاید 6: 6Comparing the ArchitecturesBoth Linux and Windows are monolithicAll core operating system services run in a shared address space in kernel-modeAll core operating system services are part of a single moduleLinux: vmlinuz Windows: ntoskrnl.exeWindowing is handled differently:Windows has a kernel-mode Windowing subsystemLinux has a user-mode X-Windowing system
اسلاید 7: 7Kernel ArchitecturesDevice DriversProcess Management, Memory Management, I/O Management, etc.X-WindowsApplicationSystem ServicesUser ModeKernel ModeHardware Dependent CodeLinuxDevice DriversProcess Management, Memory Management, I/O Management, etc.Win32WindowingApplicationSystem ServicesUser ModeKernel ModeHardware Dependent CodeWindows
اسلاید 8: 8Linux KernelLinux is a monolithic but modular systemAll kernel subsystems form a single piece of code with no protection between themModularity is supported in two ways:Compile-time optionsMost kernel components can be built as a dynamically loadable kernel module (DLKM)DLKMsBuilt separately from the main kernel Loaded into the kernel at runtime and on demand (infrequently used components take up kernel memory only when needed)Kernel modules can be upgraded incrementallySupport for minimal kernels that automatically adapt to the machine and load only those kernel components that are used
اسلاید 9: 9Windows KernelWindows is a monolithic but modular systemNo protection among pieces of kernel code and driversSupport for Modularity is somewhat weak:Windows Drivers allow for dynamic extension of kernel functionalityWindows XP Embedded has special tools / packaging rules that allow coarse-grained configuration of the OSWindows Drivers are dynamically loadable kernel modulesSignificant amount of code run as drivers (including network stacks such as TCP/IP and many services)Built independently from the kernelCan be loaded on-demandDependencies among drivers can be specified
اسلاید 10: 10Comparing PortabilityBoth Linux and Windows kernels are portableMainly written in CHave been ported to a range of processor architecturesWindowsi486, MIPS, PowerPC, Alpha, IA-64, x86-64Only x86-64 and IA-64 currently supported> 64MB memory requiredLinuxAlpha, ARM, ARM26, CRIS, H8300, i386, IA-64, M68000, MIPS, PA-RISC, PowerPC, S/390, SuperH, SPARC, VAX, v850, x86-64DLKMs allow for minimal kernels for microcontrollers> 4MB memory required
اسلاید 11: 11Comparing Layering, APIs, ComplexityWindowsKernel exports about 250 system calls (accessed via ntdll.dll)Layered Windows/POSIX subsystems Rich Windows API (17 500 functions on top of native APIs)LinuxKernel supports about 200 different system callsLayered BSD, Unix Sys V, POSIX shared system librariesCompact APIs (1742 functions in Single Unix Specification Version 3; not including X Window APIs)
اسلاید 12: 12Comparing ArchitecturesProcesses and schedulingSMP supportMemory managementI/OFile CachingSecurity
اسلاید 13: Windows Operating System Internals - by David A. Solomon and Mark E. Russinovich with Andreas PolzeProcess Management
اسلاید 14: 14Process ManagementWindowsProcessAddress space, handle table, statistics and at least one threadNo inherent parent/child relationshipThreadsBasic scheduling unitFibers - cooperative user-mode threadsLinuxProcess is called a TaskBasic Address space, handle table, statisticsParent/child relationshipBasic scheduling unitThreadsNo threads per-seTasks can act like Windows threads by sharing handle table, PID and address spacePThreads – cooperative user-mode threads
اسلاید 15: 15Scheduling PrioritiesWindowsTwo scheduling classes“Real time” (fixed) - priority 16-31Dynamic - priority 1-15Higher priorities are favoredPriorities of dynamic threads get boosted on wakeupsThread priorities are never lowered3115160FixedDynamicI/OWindows
اسلاید 16: 16Scheduling PrioritiesWindowsTwo scheduling classes“Real time” (fixed) - priority 16-31Dynamic - priority 1-15Higher priorities are favoredPriorities of dynamic threads get boosted on wakeupsThread priorities are never loweredLinuxHas 3 scheduling classes:Normal – priority 100-139Fixed Round Robin – priority 0-99Fixed FIFO – priority 0-99Lower priorities are favored Priorities of normal threads go up (decay) as they use CPUPriorities of interactive threads go down (boost)
اسلاید 17: 17Scheduling Priorities (cont)3115160FixedDynamicI/OWindows140100990Fixed FIFOFixed Round-RobinNormalCPUI/OLinux
اسلاید 18: 18Linux Scheduling DetailsMost threads use a dynamic priority policy Normal class - similar to the classic UNIX schedulerA newly created thread starts with a base priority Threads that block frequently (I/O bound) will have their priority gradually increasedThreads that always exhaust their time slice (CPU bound) will have their priority gradually decreased“Nice value” sets a thread’s base priorityLarger values = less priority, lower values = higher priorityValid nice values are in the range of -20 to +20 Nonprivileged users can only specify positive nice valueDynamic priority policy threads have static priority zero Execute only when there are no runnable real-time threads
اسلاید 19: 19Real-Time Scheduling on LinuxLinux supports two static priority scheduling policies:Round-robin and FIFO (first in, first out)Selected with the sched-setscheduler( ) system callUse static priority values in the range of 1 to 99Executed strictly in order of decreasing static priorityFIFO policy lets a thread run to completion Thread needs to indicate completion by calling the sched-yield( )Round-robin lets threads run for up to one time slice Then switches to the next thread with the same static priorityRT threads can easily starve lower-prio threads from executing Root privileges or the CAP-SYS-NICE capability are required for the selection of a real-time scheduling policyLong running system calls can cause priority-inversionSame as in Windows; but cmp. rtLinux
اسلاید 20: 20Windows Scheduling DetailsMost threads run in variable priority levelsPriorities 1-15; A newly created thread starts with a base priority Threads that complete I/O operations experience priority boosts (but never higher than 15)A thread’s priority will never be below base priorityThe Windows API function SetThreadPriority() sets the priority value for a specified threadThis value, together with the priority class of the threads process, determines the threads base priority levelWindows will dynamically adjust priorities for non-realtime threads
اسلاید 21: 21Real-Time Scheduling on WindowsWindows supports static round-robin scheduling policy for threads with priorities in real-time range (16-31)Threads run for up to one quantumQuantum is reset to full turn on preemptionPriorities never get boostedRT threads can starve important system servicesSuch as CSRSS.EXESeIncreaseBasePriorityPrivilege required to elevate a thread’s priority into real-time range (this privilege is assigned to members of Administrators group)System calls and DPC/APC handling can cause priority inversion
اسلاید 22: 22Scheduling TimeslicesWindowsThe thread timeslice (quantum) is 10ms-120msWhen quanta can vary, has one of 2 valuesReentrant and preemptible Fixed: 120ms20msForeground: 60msBackgroundLinuxThe thread quantum is 10ms-200msDefault is 100msVaries across entire range based on priority, which is based on interactivity levelReentrant and preemptible 100ms200ms10ms
اسلاید 23: 23Kernel ReentrancyMark Russinovich’s April 1999 Windows NT Magazine article, “Linux and the Enterprise”, pointed out that much of the Linux 2.2 was not reentrantIngo Molnar stated in rebuttal:“his example is a clear red herring.”A month later he made all major paths reentrantcpu 1cpu 2cpu 1cpu 2Non-reentrantReentrantTime Saved
اسلاید 24: 24Kernel PreemptibilityA preemptible kernel is more responsive to high-priority tasksThrough the base release of v2.4 Linux was only cooperatively preemptibleThere are well-defined safe places where a thread running in the kernel can be preemptedThe kernel is preemptible in v2.4 patches and v2.6Windows NT has always been preemptible
اسلاید 25: 25SchedulingThe Linux 2.4 scheduler is O(n)If there are 10 active tasks, it scans 10 of them in a list in order to decide which should execute nextThis means long scans and long durations under the scheduler lock103112112101ReadyListHighest PriorityTask
اسلاید 26: 26SchedulingLinux 2.6 has a revamped scheduler that’s O(1) from Ingo Molnar that:Calculates a task’s priority at the time it makes scheduling decisionHas per-CPU ready queues where the tasks are pre-sorted by priority112112101103Highest-priorityNon-empty Queue
اسلاید 27: 27SchedulingWindows NT has always had an O(1) scheduler based on pre-sorted thread priority queuesServer 2003 introduced per-CPU ready queuesLinux load balances queues Windows does notNot seen as an issue in performance testing by MicrosoftApplications where it might be an issue are expected to use affinity
اسلاید 28: 28Zero-Copy SendfileLinux 2.2 introduced Sendfile to efficiently send file data over a socketI pointed out that the initial implementation incurred a copy operation, even if the file data was cachedLinux 2.4 introduced zero-copy SendfileWindows NT pioneered zero-copy file sending with TransmitFile, the Sendfile equivalent, in Windows NT 4File DataBufferNetwork AdapterBufferNetworkFile DataBufferNetworkDriverNetworkNetworkDriver1-Copy0-Copy
اسلاید 29: 29Wake-one Socket SemanticsLinux 2.2 kernel had the thundering herd or overscheduling problemIn a network server application there are typically several threads waiting for a new connectionIn v2.2 when a new connection came in all the waiters would race to get itIngo Molnar’s response: 5/2/99: “here he again forgets to _prove_ that overscheduling happens in Linux.”5/7/99: “as of 2.3.1 my wake-one implementation and waitqueues rewrite went in”In Linux 2.4 only one thread wakes up to claim the new connection Windows NT has always had wake-1 semantics
اسلاید 30: 30Light-Weight SynchronizationLinux 2.6 introduces FutexesThere’s only a transition to kernel-mode when there’s contentionWindows has always had CriticalSectionsSame behaviorFutexes go further:Allow for prioritization of waitsWorks interprocess as well
اسلاید 31: Windows Operating System Internals - by David A. Solomon and Mark E. Russinovich with Andreas PolzeMemory Management
اسلاید 32: 32Virtual Memory ManagementWindows32-bit versions split user-mode/kernel-mode from 2GB/2GB to 3GB/1GBDemand-paged virtual memory32 or 64-bitsCopy-on-writeShared memoryMemory mapped filesUserSystem02GB4GBLinuxSplits user-mode/kernel-mode from 1GB/3GB to 3GB/1GB2.6 has “4/4 split” option where kernel has its own address spaceDemand-paged virtual memory32-bits and/or 64-bitsCopy-on-writeShared memoryMemory mapped filesUserSystem03GB4GB
اسلاید 33: 33Physical Memory ManagementWindowsPer-process working setsWorking set tuner adjust sets according to memory needs using the “clock” algorithmNo “swapper”ProcessLRUReused PageLinuxGlobal working set management uses “clock” algorithmNo “swapper” (the working set trimmer code is called the swap daemon, however)LRUReused PageOther ProcessLRU
اسلاید 34: 34I/O ManagementWindowsCentered around the file objectLayered driver architecture throughout driver typesMost I/O supports asynchronous operationInternal interrupt request level (IRQL) controls interruptabilityInterrupts are split between an Interrupt Service Routine (ISR) and a Deferred Procedure Call (DPC)Supports plug-and-playLinuxCentered around the vnodeNo layered I/O modelMost I/O is synchronousOnly sockets and direct disk I/O support asynchronous I/OInternal interrupt request level (IRQL) controls interruptabilityInterrupts are split between an ISR and soft IRQ or taskletSupports plug-and-playIRQLMasked
اسلاید 35: Windows Operating System Internals - by David A. Solomon and Mark E. Russinovich with Andreas PolzeI/O & File System Management
اسلاید 36: 36File CachingWindowsSingle global common cacheVirtual file cacheCaching is at file vs. disk block levelFiles are memory mapped into kernel memory Cache allows for zero-copy file servingFile CacheFile System Driver Disk DriverLinuxSingle global common cacheVirtual file cacheCaching is at file vs. disk block levelFiles are memory mapped into kernel memory Cache allows for zero-copy file servingFile CacheFile System Driver Disk Driver
اسلاید 37: 37Monitoring - Linux procfsLinux supports a number of special filesystemsLike special files, they are of a more dynamic nature and tend to have side effects when accessedPrime example is procfs (mounted at /proc)provides access to and control over various aspects of Linux (I.e.; scheduling and memory management)/proc/meminfo contains detailed statistics on the current memory usage of LinuxContent changes as memory usage changes over timeServices for Unix implements procfs on Windows
اسلاید 38: 38I/O ProcessingLinux 2.2 had the notion of bottom halves (BH) for low-priority interrupt processingFixed number of BHsOnly one BH of a given type could be active on a SMPLinux 2.4 introduced tasklets, which are non-preemptible procedures called with interrupts enabledTasklets are the equivalent of Windows Deferred Procedure Calls (DPCs)
اسلاید 39: 39Asynchronous I/OLinux 2.2 only supported asynchronous I/O on socket connect operations and tty’sLinux 2.6 adds asynchronous I/O for direct-disk accessAIO model includes efficient management of asynchronous I/OAlso added alternate epoll modelUseful for database servers managing their database on a dedicated raw partitionDatabase servers that manage a file-based database suffer from synchronous I/OWindows I/O is inherently asynchronousWindows has had completion ports since NT 3.5More advanced form of AIO
اسلاید 40: Windows Operating System Internals - by David A. Solomon and Mark E. Russinovich with Andreas PolzeSecurity
اسلاید 41: 41SecurityWindowsVery flexible security model based on Access Control ListsUsers are defined withPrivilegesMember groupsSecurity can be applied to any Object Manager objectFiles, processes, synchronization objects, …Supports auditingLinuxTwo models: Standard UNIX modelAccess Control Lists (SELinux)Users are defined with:Capabilities (privileges)Member groupsSecurity is implemented on an object-by-object basisHas no built-in auditing supportVersion 2.6 includes Linux Security Module framework for add-on security models
اسلاید 42: 42A Look at the FutureThe kernel architectures are fundamentally similarThere are differences in the detailsLinux implementation is adopting more of the good ideas used in WindowsFor the next 2-4 years Windows has and will maintain an edgeLinux is still behind on the cutting edge of performance tricksLarge performance team and lab at Microsoft has direct ties into the kernel developersAs time goes on the technological gap will narrowOpen Source Development Labs (OSDL) will feed performance test results to the kernel teamIBM and other vendors have Linux technology centersSqueezing performance out of the OS gets much harder as the OS gets more tuned
اسلاید 43: 43Linux Technology UnknownsLinux kernel forkingRedHat has already done it: Red Hat Enterprise Server v3.0 is Linux 2.4 with some Linux 2.6 featuresBackward compatibility philosophyLinus Torvalds makes decisions on kernel APIs and architecture based on technical reasons, not business reasons
اسلاید 44: 44Further ReadingTransaction Processing Council: www.tpc.orgSPEC: www.spec.orgNT vs Linux benchmarks: www.kegel.com/nt-linux-benchmarks.htmlThe C10K problem: http://www.kegel.com/c10k.htmlLinus Torvald’s home: http://www.osdl.org/Linux Kernel Archives: http://www.kernel.org/Linux history: http://www.firstmonday.dk/issues/issue5_11/moon/Veritest Netbench result: http://www.veritest.com/clients/reports/microsoft/ms_netbench.pdfMark Russinovich’s 1999 article, “Linux and the Enterprise”: http://www.winntmag.com/Articles/Index.cfm?ArticleID=5048The Open Groups Single UNIX Specification: http://www.unix.org/version3/
نقد و بررسی ها
هیچ نظری برای این پاورپوینت نوشته نشده است.