OS Organization
description
Transcript of OS Organization
![Page 1: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/1.jpg)
OS Organization
Andy Wang
COP 5611
Advanced Operating Systems
![Page 2: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/2.jpg)
Outline
Organizing operating systemsSome microkernel examplesObject-oriented organizations
Spring
Organization for multiprocessors
![Page 3: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/3.jpg)
Operating System Organization
Size of modern OsesMicrosoft Windows: 50 millions (2003)Mercedes Benz: 20 millions (2009)Linux: 15 millions (2012)Space shuttle: 400,000 (2010)
What is the best way to design an OS?What are the important software
characteristics of an OS?
![Page 4: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/4.jpg)
Important OS Software Characteristics
Correctness and simplicityPower and completenessExtensibility and portabilityPerformanceSuitability for distributed and parallel
systemsCompatibility with existing systemsSecurity and fault tolerance
![Page 5: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/5.jpg)
Common OS Organizations
Monolithic Virtual machine Layered designsKernel designsMicrokernelsObject-oriented
Note that individual OS components can be organized these ways
![Page 6: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/6.jpg)
Monolithic OS Design
Build OS as single combined moduleHopefully using data abstraction,
compartmentalized function, etc.
OS lives in its own, single address spaceExamples
DOSearly Unix systemsmost VFS file systems
![Page 7: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/7.jpg)
Pros/Cons of Monolithic OS Organization
+ Highly adaptable (at first . . .)
+ Little planning required
+ Potentially good performance
– Hard to extend and change
– Eventually becomes extremely complex
– Eventually performance becomes poor
– Highly prone to bugs
![Page 8: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/8.jpg)
Virtual Machine Organizations
A base OS provides services in a very generic way
One or more other OSes live on top of the base systemUsing the services it providesTo offer different views of system to users
Examples - the Java interpreter, Xen, VMWare
![Page 9: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/9.jpg)
Pros/Cons of VM Organizations
+ Allows multiple OS personalities on a single machine
+ Good OS development environment
+ Can provide good portability of applications
– Significant performance problems
– Especially if more than 2 layers
– Lacking in flexibility
![Page 10: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/10.jpg)
Layered OS Design
Design tiny innermost layer of softwareNext layer out provides more functionality
Using services provided by inner layer
Continue adding layers until all functionality required has been provided
ExamplesMulticsFlukelayered file systems and comm. protocols
![Page 11: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/11.jpg)
Pros/Cons of Layered Organization
+ More structured and extensible
+ Easy model
– Layer crossing can be expensive
– In some cases, multiple layers unnecessary
– Duplicate caching/consistency issues
![Page 12: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/12.jpg)
Kernel OS Designs
Similar to layers, but only two OS layersKernel OS servicesNon-kernel OS services
Move certain functionality outside kernelfile systems, libraries
Unlike VMs, kernel doesn’t stand aloneExamples - Most modern Unix systems
![Page 13: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/13.jpg)
Pros/Cons of Kernel OS Organization
+ Advantages of layering, without too many layers
+ Easier to demonstrate correctness
– Not as general as layering
– Offers no organizing principle for other parts of OS, user services
– Kernels tend to grow to monoliths
![Page 14: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/14.jpg)
Microkernel OS Design
Like kernels, only less soTry to include only small set of required
services in the microkernelSee Liedtke’s paper and Lions’ book
Moves more out of innermost OS partLike parts of VM, IPC, paging, etc.
Examples - Mach, Amoeba, Plan 9, Chorus, Windows NT, Minix 3
![Page 15: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/15.jpg)
Pros/Cons of Microkernel Organization
+ Those of kernels, plus:
+ Minimizes code for most important OS services
+ Offers model for entire system
– Microkernels tend to grow into kernels
– Requires very careful initial design choices
– Serious danger of bad performance– Too many kernel crossings (addressed by L3)
![Page 16: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/16.jpg)
Object-Oriented OS Design
Design internals of OS as set of privileged objects, using OO methods
Sometimes extended into app spaceTends to lead to client/server style of
computingExamples
Mach (internally)Spring (totally)
![Page 17: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/17.jpg)
Pros/Cons of OO OS Organization
+ Offers organizational model for entire system
+ Easily divides system into pieces
+ Good hooks for security
– Can be a limiting model
– Must watch for performance problems
![Page 18: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/18.jpg)
Micro-ness is in the eye of the beholderMachAmoebaPlan 9Windows NT
Some Important Microkernel Designs
![Page 19: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/19.jpg)
Mach
Mach didn’t start life as a microkernelBecame one in Mach 3.0
Object-oriented internallyDoesn’t force OO at higher levels
Microkernel focus is on communications facilities
Much concern with parallel/distributed systems
![Page 20: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/20.jpg)
Mach Model
Kernelspace
UserspaceSoftware
emulationlayer
4.3BSDemul.
SysVemul.
HP/UXemul.
otheremul.
Userprocesses
Microkernel
![Page 21: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/21.jpg)
What’s In the Mach Microkernel?
Tasks & threadsPorts and port setsMessagesMemory objectsDevice supportMultiprocessor/distributed support
![Page 22: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/22.jpg)
Mach Tasks
An execution environment providing basic unit of resource allocation
Contains Virtual address spacePort setOne or more threads
![Page 23: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/23.jpg)
Mach Task Model
Processport
Bootstrapport
Exceptionport
Registeredports
Addressspace
Thread
Process
Use
r sp
ace
Ker
nel
![Page 24: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/24.jpg)
Mach Threads
Basic unit of Mach executionRun in context of one taskAll threads in one task share its resourcesUnix process similar to Mach task with
single thread
![Page 25: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/25.jpg)
Task and Thread Scheduling
Very flexibleControllable by kernel or user-level
programsThreads of single task can run in parallel
On single processor and multiple processorsLocal and global schedulers for multicore
machines
User-level scheduling can extend to multiprocessor scheduling
![Page 26: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/26.jpg)
Mach Ports
Basic Mach object reference mechanismKernel-protected communication channel
Tasks communicate by sending messages to ports
Threads in receiving tasks pull messages off a queue
Ports are location independentPort queues protected by kernel; bounded
![Page 27: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/27.jpg)
Port Rights (Capability)
Mechanism by which tasks control who may talk to their portsKernel prevents messages being sent to a port
unless the sender has its port rights
Port rights also control which single task receives on a port
![Page 28: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/28.jpg)
Port Sets
A group of ports sharing a common message queue
A thread can receive messages from a port setThus servicing multiple ports
Messages are tagged with the actual portA port can be a member of at most one
port set
![Page 29: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/29.jpg)
Mach Messages
Typed collection of data objectsUnlimited size
Sent to particular portMay contain actual data or pointer to dataPort rights may be passed in a messageKernel inspects messages for particular
data types (like port rights)
![Page 30: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/30.jpg)
Mach Memory Objects
A source of memory accessible by tasksMay be managed by user-mode external
memory managera file managed by a file server
Accessed by messages through a portKernel manages physical memory as
cache of contents of memory objects
![Page 31: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/31.jpg)
Mach Device Support
Devices represented by portsMessages control the device and its data
transferActual device driver outside the kernel in
an external objectDevice drivers in early Linux for performanceDevice drivers are moving out of Linux for
reliability
![Page 32: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/32.jpg)
Mach Multiprocessor and Distributed System SupportMessages and ports can extend across
processor/machine boundariesLocation transparent entities
Kernel manages distributed hardwarePer-processor data structures, but also
structures shared across the processorsIntermachine messages handled by a
server that knows about network details
![Page 33: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/33.jpg)
Mach’s NetMsgServer
User-level capability-based networking daemon
Handles naming and transport for messages
Provides world-wide name service for ports
Messages sent to off-node ports go through this server
![Page 34: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/34.jpg)
NetMsgServer in Action
User space
Kernel space
Sender
User process
NetMsgServer
User space
Kernel space
Receiver
User process
NetMsgServer
![Page 35: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/35.jpg)
Mach and User Interfaces
Mach was built for the UNIX community UNIX programs don’t know about ports,
messages, threads, and tasks
How do UNIX programs run under Mach?Mach typically runs a user-level server that
offers UNIX emulationEither provides UNIX system call semantics
internally or translates it to Mach primitives
![Page 36: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/36.jpg)
Amoeba
Amoeba presents transparent distributed computing environment (a la timesharing)
Major componentsprocessor poolsserver machinesX-terminalsgateway servers for off-LAN communications
Microkernel runs everywhere
![Page 37: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/37.jpg)
Amoeba Diagram
Server pool
Workstations
Specialized servers
Gateway
LAN
WAN
![Page 38: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/38.jpg)
Amoeba’s Basic Primitives
ProcessesThreadsLow level memory managementRPCI/O
![Page 39: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/39.jpg)
Amoeba Software Model
Addressspace
Thread
Process
Use
r sp
ace
Ker
nel
Process mgmt.Memory mgmt.Comm’sI/O
![Page 40: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/40.jpg)
Amoeba Processes
Similar to Mach processesProcess has multiple threads
But each thread has a dedicated portion of a shared address space
Thread scheduling by microkernel
![Page 41: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/41.jpg)
Amoeba Memory Management
Amoeba microkernel supports concept of segmentsTo avoid the heavy cost of fork across machine
boundariesFork only creates new memory mappings
Copy on writes (COW)
A segment is a set of memory blocksSegments can be mapped in/out of
address spaces
![Page 42: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/42.jpg)
Remote Procedure Call
Fundamental Amoeba IPC mechanismAmoeba RPC is thread-to-threadMicrokernel handles on/off machine
invocation of RPC
![Page 43: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/43.jpg)
Plan 9
Everything in Plan 9 is a file system (almost)ProcessesFilesIPCDevices
Only a few operations are required for filesText-based interface
![Page 44: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/44.jpg)
Plan 9 Basic Primitives
TerminalsCPU serversFile systemsChannels
![Page 45: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/45.jpg)
File Systems in Plan 9
File systems consist of a hierarchical tree Can be persistent or temporaryCan represent simple or complex entitiesCan be implemented
In the kernel as a driverAs a user level processBy remote servers
![Page 46: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/46.jpg)
Sample Plan 9 File Systems
Device file systems - Directory containing data and ctl file
Process file systems - Directory containing files for memory, text, control, etc.
Network interface file systems
![Page 47: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/47.jpg)
Plan 9 Channels and Mounting
A channel is a file descriptorSince a file can be anything, a channel is a
general pointer to anything
Plan 9 provides 9 primitives on channelsMounting is used to bring resources into a
user’s name spaceUsers start with minimal name space,
build it up as they go along
![Page 48: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/48.jpg)
Typical User Operation in Plan 9User logs in to a terminal
Provides bitmap display and input
Minimal name space is set up on loginMounts used to build spacePooled CPU servers used for compute
tasksSubstantial caching used to make
required files local
![Page 49: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/49.jpg)
Windows NT
More layered than some microkernel designs
NT Microkernel provides base servicesExecutive builds on base services via
modules to provide user-level servicesUser-level services used by
privileged subsystems (parts of OS)true user programs
![Page 50: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/50.jpg)
Windows NT Diagram
Hardware
MicrokernelExecutive
UserProcesses
ProtectedSubsystems
User Mode
Kernel Mode
Win32 POSIX
![Page 51: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/51.jpg)
NT Microkernel
Thread schedulingProcess switchingException and interrupt handlingMultiprocessor synchronizationOnly NT part not preemptible or pageable
(why?)All other NT components runs in threads
![Page 52: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/52.jpg)
NT Executive
Higher level services than microkernelRuns in kernel mode
but separate from the microkernel itselfease of change and expansion
Built of independent modulesall preemptible and pageable
![Page 53: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/53.jpg)
NT Executive Modules
Object managerSecurity reference monitorProcess managerLocal procedure call facility (a la RPC)Virtual memory managerI/O manager
![Page 54: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/54.jpg)
Typical Activity in NT
Hardware
KernelExecutive
Client Process
Win32ProtectedSubsystem
![Page 55: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/55.jpg)
Windows NT Threads
Executable entity running in an address space
Scheduled by kernelHandled by kernel’s dispatcherKernel works with stripped-down view of
thread - kernel thread objectMultiple process threads can execute on
distinct processors--even Executive ones
![Page 56: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/56.jpg)
Microkernel Process Object
A proxy for the real processMicrokernel’s interface to the real processContains pointers to the various resources
owned by the processe.g., threads and address spaces
Alterable only by microkernel calls
![Page 57: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/57.jpg)
Microkernel Thread Objects
Proxies for the real thread One per thread
Contains minimal information about threadPriorities, dispatching state
Used by the microkernel for dispatching
![Page 58: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/58.jpg)
Microkernel Process and Thread Object Diagram
Kernel Process
Kernel Thread
Kernel Thread
![Page 59: OS Organization](https://reader035.fdocuments.us/reader035/viewer/2022062322/56814e2d550346895dbb91f8/html5/thumbnails/59.jpg)
Other Microkernel Process Information
Kernel Process
Kernel Thread
Kernel Thread
Virtual Address SpaceDescriptors
Object Table
ProcessObject
ThreadObjects