Sie sind auf Seite 1von 23

Comparing Windows and Linux

4/21/12

Linus and Linux


In 1991 Linus Torvalds took a college computer science course that used the Minix operating system
Minix is a toy UNIX-like OS written by Andrew Tanenbaum as a learning workbench Linus wanted to make MINIX more usable, but Tanenbaum wanted to keep it ultra-simple

Linus went in his own direction and began working on Linux


In October 1991 he announced Linux v0.02 In March 1994 he released Linux v1.0

4/21/12

Windows and Linux


Both Linux and Windows are based on foundations developed in the mid1970s 198 197 199 200
0 0 0 0
v 0 v2. 1 2. U bo NIX rn U pu NIX bl ic
L v1 inu .0 x

197 0
V v1 MS .0

U V6 NIX

198 0

199 0
N 4. T 0

v 2 2. v 3 2. v 4 2.

200 0

v 6 2.

4/21/12

Comparing the Architectures


Both Linux and Windows are monolithic
All core operating system services run in a shared address space in kernel-mode All core operating system services are part of a single module
Linux: vmlinuz Windows: ntoskrnl.exe

Windowing is handled differently:


Windows has a kernel-mode Windowing subsystem Linux has a user-mode X-Windowing system

4/21/12

Comparing Portability
Both Linux and Windows kernels are portable Windows
Mainly written in C Have been ported to a range of processor architectures i486, MIPS, PowerPC, Alpha, IA-64, x86-64 Only x86-64 and IA-64 currently supported > 64MB memory required Alpha, ARM, ARM26, CRIS, H8300, i386, IA-64, M68000, MIPS, PA-RISC, PowerPC, S/390, SuperH, SPARC, VAX, v850, x86-64 DLKMs allow for minimal kernels for microcontrollers > 4MB memory required

Linux

4/21/12

Comparing Architectures
Processes and scheduling Memory management I/O File Caching Security

4/21/12

Process Management

4/21/12

Process Management
Windows Process
Address space, handle table, statistics and at least one thread No inherent parent/child relationship Basic scheduling unit Fibers - cooperative usermode threads

Linux Process is called a Task


Basic Address space, handle table, statistics Parent/child relationship Basic scheduling unit Threads No threads per-se Tasks can act like Windows threads by sharing handle table, PID and address space PThreads cooperative user-mode threads

Threads

4/21/12

Scheduling Priorities
Windows Two scheduling classes
Real time (fixed) priority 16-31 Dynamic - priority 1-15
31 Fixed

Higher priorities are favored

Priorities of dynamic threads get boosted on wakeups Thread priorities are never lowered

16 15 Dynamic I/O

Windows
4/21/12 9

Scheduling Priorities
Windows Two scheduling classes
Real time (fixed) priority 16-31 Dynamic - priority 1-15

Linux Has 3 scheduling classes:

Higher priorities are favored

Priorities of dynamic threads get boosted on wakeups Thread priorities are never lowered

Normal priority 100-139 Fixed Round Robin priority 0-99 Fixed FIFO priority 0-99 Lower priorities are favored Priorities of normal threads go up (decay) as they use CPU Priorities of interactive threads go down (boost)

4/21/12

10

Scheduling Priorities (cont)


31 0 Fixed

Fixed FIFO Fixed Round-Robin

16 15 Dynamic I/O 99 100 Normal 0 140 I/O CPU

Windows

Linux

4/21/12

11

Scheduling Timeslices
Windows The thread timeslice (quantum) is 10ms120ms
When quanta can vary, has one of 2 values

Reentrant and preemptible

Linux The thread quantum is 10ms200ms Default is 100ms Varies across entire range based on priority, which is based on interactivity level Reentrant and preemptible

Fixed: 120ms 20ms Background 10ms 100ms 4/21/12 12 200ms

Foreground: 60ms

Zero-Copy Sendfile
Linux 2.2 introduced Sendfile to efficiently send file data over a socket
I pointed out that the initial implementation incurred a copy operation, even if the file data was cached

Linux 2.4 introduced zero-copy Sendfile Windows NT pioneered zero-copy file sending with TransmitFile, the Sendfile equivalent, in Windows NT 4

File Data Buffer

1Copy
Networ k

File Data Buffer

0Copy
Networ k 4/21/12 13

Networ Networ k Adapter k Buffer Driver

Networ k Driver

Linux 2.6 introduces Futexes Windows has always had CriticalSections


Same behavior

Light-Weight Synchronization

Theres only a transition to kernel-mode when theres contention

Futexes go further:
Allow for prioritization of waits Works interprocess as well
4/21/12 14

Memory Management

4/21/12

Virtual Memory Linux Windows Management to 3GB/1GB Splits user-mode/kernel-mode 32-bit versions split usermode/kernel-mode from from 1GB/3GB
2GB/2GB to 3GB/1GB Demand-paged virtual memory
32 or 64-bits Copy-on-write Shared memory Memory mapped files

Demand-paged virtual memory


32-bits and/or 64-bits Copy-on-write Shared memory Memory mapped files

2.6 has 4/4 split option where kernel has its own address space

0 Use r 2G B Syste m 4G B

0 User

3GB 4GB System

4/21/12

16

Physical Memory Windows Linux Management set Per-process working sets Global working
No swapper
LRU Process Reused Page LRU Other Process Reused Page Working set tuner adjust sets according to memory needs using the clock algorithm

management uses clock algorithm No swapper (the working set trimmer code is called the swap daemon, however)

LRU

4/21/12

17

I/O Management
Windows
Centered around the file object Layered driver architecture throughout driver types Most I/O supports asynchronous operation Internal interrupt request level (IRQL) controls interruptability Interrupts are split between an Interrupt Service Routine (ISR) and a Deferred Procedure Call (DPC) Supports plug-and-play

Linux Centered around the vnode No layered I/O model Most I/O is synchronous

Only sockets and direct disk I/O support asynchronous I/O Internal interrupt request level (IRQL) controls interruptability Interrupts are split between an ISR and soft IRQ or tasklet Supports plug-and-play

IRQL Maske d 4/21/12 18

I/O & File System Management

4/21/12

File Caching
Windows
Single global common cache Virtual file cache
Caching is at file vs. disk block level Files are memory mapped into kernel memory

Linux
Single global common cache Virtual file cache
Caching is at file vs. disk block level Files are memory mapped into kernel memory

Cache allows for zero-copy file serving

Cache allows for zero-copy file serving

File Cache

File Cache

File System Driver Disk Driver

File System Driver

Disk Driver 4/21/12 20

Security

4/21/12

Security
Windows
Very flexible security model based on Access Control Lists Users are defined with

Linux

Two models:

Security can be applied to any Object Manager object Supports auditing


Files, processes, synchronization objects,

Privileges Member groups

Users are defined with:

Standard UNIX model Access Control Lists (SELinux) Capabilities (privileges) Member groups

Security is implemented on an object-by-object basis Has no built-in auditing support Version 2.6 includes Linux Security Module framework for add-on security models

4/21/12

22

Thank You

4/21/12

Das könnte Ihnen auch gefallen