Docsity

Mach System - Operating System - Lecture Slides, Slides of Computer Science

Partial preview of the text

Download Mach System - Operating System - Lecture Slides and more Slides Computer Science in PDF only on Docsity!

1

The Mach System

2

Overall Mach Structure

  • Additional, middle,

layer of operating

system

  • Other O/S’s typically

implemented as user

level O/S’s

Mach microkernel

application level O/S (e.g., UNIX)

User application

5

  • http://developer.apple.com/documentation/Darwin/Concep

tual/KernelProgramming/Architecture/chapter_3_section_ 1.html

Figure 3- Mac OS X kernel architecture (4.4 BSD)

7

Goals of Mach

  • “Simple” kernel
    • Only one way to accomplish kernel programming tasks
  • Diverse hardware support
    • “Multiprocessing”: Tightly coupled or loosely coupled
      • Varying degrees of shared memory access
    • One to thousands of processors
    • Heterogeneous system support
  • Distributed & object-oriented
    • All kernel objects within the system are location independent
  • Integrated memory management & interprocess

communication (IPC)

  • Varying network speeds
  • Extensible microkernel Docsity.com

9

10

Interprocess Communication

  • Ports
    • Microkernel protected communication channel
    • Communication occurs by sending messages to ports
    • Microkernel object reference mechanism
    • Provides access to devices, tasks, threads, memory objects, and processors
    • Allow microkernel objects to transparently reside anywhere in network
    • Threads have port rights (send & receive)
  • Port sets
    • Group of ports sharing a common message queue
    • By receiving messages for a port set, a thread can service multiple ports
    • Similar to select call in BSD Unix

12

“User-Level” Message Server:

NetMsgServer

  • Networking daemon
  • Enables location-independent naming of ports
    • Does not matter which computer a port is on
    • NetMsgServer dynamically resolves the addresses
  • Services
    • Forwards message between computers
    • Network wide name service
      • Tasks can register ports for lookup by tasks on any other computer on network
    • Distributed database of port rights
    • Tracks all rights & out-of-line memory passed in intercomputer messages & arranges for transfers
    • Data conversions (different computer architectures)
    • Proxy ports for passing port rights between computers

14

Mach Messages

  • Data in messages: typed
  • Simple types (integer, float etc)
  • In-line and out-of-line data
  • Out-of-line data: Pointers
    • Kernel interprets these pointers as part of message passing
    • Receiver on same computer
      • Don’t want to necessarily copy message from sender to receiver - Takes time to copy messages
      • Instead, when message contents unchanged, use virtual memory-based technique for improving efficiency - A kind of shared memory solution - “copy-on-write”
    • Receiver on different computer
      • Need to copy data referred to by pointer Docsity.com

16

Mach Memory Objects

  • Memory objects: objects in memory mapped from devices
    • Ports provide operations
    • Transparent remote & shared access
  • “may be backed by user-level memory managers, which take the place of more traditional kernel-incorporated virtual-memory pager found in other operating systems” (p. 874-875)
  • For user processes (i.e., not O/S user-level processes), usually mapped from a disk device - Can implement access to files in this way - Map a series of disk blocks onto memory
  • Can also map other devices to memory
    • Gives “memory mapped I/O”
      • E.g., Writing to a memory address writes to the control register of a device; reading from a memory address reads from the control register of a device

17

User-Level Memory Managers

  • May reject the kernel’s replacement victim if it

knows of a better candidate

  • May monitor the memory object it is backing, and

request pages to be paged out before memory

usage invokes Mach’s pageout daemon

  • Can control order of operations on secondary

storage to enforce consistency constraints

  • Control memory mapped file access

19

Mach I/O System - 1

  • Device management
    • Memory Objects used for mapping devices to memory
      • handled in ‘user level’ processes
    • Non-memory mapped devices handled in microkernel
  • Location-transparent device management
    • Devices are Memory Objects
    • Ports on these devices can be accessed by any task with appropriate rights
  • “User level” I/O can increase performance
    • Avoid data copy between kernel memory space and user level memory space
    • In experiments, performance with “user level” device management at least as good as kernel-level - In some cases performance increased

Mach I/O System - 2

  • Functionally grouped device drivers
  • Screen, console, disk, tape, serial line, Ethernet
    • e.g., Instead of character & block devices
  • Each driver
    • layer(s) of chip independent code
    • minimal device dependent code: in microkernel
    • Example: serial line driver
      • Device independent components
        • open, close, read, write
        • start, stop
        • modem controls
        • interrupt handlers for devices that operate on one-interrupt per character basis
        • send/receive char– polling mode
      • Device dependent components
        • Only operations that manipulate device registers directly 20

22

Process Management

  • Task
    • Contains threads
    • Virtual address space + Port rights ( capability )
  • Threads
    • Running : executing or waiting to be allocated to a processor - Considered to be running even when blocked within kernel (e.g., on a page fault)
    • Suspended : Neither executing on a processor nor waiting to be allocated to a processor. - Used to achieve a type of thread-level synchronization
  • CPU scheduling

23

Mach CPU Scheduling

  • Global & local (single CPU) run queues
    • Thread assigned to processor from a run queue
    • Only threads are scheduled; compete equally for CPU
  • Threads have dynamic priorities 0-
    • Generally equal competition for resources
    • Priority based on exponential average of CPU usage
      • Reduces priority with increasing CPU usage
  • Threads can be “bound” to a CPU
    • Thread will only run on that CPU
    • E.g., for a thread that handles a device associated with that CPU
  • Variable time quantum (processor time per process)
    • Dependent on # processors & # processes