Introduction
 

UNIX on Mungi



Charles Gray

cgray@cse.unsw.edu.au

Introduction
1

UNIX on Mungi
 
  • UNIX has many apps we want

  • I'm not going to re-write and maintain them

  • There's nothing fundamentally wrong with the UNIX model
  • You have to write to some abstractions

UNIX on Mungi
2

Troll
 

WE DO NOT WANT TO RE-WRITE ALL OUR APPS!!!

Nor do we want to change the way we write apps

UNIX on Mungi :: Troll
3

What is UNIX?
 
  • MASOS by definition
  • fork()

  • Files and Pipes

  • Signals

  • Job Control

UNIX on Mungi :: What is UNIX?
4

What is fundamentally wrong with UNIX?
 
  • Job Control

  • setuid

  • root

  • ioctl

  • IPC Primitives

  • 'All or Nothing' protection

UNIX on Mungi :: What is fundamentally wrong with UNIX?
5

UNIX Files in Mungi
 
  • Currently we have a file library

  • Used quite extensively on Mungi boot

  • Files are a single Mungi object
  • 10mb ought to be enough for any file!

  • Is this right??

UNIX on Mungi :: Files
6

Files as objects
 
  • Nice and simple

  • You can run ELF files in place etc.

  • Interracts well with other Mungi apps
  • Not that we have a lot...

  • Can't support arbitrary length files

UNIX on Mungi :: Files :: Files as objects
7

Segmented Files
 
  • Create a memory filesystem

  • The 'file' is a memory inode

  • Pointers to each chunk of data around the SAS

  • A lot more work

  • Introduces race conditions

  • A contiguous view can be produced with VM tricks

UNIX on Mungi :: Files :: Segmented Files
8

So which is better?
 
UNIX on Mungi :: Files :: So which is better?
9

fork()
 
  • Fork is horrible

  • No one likes programming it

  • Makes benchmarks and kernel code easier
  • and that's about it

  • WARNING: hacks ahead

fork()
10

fork() to exec
 
  • Most programs fork() to exec()

  • Lazy programmers modify the stack and heap

  • We can't just let the caller's data get trashed... can we?
  • ucLinux hack

fork() :: fork() to exec
11

Steps to fork()
 
  • Caller backs up stack and heap using COW

  • Caller creates callee thread and blocks

  • Callee runs until it calls exec()

  • Callee unblocks caller before jumping

  • Caller restores original stack and heap

fork() :: Steps to fork()
12

Problems
 
  • It's a hack

  • Buggy code can still access the caller PD

  • No caller/callee communication between fork() and exec()

  • Callee is under control of the caller
  • No kernel guarantees. setuid problems?

fork() :: Problems
13

fork() to fork()
 
  • Some programs want fork() semantics
  • apache, squid, shells

  • Often for the wrong reasons
  • Threads, select()

fork() :: fork() to fork()
14

Steps to fork() (2)
 
  • Caller duplicates stack and heap

  • Caller creates callee with modified stack and data pointers

  • Requires compiler hacks

fork() :: fork() to fork() :: Steps to fork() (2)
15

Pipes on Mungi
 
  • UNIX uses pipes for a lot of things:

    • stdin/stdout

    • devices

    • IPC

    • Sockets

Pipes on Mungi
16

Emulating pipes
 
  • UNIX has a blocking read/write model

  • Mungi has a dispatch/comletion callback model

  • Can we emulate them?

Pipes on Mungi :: Emulating pipes
17

Yes!
 
  • PDX makes it easy

  • Threads can migrate into your PD at any time

  • Just move kernel buffers and locks into each PD

  • select() becomes easy

Pipes on Mungi :: Emulating pipes :: Yes!
18

Then what?
 
  • Once we have UNIX emulation we can...

    • Port our favourite Linux distro (debian!)

    • Have a distributed/persistent UNIX

    • Beat the MOSIX and beowulf guys

    • Run fortune

Then what?
19

End
 
Questions?
End
20