RESOURCE MANAGEMENT - TU Dresdenos.inf.tu-dresden.de/Studium/KMB/WS2012/07-Resource-Manageme… ·...

49
Faculty of Computer Science Institute of Systems Architecture, Operating Systems Group MICHAEL ROITZSCH RESOURCE MANAGEMENT

Transcript of RESOURCE MANAGEMENT - TU Dresdenos.inf.tu-dresden.de/Studium/KMB/WS2012/07-Resource-Manageme… ·...

Page 1: RESOURCE MANAGEMENT - TU Dresdenos.inf.tu-dresden.de/Studium/KMB/WS2012/07-Resource-Manageme… · all kernel bookkeeping for the object uses the underlying physical memory no implicit

Faculty of Computer Science Institute of Systems Architecture, Operating Systems Group

MICHAEL ROITZSCH

RESOURCE MANAGEMENT

Page 2: RESOURCE MANAGEMENT - TU Dresdenos.inf.tu-dresden.de/Studium/KMB/WS2012/07-Resource-Manageme… · all kernel bookkeeping for the object uses the underlying physical memory no implicit

TU Dresden MOS: Resource Management

AGENDA

2

■ done: time, drivers

■ today: misc. resources

■ architectures for resource management

■ solutions for specific resources

■ capabilities to manage resource access

■ upcoming: applications, legacy support

■ next week: exercise first in INF E069

Page 3: RESOURCE MANAGEMENT - TU Dresdenos.inf.tu-dresden.de/Studium/KMB/WS2012/07-Resource-Manageme… · all kernel bookkeeping for the object uses the underlying physical memory no implicit

TU Dresden MOS: Resource Management

KERNEL RESOURCES

3

Page 4: RESOURCE MANAGEMENT - TU Dresdenos.inf.tu-dresden.de/Studium/KMB/WS2012/07-Resource-Manageme… · all kernel bookkeeping for the object uses the underlying physical memory no implicit

TU Dresden MOS: Resource Management

PROBLEM

4

■ kernel needs memory for its abstractions

■ tasks: page tables

■ threads: kernel-TCB

■ capability tables

■ IPC wait queues

■ mapping database

■ kernel memory is limited

■ opens the possibility of DoS attacks

Page 5: RESOURCE MANAGEMENT - TU Dresdenos.inf.tu-dresden.de/Studium/KMB/WS2012/07-Resource-Manageme… · all kernel bookkeeping for the object uses the underlying physical memory no implicit

TU Dresden MOS: Resource Management

IDEA■ memory management policy should not

be in the kernel

■ account all memory to the application it is needed for (directly or indirectly)

■ kernel provides memory control mechanism

■ exception for bootstrapping:initial kernel memory is managed by kernel

5

Page 6: RESOURCE MANAGEMENT - TU Dresdenos.inf.tu-dresden.de/Studium/KMB/WS2012/07-Resource-Manageme… · all kernel bookkeeping for the object uses the underlying physical memory no implicit

TU Dresden MOS: Resource Management

SOLUTION■ untyped memory in seL4

■ all physical memory unused after bootstrap is represented by untyped memory capabilities

■ can be granted, split or retyped

■ restricted to powers of 2 (see flexpages)

■ initial resource manager gets all (see σ0)

■ user code decides how to use them6

Page 7: RESOURCE MANAGEMENT - TU Dresdenos.inf.tu-dresden.de/Studium/KMB/WS2012/07-Resource-Manageme… · all kernel bookkeeping for the object uses the underlying physical memory no implicit

TU Dresden MOS: Resource Management

SOLUTION■ application retype UM to kernel objects

■ TCB, endpoint, CNode, VNode, frame, interrupt

■ all kernel bookkeeping for the object uses the underlying physical memory

■ no implicit memory allocation by the kernel

■ retyping and splitting is remembered in capability derivation tree

■ revoking recursively destroys all derived capabilities and kernel objects

7

Page 8: RESOURCE MANAGEMENT - TU Dresdenos.inf.tu-dresden.de/Studium/KMB/WS2012/07-Resource-Manageme… · all kernel bookkeeping for the object uses the underlying physical memory no implicit

TU Dresden MOS: Resource Management

PRINCIPLE

8

separate enforcement and management

Page 9: RESOURCE MANAGEMENT - TU Dresdenos.inf.tu-dresden.de/Studium/KMB/WS2012/07-Resource-Manageme… · all kernel bookkeeping for the object uses the underlying physical memory no implicit

TU Dresden MOS: Resource Management

ARCHITECTURES

9

Page 10: RESOURCE MANAGEMENT - TU Dresdenos.inf.tu-dresden.de/Studium/KMB/WS2012/07-Resource-Manageme… · all kernel bookkeeping for the object uses the underlying physical memory no implicit

TU Dresden MOS: Resource Management

SPECTRUM

10

high-level resource abstractionsimplicit management

low-level resource abstractionsexplicit management

mo

no

lith

reso

urc

e co

nta

iner

s

exo

kern

el

mu

ltis

erve

r

Page 11: RESOURCE MANAGEMENT - TU Dresdenos.inf.tu-dresden.de/Studium/KMB/WS2012/07-Resource-Manageme… · all kernel bookkeeping for the object uses the underlying physical memory no implicit

TU Dresden MOS: Resource Management

MONOLITHS

11

■ enforcement and management implicitly tied to process abstraction

■ resource containers were proposed to make resource management explicit

■ bags of resources assigned to subsystems

isolation accounting

processprocess

protection domain resource container

Page 12: RESOURCE MANAGEMENT - TU Dresdenos.inf.tu-dresden.de/Studium/KMB/WS2012/07-Resource-Manageme… · all kernel bookkeeping for the object uses the underlying physical memory no implicit

TU Dresden MOS: Resource Management

EXOKERNEL

12

Exokernel

Library OS

Application

Enforcement

Management

Page 13: RESOURCE MANAGEMENT - TU Dresdenos.inf.tu-dresden.de/Studium/KMB/WS2012/07-Resource-Manageme… · all kernel bookkeeping for the object uses the underlying physical memory no implicit

TU Dresden MOS: Resource Management

DESIGN

13

■ provide primitives at the lowest possible level necessary for protection

■ use physical names wherever possible

■ resource management primitives:

■ explicit allocation

■ exposed revocation

■ protected sharing

■ ownership tracking

Page 14: RESOURCE MANAGEMENT - TU Dresdenos.inf.tu-dresden.de/Studium/KMB/WS2012/07-Resource-Manageme… · all kernel bookkeeping for the object uses the underlying physical memory no implicit

TU Dresden MOS: Resource Management

CONSEQUENCES■ each application can use its own library OS

■ library OS’es cannot trust each other

■ no central management for global resources

■ think of a file system

■ kernel manages disk ownership with block granularity

■ each library OS comes with its own filesystem implementation

■ one partition per application?14

Page 15: RESOURCE MANAGEMENT - TU Dresdenos.inf.tu-dresden.de/Studium/KMB/WS2012/07-Resource-Manageme… · all kernel bookkeeping for the object uses the underlying physical memory no implicit

TU Dresden MOS: Resource Management

SHARING■ invariants in shared resources must be

maintained

■ four mechanisms provided by the exokernel

■ software regions for sub-page memory protection, allows to share state

■ capabilities for access control

■ critical sections

■ wakeup predicates: code downloaded into the kernel for arbitrary checks

15

Page 16: RESOURCE MANAGEMENT - TU Dresdenos.inf.tu-dresden.de/Studium/KMB/WS2012/07-Resource-Manageme… · all kernel bookkeeping for the object uses the underlying physical memory no implicit

TU Dresden MOS: Resource Management

MULTISERVER

16

Low-Level Resource Manager

ApplicationHigher-Level Resource Manager

Client-Libs

L4 Microkernel

works on monolithic kernels too

Page 17: RESOURCE MANAGEMENT - TU Dresdenos.inf.tu-dresden.de/Studium/KMB/WS2012/07-Resource-Manageme… · all kernel bookkeeping for the object uses the underlying physical memory no implicit

TU Dresden MOS: Resource Management

LEVELS■ different abstraction levels for resources

17

basic resourcesmemory, CPU,

IO-ports, interrupts

hardwareblock device, framebuffer,

network card

compound resources

file, GUI window,TCP session

Page 18: RESOURCE MANAGEMENT - TU Dresdenos.inf.tu-dresden.de/Studium/KMB/WS2012/07-Resource-Manageme… · all kernel bookkeeping for the object uses the underlying physical memory no implicit

TU Dresden MOS: Resource Management

HIERARCHIES■ applications can access resource on the

abstraction level they need

■ servers implementing a resource can use other, lower-level resources

■ isolation allows managers to provide real-time guarantees for their specific resource

■ DROPS:Dresden Real-time OPerating System

18

Page 19: RESOURCE MANAGEMENT - TU Dresdenos.inf.tu-dresden.de/Studium/KMB/WS2012/07-Resource-Manageme… · all kernel bookkeeping for the object uses the underlying physical memory no implicit

TU Dresden MOS: Resource Management

EXAMPLES

19

Page 20: RESOURCE MANAGEMENT - TU Dresdenos.inf.tu-dresden.de/Studium/KMB/WS2012/07-Resource-Manageme… · all kernel bookkeeping for the object uses the underlying physical memory no implicit

TU Dresden MOS: Resource Management

ANKH

20

■ driver for physical network card

■ built with DDE using Linux 2.6 drivers

■ provides multiple virtual network cards

■ implements a simple virtual bridge

Ankh

lwip

wget

Page 21: RESOURCE MANAGEMENT - TU Dresdenos.inf.tu-dresden.de/Studium/KMB/WS2012/07-Resource-Manageme… · all kernel bookkeeping for the object uses the underlying physical memory no implicit

TU Dresden MOS: Resource Management

wget

LWIP

21

■ light-weight IP Stack

■ TCP/IP, UDP, ICMP

Ankh

lwip

Page 22: RESOURCE MANAGEMENT - TU Dresdenos.inf.tu-dresden.de/Studium/KMB/WS2012/07-Resource-Manageme… · all kernel bookkeeping for the object uses the underlying physical memory no implicit

TU Dresden MOS: Resource Management

WGET

22

■ clients can use standard BSD socket interface

Ankh

lwip

wget

Page 23: RESOURCE MANAGEMENT - TU Dresdenos.inf.tu-dresden.de/Studium/KMB/WS2012/07-Resource-Manageme… · all kernel bookkeeping for the object uses the underlying physical memory no implicit

TU Dresden MOS: Resource Management

WINDHOEK

23

■ IDE driver to access hard disks

■ includes disk request scheduling

■ based on DDE

■ provides block device

■ ongoing work on USB block devices

Windhoek

Filesystem

L4Re VFS

Page 24: RESOURCE MANAGEMENT - TU Dresdenos.inf.tu-dresden.de/Studium/KMB/WS2012/07-Resource-Manageme… · all kernel bookkeeping for the object uses the underlying physical memory no implicit

TU Dresden MOS: Resource Management

L4Re VFS

FILESYSTEM

24

■ no real one implemented yet

■ we have a tmpfs using RAM as backing store

■ VPFS: securely reuse a Linux filesystem

Windhoek

Filesystem

Page 25: RESOURCE MANAGEMENT - TU Dresdenos.inf.tu-dresden.de/Studium/KMB/WS2012/07-Resource-Manageme… · all kernel bookkeeping for the object uses the underlying physical memory no implicit

TU Dresden MOS: Resource Management

L4RE VFS

25

■ hierarchical name space

■ connects subtrees to different backend servers

■ aka mountingWindhoek

Filesystem

L4Re VFS

Page 26: RESOURCE MANAGEMENT - TU Dresdenos.inf.tu-dresden.de/Studium/KMB/WS2012/07-Resource-Manageme… · all kernel bookkeeping for the object uses the underlying physical memory no implicit

TU Dresden MOS: Resource Management

MAG

26

■ multiplexes the frame buffer

■ no virtual desktops, but window merging

■ details in the legacy / security lectures

mag

DOpE

Terminal

Page 27: RESOURCE MANAGEMENT - TU Dresdenos.inf.tu-dresden.de/Studium/KMB/WS2012/07-Resource-Manageme… · all kernel bookkeeping for the object uses the underlying physical memory no implicit

TU Dresden MOS: Resource Management

Terminal

DOPE

27

■ widget drawing server

■ handles mouse and keyboard input

■ can also operate on raw framebuffer

■ real-time capablemag

DOpE

Page 28: RESOURCE MANAGEMENT - TU Dresdenos.inf.tu-dresden.de/Studium/KMB/WS2012/07-Resource-Manageme… · all kernel bookkeeping for the object uses the underlying physical memory no implicit

TU Dresden MOS: Resource Management

TERMINAL

28

■ DOpE client providing a terminal window

■ VT100 emulation

■ can support readline applications

■ shell

■ python

mag

DOpE

Terminal

Page 29: RESOURCE MANAGEMENT - TU Dresdenos.inf.tu-dresden.de/Studium/KMB/WS2012/07-Resource-Manageme… · all kernel bookkeeping for the object uses the underlying physical memory no implicit

TU Dresden MOS: Resource Management

RESOURCE ACCESS

29

Page 30: RESOURCE MANAGEMENT - TU Dresdenos.inf.tu-dresden.de/Studium/KMB/WS2012/07-Resource-Manageme… · all kernel bookkeeping for the object uses the underlying physical memory no implicit

TU Dresden MOS: Resource Management

EXAMPLE

30

Service

Manager

Worker A Worker B

Page 31: RESOURCE MANAGEMENT - TU Dresdenos.inf.tu-dresden.de/Studium/KMB/WS2012/07-Resource-Manageme… · all kernel bookkeeping for the object uses the underlying physical memory no implicit

TU Dresden MOS: Resource Management

GOOGLE CHROME

31

■ separate processes

■ chrome parent

■ sandboxes for tabs

■ implementation on Linux: glorious mix of chroot(), clone() and setuid()

■ there must be a better way…

Page 32: RESOURCE MANAGEMENT - TU Dresdenos.inf.tu-dresden.de/Studium/KMB/WS2012/07-Resource-Manageme… · all kernel bookkeeping for the object uses the underlying physical memory no implicit

TU Dresden MOS: Resource Management

TWO WORLDS

32

POSIX POLA

operations allowed by default

nothing allowed by default

some limited restrictions apply

every right must be granted

ambient authority explicit authority

Page 33: RESOURCE MANAGEMENT - TU Dresdenos.inf.tu-dresden.de/Studium/KMB/WS2012/07-Resource-Manageme… · all kernel bookkeeping for the object uses the underlying physical memory no implicit

TU Dresden MOS: Resource Management

L4RE

33

L4Re — the L4 Runtime Environmentset of libraries and system services on

top of the Fiasco.OC microkernel

Page 34: RESOURCE MANAGEMENT - TU Dresdenos.inf.tu-dresden.de/Studium/KMB/WS2012/07-Resource-Manageme… · all kernel bookkeeping for the object uses the underlying physical memory no implicit

TU Dresden MOS: Resource Management

CAPABILITIES

34

■ Fiasco.OC and L4Re form anobject-capability system

■ actors in the system are objects

■ objects have local state and behavior

■ capabilities are references to objects

■ any object interaction requires a capability

■ unseparable and unforgeable combination of reference and access right

Page 35: RESOURCE MANAGEMENT - TU Dresdenos.inf.tu-dresden.de/Studium/KMB/WS2012/07-Resource-Manageme… · all kernel bookkeeping for the object uses the underlying physical memory no implicit

TU Dresden MOS: Resource Management

CAPABILITIES

35

Fiasco.OC

Task A

A B C D E

Task BC

apab

ility

Tab

le 12345 C

apab

ility

Tab

le12345

Page 36: RESOURCE MANAGEMENT - TU Dresdenos.inf.tu-dresden.de/Studium/KMB/WS2012/07-Resource-Manageme… · all kernel bookkeeping for the object uses the underlying physical memory no implicit

TU Dresden MOS: Resource Management

HOW TO USE?

36

■ invocation of any object requires a capability to that object

■ no global names

■ no sophisticated rights representation beyond capability ownership

■ just four rights bits on objects

■ C++ language integration

■ capabilities passed as message payload

Page 37: RESOURCE MANAGEMENT - TU Dresdenos.inf.tu-dresden.de/Studium/KMB/WS2012/07-Resource-Manageme… · all kernel bookkeeping for the object uses the underlying physical memory no implicit

TU Dresden MOS: Resource Management

CAP TRANSFER

37

X

Task A Task B

Page 38: RESOURCE MANAGEMENT - TU Dresdenos.inf.tu-dresden.de/Studium/KMB/WS2012/07-Resource-Manageme… · all kernel bookkeeping for the object uses the underlying physical memory no implicit

TU Dresden MOS: Resource Management

CAP TRANSFER

37

X

Task A Task B

1 2 3 4 5 1 2 3 4 5

Page 39: RESOURCE MANAGEMENT - TU Dresdenos.inf.tu-dresden.de/Studium/KMB/WS2012/07-Resource-Manageme… · all kernel bookkeeping for the object uses the underlying physical memory no implicit

TU Dresden MOS: Resource Management

CAP TRANSFER

37

X

Task A Task B

1 2 3 4 5 1 2 3 4 5

Page 40: RESOURCE MANAGEMENT - TU Dresdenos.inf.tu-dresden.de/Studium/KMB/WS2012/07-Resource-Manageme… · all kernel bookkeeping for the object uses the underlying physical memory no implicit

TU Dresden MOS: Resource Management

EXAMPLE

38

Manager

Service

Worker A Worker B

Page 41: RESOURCE MANAGEMENT - TU Dresdenos.inf.tu-dresden.de/Studium/KMB/WS2012/07-Resource-Manageme… · all kernel bookkeeping for the object uses the underlying physical memory no implicit

TU Dresden MOS: Resource Management

EXAMPLE

38

Manager

Service

Worker A Worker B

Page 42: RESOURCE MANAGEMENT - TU Dresdenos.inf.tu-dresden.de/Studium/KMB/WS2012/07-Resource-Manageme… · all kernel bookkeeping for the object uses the underlying physical memory no implicit

TU Dresden MOS: Resource Management

EXAMPLE

38

Manager

Service

Worker A Worker B

Page 43: RESOURCE MANAGEMENT - TU Dresdenos.inf.tu-dresden.de/Studium/KMB/WS2012/07-Resource-Manageme… · all kernel bookkeeping for the object uses the underlying physical memory no implicit

TU Dresden MOS: Resource Management

EXAMPLE

39

Manager

Service

Worker A Worker B

mag

Page 44: RESOURCE MANAGEMENT - TU Dresdenos.inf.tu-dresden.de/Studium/KMB/WS2012/07-Resource-Manageme… · all kernel bookkeeping for the object uses the underlying physical memory no implicit

TU Dresden MOS: Resource Management

mag

MAG■ factory for new

framebuffer sessions

■ session object

■ backing store memory

■ view: visible rectangle on the backing store

■ metadata, refresh method

■ How does it appear on the screen?

40

Factory S S

Manager

Page 45: RESOURCE MANAGEMENT - TU Dresdenos.inf.tu-dresden.de/Studium/KMB/WS2012/07-Resource-Manageme… · all kernel bookkeeping for the object uses the underlying physical memory no implicit

TU Dresden MOS: Resource Management

mag

MAG■ hardware framebuffer is

memory with side effect

■ all memory is initially mapped to the root task

■ framebuffer driver

■ find framebuffer memory

■ wrap in FB-interface

■ same interface as mag’s

41

Factory S S

Memory

moe

fb-drv

Page 46: RESOURCE MANAGEMENT - TU Dresdenos.inf.tu-dresden.de/Studium/KMB/WS2012/07-Resource-Manageme… · all kernel bookkeeping for the object uses the underlying physical memory no implicit

TU Dresden MOS: Resource Management

INTERFACES■ virtualizable interfaces

■ L4Re uses one interface per resource

■ independent of the implementation

■ servers can (re-)implement any interface

■ the kernel is a special server: provides low-level objects that need CPU privileges

■ minimal policy

■ userland servers can augment

42

Page 47: RESOURCE MANAGEMENT - TU Dresdenos.inf.tu-dresden.de/Studium/KMB/WS2012/07-Resource-Manageme… · all kernel bookkeeping for the object uses the underlying physical memory no implicit

TU Dresden MOS: Resource Management

EXAMPLES

43

fb-drv

mag

kernel

balancer

Graphics Thread scheduling

pong multithreaded application

Page 48: RESOURCE MANAGEMENT - TU Dresdenos.inf.tu-dresden.de/Studium/KMB/WS2012/07-Resource-Manageme… · all kernel bookkeeping for the object uses the underlying physical memory no implicit

TU Dresden MOS: Resource Management

CONCLUSION

■ all services provided as objects

■ uniform access control with capabilities

■ invocation is the only system call

■ virtualizable: all interfaces can be interposed

■ resource refinement and multiplexing transparent to clients

44

Page 49: RESOURCE MANAGEMENT - TU Dresdenos.inf.tu-dresden.de/Studium/KMB/WS2012/07-Resource-Manageme… · all kernel bookkeeping for the object uses the underlying physical memory no implicit

TU Dresden MOS: Resource Management

SUMMARY■ kernel resource management

■ basic resource management concepts

■ resource containers

■ exokernel

■ multiserver

■ management details for specific resources

■ object capabilities and virtualizable interfaces

45