200 likes | 217 Views
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
E N D
The Mach System Presented by Catherine Vilhauer CS533 - Concepts of Operating Systems
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 CS533 - Concepts of Operating Systems
Design Principles: Based on BSD Unix • Advantages of BSD Unix • Simple programmer interface • Easy portability • Extensive library • Combine utilities via pipes • Disadvantages • Redundant features in kernel • Lack of support for multi-processing • Too many fundamental abstractions to choose from CS533 - Concepts of Operating Systems
Mach Goals • Support diverse architectures • 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 CS533 - Concepts of Operating Systems
How Mach Works Maybe another OS Software Emulation Layer Another OS Windows Database System BSD Unix Tasks and Threads Virtual Memory IPC Scheduling Microkernel MACH CS533 - Concepts of Operating Systems
Mach: Basic Abstractions Task: execution environment • virtual address space • protected access to system resources via ports • may contain one or more threads Thread: basic unit of execution • must run in context of a task Port: basic object reference mechanism • kernel-protected communication channel • protected by port rights Port Set: group of ports sharing common message queue Message: basic method of communication Memory Object: source of memory • May be managed by external memory manager CS533 - Concepts of Operating Systems
Mach’s Basic Abstractions Text Region Message Port Program counter Data Region Task Port Set SecondaryStorage CS533 - Concepts of Operating Systems
Key Features of the Mach System • Blending of memory management and communication • 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 • 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 CS533 - Concepts of Operating Systems
Advantages of Mach Approach • Increased flexibility in memory management to user programs • Greater generality • Improved performance over Unix message passing • Easier task migration • Since ports are location independent, a task and all its ports can be moved from one machine to the other • 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 CS533 - Concepts of Operating Systems
Process Management • Tasks main execution environment • Can contain no or many kernel-supported threads • Thread synchronization minimal but sufficient • 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 • 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 CS533 - Concepts of Operating Systems
CPU Scheduling • Only threads scheduled (not tasks) • Priority scheduling • Run-queues • 32 global run-queues, searched in priority order • Per-processor run-queues for threads bound to individual processor • No central dispatcher • When idle each processor consults run queues • Local run queue has absolute priority • No fixed-length quantum • Varies inversely with number of threads on system CS533 - Concepts of Operating Systems
Interprocess Communication • Two components to Mach IPC • PORTS and MESSAGES • Objects addressed by communications ports • Allows location independence and security of communication • Security established by means of ‘rights’ • ‘Right’ = port name and capability (send / receive) on that port • Only one task with ‘receive’ rights • Many with ‘send’ rights CS533 - Concepts of Operating Systems
Interprocess Communication • Ports • Protected, bounded queue within kernel • Port sets - a collection of ports. • Useful if one thread is to service requests on multiple ports • Messages • Fixed-length header (destination and reply port, msg length) • Variable number of typed data objects • Data (in-line data) sent in message or as pointer • Pointers allow transfer of task address space in one message • No copying if on same system! Copy-on-write. CS533 - Concepts of Operating Systems
Interprocess Communication • Need way to extend IPC across multiple computers • NetMsgServer • Mach’s kernel IPC transfers message to NetMsgServer • NetMsgServer then uses network protocol to transfer • NetMsgServer on receiving computer uses that kernel’s IPC to send message to correct destination task. • Uses type info in message to transfer data to heterogenous machines in understandable way • Alternative in form of NORMA CS533 - Concepts of Operating Systems
Memory Management • Memory Object principle abstraction • Used to manage secondary storage • Represent files, pipes and other data mapped into virtual memory • Instead of traditional approach where kernel provides management of secondary storage Mach treats it like all other objects CS533 - Concepts of Operating Systems
Memory Management (cont’d.) • Mach virtual address space sparse • No regular page table • Less memory storage required • Simpler address-space maintenance • User-level memory managers can be used instead CS533 - Concepts of Operating Systems
User-Level Memory Managers • Mach takes care of basics only • Acts as interface between hardware and user-level • e.g. receives page faults from hardware • Notifies relevant task (via port) of page fault • Implements pageout policy (FIFO) • Supplies default Memory Manager in some cases • User-Level Memory Managers • Handle majority of memory management - can page memory • System calls used to communicate with kernel for memory mapping / page-in / page-out / provide page-level locking • Responsible for consistency of the contents of a memory object mapped by tasks on different machines CS533 - Concepts of Operating Systems
Shared Memory • Shared memory advantages • Provides fast IPC • Reduces file management overhead • Supports multiprocessing and database management • Mach supports lean version • Threads in a task share memory • 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 CS533 - Concepts of Operating Systems
Programmer Interface • System calls • Equivalent to Unix system call interface • How does it do this? • With emulation libraries • Live in a read-only part of program’s address space • OS calls are translated into subroutine calls • Have emulated MS-DOS and Macintosh OS’s • Lives in address space of program needing its functionality CS533 - Concepts of Operating Systems
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 CS533 - Concepts of Operating Systems