the mach system

20
CS533 - Concepts of Operating Systems 1 The Mach System Presented by Catherine Vilhauer

Upload: curran-horn

Post on 31-Dec-2015

41 views

Category:

Documents


0 download

DESCRIPTION

The Mach System. Presented by Catherine Vilhauer. What is Mach?. First Generation micro-kernel Builds operating system above minimal kernel Kernel provides only fundamental services These services basic but powerful enough to be used on wide range of architectures - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: The Mach System

CS533 - Concepts of Operating Systems 1

The Mach System

Presented by Catherine Vilhauer

Page 2: The Mach System

CS533 - Concepts of Operating Systems 2

What is Mach?

First Generation micro-kernel Builds operating system above minimal kernel Kernel provides only fundamental services These services basic but powerful enough to be

used on wide range of architectures Aids distributed computing and multiprocessing

Page 3: The Mach System

CS533 - Concepts of Operating Systems 3

Design Principles: Based on BSD Unix

Advantages of BSD Unixo Simple programmer interfaceo Easy portabilityo Extensive libraryo Combine utilities via pipes

Disadvantageso Redundant features in kernelo Lack of support for multi-processingo Too many fundamental abstractions to choose from

Page 4: The Mach System

CS533 - Concepts of Operating Systems 4

Mach Goals

Support diverse architectureso With varying degrees of shared memory

Function with varying intercomputer network speeds

Simplified kernel structure Distributed operation Integrated memory management and IPC Heterogenous system support

Page 5: The Mach System

CS533 - Concepts of Operating Systems 5

How Mach Works

BSD UnixAnother

OSWindows

Maybe another

OS Database System

MACH

Tasks and Threads

IPC Virtual Memory

Scheduling

Software Emulation Layer

Microkernel

Page 6: The Mach System

CS533 - Concepts of Operating Systems 6

Mach: Basic Abstractions

Task: execution environmento virtual address spaceo protected access to system resources via portso may contain one or more threads

Thread: basic unit of executiono must run in context of a task

Port: basic object reference mechanismo kernel-protected communication channelo protected by port rights

Port Set: group of ports sharing common message queueMessage: basic method of communicationMemory Object: source of memory

o May be managed by external memory manager

Page 7: The Mach System

CS533 - Concepts of Operating Systems 7

Mach’s Basic Abstractions

Message

Port

Text Region

Port Set

Secondary Storage

Data Region

Program counter

Task

Page 8: The Mach System

CS533 - Concepts of Operating Systems 8

Key Features of the Mach System

Blending of memory management and communication

o Memory management • based on use of memory objects• Memory object represented by port• IPC messages sent to request operations (pagein / pageout)• Because IPC used, memory objects can live on remote systems• Kernel caches contents of memory objects in local memory

o Communication• Message-based kernel so message handling must be efficient• Uses virtual memory remapping (large messages)• Message transfer modifies receiving task’s address space to

include a copy of the message contents• Copy on Write

Page 9: The Mach System

CS533 - Concepts of Operating Systems 9

Advantages of Mach Approach

Increased flexibility in memory management to user programs

Greater generality Improved performance over Unix message

passing Easier task migration

o Since ports are location independent, a task and all its ports can be moved from one machine to the other

o All tasks previously communictated with the moved task can continue to do so because they reference a task by only its ports and communicate via messages

Page 10: The Mach System

CS533 - Concepts of Operating Systems 10

Process Management

Tasks main execution environment Can contain no or many kernel-supported threads Thread synchronization minimal but sufficient

o Threads synchronized via IPC• Messages used to queue requests for resources• Thread receives message if resource available• To return resource thread can send a message to the port• Equivalent to send and receive

o Suspend count kept for thread - multiple suspend calls on a thread but only when an equal number of resume calls made can it wake up

Cthreads

Page 11: The Mach System

CS533 - Concepts of Operating Systems 11

CPU Scheduling

Only threads scheduled (not tasks) Priority scheduling Run-queues

o 32 global run-queues, searched in priority order o Per-processor run-queues for threads bound to

individual processor No central dispatcher

o When idle each processor consults run queueso Local run queue has absolute priority

No fixed-length quantumo Varies inversely with number of threads on system

Page 12: The Mach System

CS533 - Concepts of Operating Systems 12

Interprocess Communication

Two components to Mach IPCo PORTS and MESSAGES

Objects addressed by communications portso Allows location independence and security of

communication Security established by means of ‘rights’

o ‘Right’ = port name and capability (send / receive) on that port

o Only one task with ‘receive’ rightso Many with ‘send’ rights

Page 13: The Mach System

CS533 - Concepts of Operating Systems 13

Interprocess Communication

Portso Protected, bounded queue within kernel

Port sets - a collection of ports.o Useful if one thread is to service requests on multiple ports

Messageso Fixed-length header (destination and reply port, msg length)o Variable number of typed data objectso Data (in-line data) sent in message or as pointero Pointers allow transfer of task address space in one

messageo No copying if on same system! Copy-on-write.

Page 14: The Mach System

CS533 - Concepts of Operating Systems 14

Interprocess Communication

Need way to extend IPC across multiple computers

NetMsgServero Mach’s kernel IPC transfers message to NetMsgServero NetMsgServer then uses network protocol to transfero NetMsgServer on receiving computer uses that kernel’s

IPC to send message to correct destination task.o Uses type info in message to transfer data to

heterogenous machines in understandable way Alternative in form of NORMA

Page 15: The Mach System

CS533 - Concepts of Operating Systems 15

Memory Management

Memory Object principle abstractiono Used to manage secondary storageo Represent files, pipes and other data mapped into

virtual memoryo Instead of traditional approach where kernel provides

management of secondary storage Mach treats it like all other objects

Page 16: The Mach System

CS533 - Concepts of Operating Systems 16

Memory Management (cont’d.)

Mach virtual address space sparse No regular page table

o Less memory storage requiredo Simpler address-space maintenance

User-level memory managers can be used instead

Page 17: The Mach System

CS533 - Concepts of Operating Systems 17

User-Level Memory Managers

Mach takes care of basics onlyo Acts as interface between hardware and user-level

• e.g. receives page faults from hardware• Notifies relevant task (via port) of page fault

o Implements pageout policy (FIFO)o Supplies default Memory Manager in some cases

User-Level Memory Managerso Handle majority of memory management - can page

memoryo System calls used to communicate with kernel for memory

mapping / page-in / page-out / provide page-level lockingo Responsible for consistency of the contents of a memory

object mapped by tasks on different machines

Page 18: The Mach System

CS533 - Concepts of Operating Systems 18

Shared Memory

Shared memory advantageso Provides fast IPCo Reduces file management overheado Supports multiprocessing and database management

Mach supports lean versiono Threads in a task share memoryo Difficult for separate machines to share memory and

maintain data consistency• Consistent shared memory only supported when tasks share

processor - in other cases parent can declare inherited memory to be readable-writable - coordinated through locks

• For external machines, Mach allows external memory managers

Page 19: The Mach System

CS533 - Concepts of Operating Systems 19

Programmer Interface

System callso Equivalent to Unix system call interfaceo How does it do this?o With emulation libraries

• Live in a read-only part of program’s address space• OS calls are translated into subroutine calls

o Have emulated MS-DOS and Macintosh OS’so Lives in address space of program needing its

functionality

Page 20: The Mach System

CS533 - Concepts of Operating Systems 20

Summary

Unix can run on top of Mach in ‘User Space’ Uses lightweight processes Supports multiprocessing and parrallel

computing Messages as communication method Integration of messages with virtual memory Integration of virtual memory with messages Size of kernel reduced Permits OS emulation at user-level