1 the mach system "operating systems concepts, sixth edition" by abraham silberschatz,...
TRANSCRIPT
1
THE MACH SYSTEM
"Operating Systems Concepts, Sixth Edition" by Abraham Silberschatz, Peter Baer Galvin, and Greg Gagne
Presentation by Betsy Kavali
3
History of Mach
Derived its communication system and philosophy from Accent.
BSD Unix support➢ Originally constructed inside 4.2BSD kernel.➢ Replaced one piece at a time.
Started with an effort to support multiprocessors.
4
Goals of Mach
➢ Support diverse architectures
- UMA, NUMA, NORMA➢ Simplified kernel structure➢ Compatibility with UNIX, Ease of use.➢ Integrate memory management and IPC➢ Distributed Operation and Varying network speed➢ Heterogeneous System support.➢ Object-oriented design
5
System Components
• Task• Thread• Port• Port set• Message• Memory object
task
text region
threadsport
port set
message
data region
memory object
secondarystorage
6
System Components
Task: Execution environment Contains one or more threads Provides a protection domain, a protected access to system resources via portsThread: unit of computation (execution) must run in the context of a task all threads in a task share ports, memory, etc. process = task + thread
7
System ComponentsPort: Kernel protected communication channel.Mechanism to reference an object.Port set:Group of ports sharing a common message queueMessage:Basic method of communication between threads in different tasks.Memory objects: storage unit,Map all or part of object into address spaceThey are accessed by tasks using ports
8
Process Management
Tasks ➢ Parent task creates children tasks➢ New Tasks contain one thread initially.➢ Suspending a task, suspends threads in the task.Threads➢ Suspending/resuming a thread does not suspend/resume the task.➢ Threads share the address space of the task , hence the need for synchronization
9
Process Management - Threads
User Level Threads➢ Mach provides a basic kernel interface for managing
threads➢ C threads package is built on top of Mach's
primitives. Influenced POSIX P threads standard.
10
Process Management - Threads
Thread control routines :
Create : give function to execute and its parameters
Destroy : Destroys the thread and returns a value to the creating thread.
Wait : for a specific thread to terminate then continue the calling thread
Yield : Thread yields use of a processor.
11
Process Management - Threads
Mutual Exclusion using spin locks. Mutual exclusion Routines are:
Mutex_lock, mutex_unlock, mutex_alloc, mutex_free. Synchronization through condition variables(wait,
signal), the associated routines are: Condition_alloc, condition_free
12
CPU Scheduler➢ Only threads are scheduled, tasks are ignored.➢ Each thread will have a priority number(0 -127)➢ Dynamic thread priority - The lowest priority thread is the
one with the most recent large CPU usage.➢ Global run queues + per processor local run queues➢ Processors consult run queues to select next thread:
the local queue first, then the global queue➢ Thread time quantum varies inversely with total
number of threads
13
Exception Handling➢ The exception handler is just another thread in the task.➢ RPC messages: synchronize & communicate between victim
and handler.
Two different granularities of exception handling.
Error Handlers: Perform recovery actions in response to an exception and resume execution of the thread.
Debuggers: Examine the state of an entire application to investigate why an exception occurred and/or why the program is misbehaving.
14
Exception handling proceeds as follows.
1. Victim: raise – RPC message sent to the handler.
2. Victim: wait -- synchronize with completion of exception
handling.
3. Handler: catch -- receive notification, identifies the
exception and the victim
4. Handler: take actions
• clear -- clear exception causing victim to return from wait.
• terminate -- cause termination of victim thread.
15
InterProcess Communication - IPC
Location Independent IPC
The two components of IPC are
1. Ports
2. Messages
Ports :
Protected bounded queue within the kernel
Capability: send or receive ``right‘’
16
InterProcess Communication - IPC
System calls for port functionality.
Allocate: new port in a task(task decides the rights of the port)
Deallocate: revoke tasks access rights to a port.
Get current port status.
Create a back up port
-port sets : Useful when one thread has to service requests coming on multiple ports.
17
InterProcess Communication - IPC
Messages :
Header + one or more typed data objects
Header : contains destination port name, reply port
name, message length
In-line message data : typed data, port rights
Out-of-line data: pointers to data
18
InterProcess Communication - IPCNetMsgServer Used when receiver port is not on the kernel’s
computer User-level daemon that forwards messages
between hosts Provides Name Service Primitive -Allows tasks
networkwide to register ports for lookup It is protocol independent.
20
Memory Management.
Memory Object: Mach's basic abstraction of physical memory, an
object. Secondary storage or data that are mapped into
virtual-memory (Files, pipes) Served by user-Level memory managers.
21
Memory management
User-Level memory manager -
Memory can be paged by user-written memory managers
Mach has no knowledge of memory object contents.
Default memory manager - Used in circumstances when there is no local manager.
22
Blend of Memory and IPC
This is an unique feature of Mach, and key to the system's efficiency.
Memory management using IPC.
A memory object is represented as a port.
To request operations on this object, IPC messages are sent to this port.
Because IPC is used, memory object may reside on remote systems, Kernel caches the contents.
23
Blend of Memory and IPC
IPC using memory management techniques:
Here messages are passed by moving pointers to shared-memory objects.Virtual-memory remapping to transfer large contents using virtual copy / copy-on-write techniques
25
Programmer Interface
System-call level:Implemented via emulation libraries and serversC Threads package:C language interface to Mach threads primitivesNot suitable for NORMA systems
Interface/Stub generator (MIG):Input = Interface definition (declarations of variables, types & procedures)Output = RPC interface code
26
Conclusion
➢ Micro kernel
➢ Few simple abstractions
➢Higher level OS functionality built in user level servers➢ Focus on communication facilities
➢ Mach pioneered many concepts.