Plan 9 from Bell Labs

                    oraccha
 Plan9          http://d.hatena.ne.jp/oraccha/

2009   8   10                          VM
Plan 9
•   Plan 9       OS

•   9vx Plan 9

•   Plan 9
Plan 9
UNIX
   OS

                         Phil Winterbottom




                         Dave Presotto
        Dennis Ritchie               Rob Pike




                                             1995
Plan 9
           UNIX
                     OS

                 Phil Winterbottom          Jim McKie




                 Dave Presotto
Dennis Ritchie               Rob Pike




                                     1995               2004
Plan 9



•                 BlueGene/P

•   Google Summer of Code

•           International Workshop
Plan 9

“Not only is UNIX dead,
it’s starting to smell really bad.”
              -- Rob Pike, 1991
xterm...
 User




Window               Shell



            ASR-33
Plan 9

  •
  • 9P
  •
•
•   open-read-write-close
UNIX
           Kernel

                  UFS
                            UFS
               Interface

Process          Char       Char
               Interface   device

                 Block     Block
               Interface   device
...
                   UNIX
            UNIX

•
    •       UCB

•   GUI
    •   X            MIT
Socket                   Other file
            Sysctl                   system

Process   Lotsa stuff!                UFS

             VFS         VFS          sysfs
          Interface
            Char            Char
          Interface        device
            Block          Block
          Interface        device
Kernel

                        Server
             Server
Process
            Interface
                        Device
Plan 9
                    9p2000 protocol

              Kernel

                               Server (process)
              Server         for email file system
Process
             Interface
                                Server (process)
                              for local file system



                                   Device
9P
     version
      auth
     attach
      flush
     error
      walk
      open
     create
      read
     write
     clunk
     remove
      stat
     wstat
UNIX     I/O


Plan 9

 •             I/F

 •
Plan 9   UNIX



         root
UNIX
•   9P

•   proc

•
•   rfork clone

•
•   UTF-8
•   i386   AMD64 ARM PowerPC SPARC

•                KVM QEMU    Virtual
    Box VMWare Xen    KVM   lguest



•   MIPS
UNIX            Plan 9
•   Plan9port
    •  Plan 9

    •   v9fs

•   9vx
    • Plan 9

    •
•   Drawterm
    •
9vx
        Plan 9      Plan 9      Plan 9
1       a.out       a.out       a.out


             vx32 sandbox library


             Modified Plan 9 kernel



              Host OS
    (Linux, FreeBSD, MacOS X)
9vx TIPS
•   x86_64                      Mercurial


    -   http://code.google.com/p/vx32/

•   Plan 9

    % 9fs sources
    % cd /n/sources
    % @{cd plan9/386/lib && tar c .} | 
      @{cd /386/lib && tar x}
•   acme:



•   kencc: ANSI C

•   acid:

•   APE: POSIX
man emacs(1)
EMACS(1)

 NAME
        emacs - editor macros

 SYNOPSIS
      emacs [ options ]

 DESCRIPTION
      This page intentionally left blank.

 SOURCE
      MIT

 SEE ALSO
      sam(1), vi(1)

 BUGS
        Yes.
kencc:
  rio/rio.c
 58: enum
 59: {
 60:         Cut,
 61:         Paste,
 62:         Snarf,
 63:         Plumb,
 64:         Send,
 65:         Scroll,
 66: };
 67:
                                         C99
 68: char              *menu2str[] = {
 69: [Cut]             "cut",             [Cut] = “cut”,
 70: [Paste]           "paste",
 71: [Snarf]           "snarf",
 72: [Plumb]           "plumb",
 73: [Send]            "send",
 74: [Scroll]          "scroll",
 75:                   nil
 76: };
kencc:


•   Linux

•     rio/dat.h
    107 struct Mousestate
    108 {
    109         Mouse;
    110         ulong   counter;
    111 };

rio/wind.c
  305: m = (Mousestate){w->mc.Mouse, w->mouse.counter};
Hello, World!
% cat hello.c
#include <u.h>
#include <libc.h>

void main()
{
    print(“Hello, World!n”);
    exits(nil);
}

% 8c hello.c
% 8l -o hello hello.8
% hello
% cat hello.c
#include <u.h>
#include <libc.h>

void main()
{
    print(“Hello, World!n”);
    exits(nil);
}

% 8c hello.c
% 8l -o hello hello.8
% hello
ANSI C/POSIX
% cat hello.c
#include <u.h>
#include <libc.h>

void main()
{
    print(“Hello, World!n”);
    exits(nil);
}

% 8c hello.c
% 8l -o hello hello.8
% hello
% cat hello.c
#include <u.h>
#include <libc.h>

void main()     include/libc.h:
{               1: #pragma lib    “libc.a”
    print(“Hello, World!n”);
                2: #pragma src    “/sys/src/libc”
    exits(nil);
}

% 8c hello.c
% 8l -o hello hello.8
% hello
./hello
% cat hello.c
#include <u.h>
#include <libc.h>

void main()
{
    print(“Hello, World!n”);
    exits(nil);
}

% 8c hello.c
% 8l -o hello hello.8
% hello
% ls /env
'*'	 	 boottime	 'fn#sigexit'	pid	 	 terminal
0	 	 cflag	 	 font		 prompt	 	 timezone
NPROC	 	 cputype	 fs	 rcname	 	 user
                  	    	
apid		 ether0	 	 home		 rootdir	 wctl
                                 	
auth		 facedom	 ifs	 	 service	 wsys
               	                 	
bootargs	 fileserver	 objtype	 status
                              	
bootfile	 'fn#cpu%'	path		 sysname


% cat /env/path
./bin
•
                                   /bin
       % ns   | grep /bin
       bind   /386/bin /bin
       bind   -a /rc/bin /bin
       bind   -a /usr/oraccha/bin/rc /bin
       bind   -a /usr/oraccha/bin/386 /bin

    ※Linux    aufs unionfs
•
    % foo
    foo 151: suicide: sys: trap: page fault pc=0x00001025
    % ps | grep foo
    glenda          151    0:00   0:00        8K Broken   foo



•    acid(1)
    % acid 151
    /proc/151/text: 386 plan 9 executable
       :
    acid: stk()



•                               /proc import
Plan 9
•   Web         http://plan9.bell-labs.com/
    sources/plan9/sys/src/
•                  git                git://github.com/
    ericvh/plan-9.git
       sys -- src
              |-- 9        # kernel
              | |-- pc
              | `-- port
              |-- cmd      # uesr command
              `-- libc     # libc library
Plan9   http://d.hatena.ne.jp/oraccha/

今日から始めるPlan 9 from Bell Labs

  • 1.
    Plan 9 fromBell Labs oraccha Plan9 http://d.hatena.ne.jp/oraccha/ 2009 8 10 VM
  • 2.
  • 3.
    Plan 9 OS • 9vx Plan 9 • Plan 9
  • 4.
    Plan 9 UNIX OS Phil Winterbottom Dave Presotto Dennis Ritchie Rob Pike 1995
  • 5.
    Plan 9 UNIX OS Phil Winterbottom Jim McKie Dave Presotto Dennis Ritchie Rob Pike 1995 2004
  • 6.
    Plan 9 • BlueGene/P • Google Summer of Code • International Workshop
  • 7.
    Plan 9 “Not onlyis UNIX dead, it’s starting to smell really bad.” -- Rob Pike, 1991
  • 8.
  • 9.
    Plan 9 • • 9P •
  • 10.
    • • open-read-write-close
  • 11.
    UNIX Kernel UFS UFS Interface Process Char Char Interface device Block Block Interface device
  • 12.
    ... UNIX UNIX • • UCB • GUI • X MIT
  • 13.
    Socket Other file Sysctl system Process Lotsa stuff! UFS VFS VFS sysfs Interface Char Char Interface device Block Block Interface device
  • 14.
    Kernel Server Server Process Interface Device
  • 15.
    Plan 9 9p2000 protocol Kernel Server (process) Server for email file system Process Interface Server (process) for local file system Device
  • 16.
    9P version auth attach flush error walk open create read write clunk remove stat wstat
  • 17.
    UNIX I/O Plan 9 • I/F •
  • 18.
    Plan 9 UNIX root
  • 19.
    UNIX • 9P • proc • • rfork clone • • UTF-8
  • 20.
    i386 AMD64 ARM PowerPC SPARC • KVM QEMU Virtual Box VMWare Xen KVM lguest • MIPS
  • 21.
    UNIX Plan 9 • Plan9port • Plan 9 • v9fs • 9vx • Plan 9 • • Drawterm •
  • 22.
    9vx Plan 9 Plan 9 Plan 9 1 a.out a.out a.out vx32 sandbox library Modified Plan 9 kernel Host OS (Linux, FreeBSD, MacOS X)
  • 23.
    9vx TIPS • x86_64 Mercurial - http://code.google.com/p/vx32/ • Plan 9 % 9fs sources % cd /n/sources % @{cd plan9/386/lib && tar c .} | @{cd /386/lib && tar x}
  • 24.
    acme: • kencc: ANSI C • acid: • APE: POSIX
  • 25.
    man emacs(1) EMACS(1) NAME emacs - editor macros SYNOPSIS emacs [ options ] DESCRIPTION This page intentionally left blank. SOURCE MIT SEE ALSO sam(1), vi(1) BUGS Yes.
  • 26.
    kencc: rio/rio.c 58: enum 59: { 60: Cut, 61: Paste, 62: Snarf, 63: Plumb, 64: Send, 65: Scroll, 66: }; 67: C99 68: char *menu2str[] = { 69: [Cut] "cut", [Cut] = “cut”, 70: [Paste] "paste", 71: [Snarf] "snarf", 72: [Plumb] "plumb", 73: [Send] "send", 74: [Scroll] "scroll", 75: nil 76: };
  • 27.
    kencc: • Linux • rio/dat.h 107 struct Mousestate 108 { 109 Mouse; 110 ulong counter; 111 }; rio/wind.c 305: m = (Mousestate){w->mc.Mouse, w->mouse.counter};
  • 28.
    Hello, World! % cathello.c #include <u.h> #include <libc.h> void main() { print(“Hello, World!n”); exits(nil); } % 8c hello.c % 8l -o hello hello.8 % hello
  • 29.
    % cat hello.c #include<u.h> #include <libc.h> void main() { print(“Hello, World!n”); exits(nil); } % 8c hello.c % 8l -o hello hello.8 % hello
  • 30.
    ANSI C/POSIX % cathello.c #include <u.h> #include <libc.h> void main() { print(“Hello, World!n”); exits(nil); } % 8c hello.c % 8l -o hello hello.8 % hello
  • 31.
    % cat hello.c #include<u.h> #include <libc.h> void main() include/libc.h: { 1: #pragma lib “libc.a” print(“Hello, World!n”); 2: #pragma src “/sys/src/libc” exits(nil); } % 8c hello.c % 8l -o hello hello.8 % hello
  • 32.
    ./hello % cat hello.c #include<u.h> #include <libc.h> void main() { print(“Hello, World!n”); exits(nil); } % 8c hello.c % 8l -o hello hello.8 % hello
  • 33.
    % ls /env '*' boottime 'fn#sigexit' pid terminal 0 cflag font prompt timezone NPROC cputype fs rcname user apid ether0 home rootdir wctl auth facedom ifs service wsys bootargs fileserver objtype status bootfile 'fn#cpu%' path sysname % cat /env/path ./bin
  • 34.
    /bin % ns | grep /bin bind /386/bin /bin bind -a /rc/bin /bin bind -a /usr/oraccha/bin/rc /bin bind -a /usr/oraccha/bin/386 /bin ※Linux aufs unionfs
  • 35.
    % foo foo 151: suicide: sys: trap: page fault pc=0x00001025 % ps | grep foo glenda 151 0:00 0:00 8K Broken foo • acid(1) % acid 151 /proc/151/text: 386 plan 9 executable : acid: stk() • /proc import
  • 36.
    Plan 9 • Web http://plan9.bell-labs.com/ sources/plan9/sys/src/ • git git://github.com/ ericvh/plan-9.git sys -- src |-- 9 # kernel | |-- pc | `-- port |-- cmd # uesr command `-- libc # libc library
  • 37.
    Plan9 http://d.hatena.ne.jp/oraccha/