Transcript module_01

OS/Kernel Structure
Module 01
1
MS-DOS Layer Structure
2
Unix is a monolithic system
• UNIX – the original UNIX operating system had
limited structuring. The UNIX OS consists of
two separable parts.
– Systems programs
– The kernel
• Consists of everything below the system-call interface and
above the physical hardware
• Provides the file system, CPU scheduling, memory
management, and other operating-system functions; a large
number of functions for one level.
3
UNIX System Structure
4
System Structure – Layered Approach
• The operating system is divided into a number of layers (levels),
each built on top of lower layers. The bottom layer (layer 0), is the
hardware; the highest (layer N) is the user interface.
• With modularity, layers are selected such that each uses functions
(operations) and services of only lower-level layers.
• Why layering?
– explicit structure allows identification, relationship of complex system’s
pieces
– modularization eases maintenance, develop, updating of system
• change of implementation of layer’s service transparent to rest of system
• e.g., change in gate procedure doesn’t affect rest of system
– layering considered harmful?
5
Layered Structure of the THE OS
• A layered design was first used in THE operating
system.
Its six layers are as follows:
layer 5: user programs
layer 4: buffering for input and output
layer 3: Process management
layer 2: memory management
layer 1: CPU scheduling
layer 0: hardware
6
OS/2 Layer Structure
7
Microkernels
• Small operating system core
• Contains only essential operating systems functions
• Many services traditionally included in the operating
system are now external subsystems
–
–
–
–
–
device drivers
file systems
virtual memory manager
windowing system
security services
8
9
Benefits of a Microkernel Organization
• Uniform interface on request made by a process
– All services are provided by means of message passing, not
system calls.
• Examples of opening a file
• Creating threads
• Extensibility
– Allows the addition of new services
• Flexibility
– New features added
– Existing features can be subtracted
10
Benefits of a Microkernel Organization
• Portability
– Changes needed to port the system to a new processor
is changed in the microkernel - not in the other
services
• Reliability
– Modular design
– Small microkernel can be rigorously tested
11
Benefits of Microkernel Organization
• Distributed system support
– Message are sent without knowing what the target
machine is
• Object-oriented operating system
– Components are objects with clearly defined
interfaces that can be interconnected to form software
12
Microkernel Design
• Microkernel must include functions that depend on the HW and
functions needed to support the servers and applications operating
in user mode.
– Low-level memory management
• mapping each virtual page to a physical page frame. Other
memory functions like swapping, protection, paging, etc is
done by VM service.
– Inter-process communication
• Using ports. A port is a mailbox associated with one
receiver and multiple senders.
– I/O and interrupt management
• Interrupts are transformed into messages.
13
KLM
• Examples of ukernels are Mach and Chorus
• Are the basis for KLM (Kernel Loadable Modules)
– Linux modules are located in /lib/modules and they have had
the extension ".ko" since version 2.6.
•
•
•
•
•
•
Sound
Device Drivers
Network support (Apple Talk, Novel, etc)
Language support
VM (the virtualization layer)
etc
14
Virtual Machines
 A virtual machine provides multiprogramming only by providing exact virtual
copies of the bare hardware .
 A virtual machine provides an interface identical to the underlying bare
hardware.
 The operating system creates the illusion of multiple processes, each executing
on its own processor with its own (virtual) memory.
 Virtual Machine: A machine implemented in software, not actual hardware. Also
known as a machine emulator, not as OS simulator.
 Each virtual machine can run any OS on top of it
 You can run different OSs, each best suited for some task, on the same
physical machine
 Similar to Java approach. JVM is an application VM.
 Virtual PC for Windows allows you to create separate “virtual machines” on top
of your Windows desktop, where you can install virtually any PC-based operating
system including OS/2, Linux, Solaris, NetWare or other versions of Windows.
Each virtual machine emulates a complete hardware system – from processor to
network card – in a self-contained, isolated software environment, enabling the
simultaneous operation of otherwise incompatible systems.
15
Virtual Machines (Cont.)
•
•
•
The resources of the physical computer are shared to create the virtual
machines.
– CPU scheduling can create the appearance that users have their own
processor.
– Spooling and a file system can provide virtual card readers and virtual line
printers.
– A normal user time-sharing terminal serves as the virtual machine operator’s
console.
– Instruction set emulation
Benefits of VM OS
– A big plus for SW development – can run and test SW simultaneously on
multiple OS on a single machine, without rebooting. Testing can take place
with different system configuration, like memory, disk space, etc.
– IT professionals can safely migrate and deploy new operating systems –
while continuing to run and support older or custom legacy applications.
– Internet VPS
– Cloud Computing – Amazon Elastic CC (or EC2)
– Testing networked machines with multiple NEs (routers, FWs, etc)
– Testing and parallel and distributed programming for cluster nodes
– Sandboxing – play and test in a protected environment w/o risking damage to
other kernels running.
– Server consolidation: virtualization allowed a single server to replace
multiple underutilized dedicated servers.
Any drawbacks?
16
System Models
Non-virtual Machine
Virtual Machine
(Classical Type originated by IBM
VM370 in 1972)
Similar to standalone
Hyber-V whereby a thin
layer is installed first
Virtualization layer or
Hypervisor or VMM
•VmWare (from Vmware Inc.),
•Virtual PC (Connectix, now Mircorsoft, Integrated within Windows 7 to run
all Windows XP apps)
•KVM (preferred choice for Red Hat and Ubuntu)
•Xen (freeware)
•Virtualbox from Sun Inc.
•A complete list is available at
http://en.wikipedia.org/wiki/Comparison_of_platform_virtual_machines
Possible that it can
span over multiple
CPUs (even in a
distributed fashion).
Referred as “Platform
Virtualization”
17
VMware architecture – Common Type (e.g. vmware)
18
Modern Virtualization
• Intel VT and AMD-V processors have hardware assisted
virtualization to yield better performance
• Full vs. Partial Virtualization
– Much of the underlying hardware is emulated, but not all
• Paravirtualization
– Guest OS has special calls to VM, called hybervisor calls to
speed access
– i.e. it provides an interface to VM
– Faster as the virtualization layer becomes smaller
19
Windows Hyper-V (2008 Server)
20
Hyper-V Architecture (1/2)
• A partition is a logical unit of isolation in which an OS
executes.
• The virtualization stack runs in the parent partition and
has direct access to the hardware devices.
• The parent partition then creates the child
partitions which host the guest OSs. A parent partition
creates child partitions using the hypercall API.
• A virtualized partition does not have access to the
physical processor, nor does it handle its real interrupts.
Instead, it has a virtual view of the processor and runs
in Guest Virtual Address.
21
Hyper-V Architecture (2/2)
• The hypervisor handles the interrupts to the processor, and
redirects them to the respective partition using a logical Synthetic
Interrupt Controller (SynIC). Hyper-V can hardware accelerate
the address translation between various Guest Virtual Addressspaces by using an IOMMU (I/O Memory Management Unit)
which operates independent of the memory management
hardware used by the CPU.
• Parent partitions run a Virtualization Service Provider (VSP),
which connects to the VMBus and handles device access requests
from child partitions. Child partition virtual devices internally run
a Virtualization Service Client (VSC), which redirect the request
to VSPs in the parent partition via the VMBus.
22
Microsoft Windows
• Single-user multitasking
• From Windows 2000 on, Windows
development developed to exploit modern 32bit and 64-bit microprocessors
• Designed for single users who run multiple
programs
• Main drivers are:
– Increased memory and speed of microprocessors
– Support for virtual memory
23
Windows Architecture
24
Client/Server Model
• Windows OS, protected subsystem, and
applications all use a client/server model
– Common in distributed systems, but can be used
internal to a single system
• Processes communicate via RPC
25
Windows Objects
• Windows draws heavily on the concepts of
object-oriented design.
• Key Object Oriented concepts used by
Windows are:
– Encapsulation
– Object class and instance
26
Traditional UNIX Kernel
27
System V Release 4 (SVR4)
28
Linux
• Modular Monolithic Kernel
• Although monolithic, the kernel is structures
as a collection of modules
– Loadable modules
– An object file which can be linked and unlinked at
run time
• Characteristics:
– Dynamic Linking
– Stackable modules
• For checking dependencies when unloading
29
Example of loading two modules: FAT & VFAT
VFAT is
a client
of FAT
30
•
*next: Pointer to the following module. All modules are
organized into a single linked list.
• *name: Pointer to module name.
• size:Module size in memory pages.
• usecount:Module usage counter.
– The counter is incremented when an operation involving the module’s
functions is started and decremented when the operation terminates.
•
•
•
•
•
flags:Module flags.
nsyms: Number of exported symbols.
ndeps: Number of referenced modules
*syms: Pointer to this module’s symbol table.
*deps: Pointer to list of modules the are referenced by this
module.
• *refs: Pointer to list of modules that use this module.
31
32
33
Linux Kernel Components
34