The Architecture of an OS Monolithic Operating Systems Structure - - PowerPoint PPT Presentation

the architecture of an os
SMART_READER_LITE
LIVE PREVIEW

The Architecture of an OS Monolithic Operating Systems Structure - - PowerPoint PPT Presentation

The Architecture of an OS Monolithic Operating Systems Structure and Layered Processes Virtual Machine, Library, Exokernel Micro kernel and Client/Server Otto J. Anshus Hybrids University of Troms/Oslo 27.08.03 1


slide-1
SLIDE 1

27.08.03 1

Operating Systems Structure and Processes Otto J. Anshus University of Tromsø/Oslo

27.08.03 2

The Architecture of an OS

  • Monolithic
  • Layered
  • Virtual Machine, Library, Exokernel
  • Micro kernel and Client/Server
  • Hybrids

27.08.03 3

Goals of the architecture

  • OS as Resource Manager
  • OS as Virtual Machine (abstractions)
  • Efficiency, flexibility, size, security, … as

discussed earlier

27.08.03 4

User process

C a l l a s e r v i c e i n O S

Services

Data from network Interrupt handler:

Interrupt Hardware

Operating System Kernel

Service Service Service Service

Start requested service Start (next?) user program

Overhead

  • UL -> KL
  • UL address space -> UL addr. space
slide-2
SLIDE 2

27.08.03 5

Monolithic

  • All kernel routines are

together

  • A system call interface
  • Examples:

– Linux – Most Unix OS – NT (hybrid) Kernel many many things entry User program User program call return

27.08.03 6

Layered Structure

  • Hiding information at

each layer

  • Develop a layer at a time
  • Examples

– THE (6 layers, semaphores, Dijkstra 1968) – MS-DOS (4 layers) Hardware Level 1 Level 2 Level N . . .

27.08.03 7

Microkernel and Client/Server

  • Micro-kernel is “micro”
  • Services are implemented

as user level processes

  • Micro-kernel get services
  • n behalf of users by

messaging with the service processes

  • Example: L4, Nucleus,

Taos, Mach, NT (hybrid)

µ−kernel entry User program Services call return

27.08.03 8

Virtual Machine

"A running program is often referred to as a virtual machine - a machine that doesn't exist as a matter of actual physical reality. The virtual machine idea is itself one of the most elegant in the history of technology and is a crucial step in the evolution of ideas about software. To come up with it, scientists and technologists had to recognize that a computer running a program isn't merely a washer doing laundry. A washer is a washer whatever clothes you put inside, but when you put a new program in a computer, it becomes a new machine.... The virtual machine: A way of understanding software that frees us to think of software design as machine design." From David Gelernter's "Truth, Beauty, and the Virtual Machine," Discover Magazine, September 1997, p. 72.

slide-3
SLIDE 3

27.08.03 9

Virtual Machine

  • Virtual machine monitor

– provide multiple virtual “real” hardware – run different OS codes

  • Example

– IBM VM/370: Started in the 70’s. Check out – virtual 8086 mode – Java VM – VMware – Exokernel

Bare hardware Small kernel VM1 VMn . . . OS1 OSn user user

Exact copies of the bare hardware

Syscall trapped Privileged instructions trapped

Virtual Kernel Mode Kernel Mode User Mode Virtual User Mode

27.08.03 10 27.08.03 11

Virtual 8086

27.08.03 12

Java VM

slide-4
SLIDE 4

27.08.03 13 27.08.03 14

Hardware Support

  • What is the minimal support?
  • 2 modes
  • Exception and interrupt trapping
  • Can virtual machine be protected without such

support?

  • Yes, emulation instead of executing on real machine

27.08.03 15

Pro et Contra

Monolithic Layered VM C/S Micro kernel

  • Many virtual

computers with different OS’es

  • Test of new OS

while production work continues

  • All in all:

flexibility

  • Performance

issues?

  • Complexity

issues?

  • Performance
  • More

unstructured

  • Performance

issues?

  • Clean, less bugs
  • Clear division of

labour

  • More flexible
  • Small means less

bugs+manageable

  • Distributed systems
  • Failure isolation of

services at Kernel Level

  • Flexibility issues?
  • Performance issues?
  • Clear division of

labour

  • Performance

issues?

27.08.03 16

“Truths” on Micro Kernel Flexibility and Performance

  • A micro kernel restricts application level flexibility.
  • Switching overhead kernel-user mode is inherently expensive.
  • Switching address-spaces is costly.
  • IPC is expensive.
  • Micro kernel architectures lead to memory system degradation.
  • Kernel should be portable (on top of a small hardware-

dependent layer).

Taken from J. Liedtke, SOSP 15 paper: ”On micro kernel construction” NO: Can be <50 cycles NO: 6-20 microsec round-trip, 53-500 cycles/IPC one way

slide-5
SLIDE 5

27.08.03 17

Concurrency and Process

  • Problem to solve

– A shared CPU, many I/O devices and lots of interrupts – Users feel they have machine to themselves

  • Answer

– Decompose hard problems into simple ones – Deal with one at a time – Process is such a unit

27.08.03 18

Flow of Execution

Kernel Mode User Mode “Input finished” interrupt P1: Input syscall P1: CPU bound P2: CPU bound Trap handling; Scheduler; Dispatch; Trap handling; Scheduler; Dispatch; Trap handling; Scheduler; Dispatch; Int0x80 Timer 10-100ms (Could have started another process than P1) (Assume R to disk => long wait 10- 100’s ms)

27.08.03 19

Procedure, Co-routine, Thread, Process

  • Procedure, Function, (Sub)Routine
  • Call-execute all-return nesting
  • Co-routine
  • Call-resumes-return
  • Thread (more later)
  • Process

– Single threaded – Multi threaded

User level non preemptive “scheduler” in user code

27.08.03 20

Procedure and Co-routine

Call A; Call B; Call B; 1 1 2 2 Main A B Call A; Call B; Resume A; Resume B; Main A B Resume A; Return Return Never executed “User Yield when finished” “User Yield during execution to share CPU” Return

slide-6
SLIDE 6

27.08.03 21

Process

  • Sequential execution of operations

– No concurrency inside a (single threaded) process – Everything happens sequentially

  • Process state

– Registers – Stack(s) – Main memory – Files in UNIX – Communication ports – Other resources

27.08.03 22

Program and Process

main() { ... foo() ... } foo() { ... }

Program

main() { ... foo() ... } foo() { ... }

Process heap stack

main foo

registers PC

Resources:

  • comm. ports,

files, semaphores

PID

For at least one thread of execution The context

27.08.03 23

Process vs. Program

  • Process > program

– Program is just part of process state – Example: many users can run the same program

  • Process < program

– A program can invoke more than one process – Example: Fork off processes to lookup webster

27.08.03 24

Process State Transitions

Running Blocked Ready S c h e d u l e r d i s p a t c h Wait for resource Resource becomes available Create a process terminate P4 P3 P2 P1

P2 P1 ReadyQueue P4 P3 BlockedQueue

Scheduler Dispatcher Trap Handler Service

Current

Trap Return Handler U s e r L e v e l P r o c e s s e s

KERNEL MULTIPROGRAMMING

  • Uniprocessor: Interleaving

(“pseudoparallelism”)

  • Multiprocessor: Overlapping (“true

paralellism”)

PCB’s Memory resident part

Instruction Pointer (program counter) in the EIP register

slide-7
SLIDE 7

27.08.03 25

Process State Transition

Running Blocked Ready S c h e d u l e r d i s p a t c h W a i t f

  • r

r e s

  • u

r c e Resource becomes available Create a process terminate

27.08.03 26

Process Control Block (Process Table)

  • What

– Process management info

  • State (ready, running, blocked)
  • Registers, PSW, parents, etc

– Memory management info

  • Segments, page table, stats, etc

– I/O and file management

  • Communication ports, directories, file descriptors, etc.

27.08.03 27

Discussion: What needs to be saved and restored

  • n a context switch?
  • Volatile state
  • Program counter (Program Counter (PC) also called Instruction

Pointer (Intel: EIP))

  • Processor status register
  • Other register contents
  • User and kernel stack pointers
  • A pointer to the address space in which the process runs
  • the process’s page table directory

27.08.03 28

…and how?

  • Save(volatile machine state, current process);
  • Load(another process’s saved volatile state);
  • Start(new process);
slide-8
SLIDE 8

27.08.03 29

Threads and Processes

Process Threads Kernel threads Kernel Address Space Kernel Level User Level

Project OpSys

  • Trad. Threads

Processes in individual address spaces