plan 9 from bell labs - university of rochestersandhya/csc256/seminars/liddell_plan9.pdf · i use...

30
Outline Introduction Design Implementation Conclusion References Plan 9 from Bell Labs Kyle Liddell December 9, 2008 Kyle Liddell Plan 9 from Bell Labs

Upload: truongthuan

Post on 30-Apr-2018

216 views

Category:

Documents


0 download

TRANSCRIPT

OutlineIntroduction

DesignImplementation

ConclusionReferences

Plan 9 from Bell Labs

Kyle Liddell

December 9, 2008

Kyle Liddell Plan 9 from Bell Labs

OutlineIntroduction

DesignImplementation

ConclusionReferences

IntroductionWhat is Plan 9?

DesignOverviewDistributed Design AspectsUNIX Design Simplification

ImplementationPlan 9 KernelNetwork Protocol

Conclusion

References

Kyle Liddell Plan 9 from Bell Labs

OutlineIntroduction

DesignImplementation

ConclusionReferences

What is Plan 9?

What is Plan 9?

I UNIX-like distributed operating system

I Developed at Bell Labs

I Open source

Kyle Liddell Plan 9 from Bell Labs

OutlineIntroduction

DesignImplementation

ConclusionReferences

What is Plan 9?

History

I Initial work in late 1980s, with first version released in 1992,only available to universities

I Version 2, 1995, available to anyone, for a fee

I Version 3, 2000, as open source

I Version 4, 2002, used new 9P network protocol, new fileservers

I Currently, nightly builds are available

Kyle Liddell Plan 9 from Bell Labs

OutlineIntroduction

DesignImplementation

ConclusionReferences

What is Plan 9?

Why Plan 9?

I “build a UNIX out of a lot of little systems, not a system outof a lot of little UNIXes”

I Use networks of inexpensive machines more effectively

I Centralize administration, maintenance tasks

I Eliminate outdated UNIX components

Kyle Liddell Plan 9 from Bell Labs

OutlineIntroduction

DesignImplementation

ConclusionReferences

OverviewDistributed Design AspectsUNIX Design Simplification

Major Design Aspects

I Uses, extends UNIX philosophy of “everything is a file”

I Try to minimize the number of interfaces

I Diverge from UNIX, POSIX standards when convenient

Following these ideas, with the goal of creating a distributedsystem, has lead to an interesting design.

Kyle Liddell Plan 9 from Bell Labs

OutlineIntroduction

DesignImplementation

ConclusionReferences

OverviewDistributed Design AspectsUNIX Design Simplification

Distributed Design Aspects

I Everything is a file

I Use hierarchical file system as method to organize resources ina namespace

I Extensive use of union mounting to create these namespaces

Kyle Liddell Plan 9 from Bell Labs

OutlineIntroduction

DesignImplementation

ConclusionReferences

OverviewDistributed Design AspectsUNIX Design Simplification

Everything is a File

This idea is present in UNIX, but to a lesser extent.

I Enable DMA for a hard disk – need hdparm

I List open TCP connections – need netstat

I List running processes – need(ed) special system calls

Not enough information is exported through the file interface.

Kyle Liddell Plan 9 from Bell Labs

OutlineIntroduction

DesignImplementation

ConclusionReferences

OverviewDistributed Design AspectsUNIX Design Simplification

Device Files

UNIX solves this with ioctl() – which is device dependent.In Plan 9, every device has several files associated with it:

I the actual data I/O file

I status file

I control file

I ...

With this design, no special commands are needed, and exportingthis information to other systems becomes possible.

Kyle Liddell Plan 9 from Bell Labs

OutlineIntroduction

DesignImplementation

ConclusionReferences

OverviewDistributed Design AspectsUNIX Design Simplification

Device-like Files

I /proc filesystem: exports information, resources, memoryimages of processes on each system

I /net filesystem: exports TCP/IP interface, and statusinformation

Kyle Liddell Plan 9 from Bell Labs

OutlineIntroduction

DesignImplementation

ConclusionReferences

OverviewDistributed Design AspectsUNIX Design Simplification

Library/System Functions as Files

How does the system provide access to services such as thenetworking subsystem, or the domain name resolver?

I Traditional systems use a library interface:I C libraries for programsI Special library wrapper programs like nslookup for users

I Plan 9 instead supplies these services as files:I /net/tcp/clone file creates sockets, /net/tcp/socket#/ files

allow data manipulation and controlI Domain name resolver exported through /dev/dns file

Kyle Liddell Plan 9 from Bell Labs

OutlineIntroduction

DesignImplementation

ConclusionReferences

OverviewDistributed Design AspectsUNIX Design Simplification

Hierarchical Namespace

How are remote resources named?Pair machine name and resource, for example, \\server\homesNot enough abstraction, especially for a large network. Consider:

I C:\my disk

I D:\sharedserver

I printserver:laser1

I . . .

Kyle Liddell Plan 9 from Bell Labs

OutlineIntroduction

DesignImplementation

ConclusionReferences

OverviewDistributed Design AspectsUNIX Design Simplification

Hierarchical Namespace

Plan 9 uses the familiar hierarchical tree structure, with datasources hanging off directories of the tree.Remote resources are “mounted”, placing them as a name in thetree.

I Uniform structure

I Hides distributed nature of resources

Kyle Liddell Plan 9 from Bell Labs

OutlineIntroduction

DesignImplementation

ConclusionReferences

OverviewDistributed Design AspectsUNIX Design Simplification

Hierarchical Namespace – UNIX Example

Consider a network with workstations, fast compute nodes, andnetworked file systems. How could one use a workstation toquickly perform an expensive computation on some files?

I Networked /home filesystem is mounted on each machine(perhaps NFS)

I User logs into compute node (perhaps SSH)

I User runs programs on compute node, sending data throughSSH

I Output files are shared through NFS

Kyle Liddell Plan 9 from Bell Labs

OutlineIntroduction

DesignImplementation

ConclusionReferences

OverviewDistributed Design AspectsUNIX Design Simplification

Hierarchical Namespace – UNIX Example

I What if the computation requires the use of graphics?

I What if the computation should generate sounds for the user?

The network connections must be explicitly named andmanipulated to allow this on UNIX.

Kyle Liddell Plan 9 from Bell Labs

OutlineIntroduction

DesignImplementation

ConclusionReferences

OverviewDistributed Design AspectsUNIX Design Simplification

Hierarchical Namespace – Plan 9 Example

I User logs into compute machine

I System mounts fileserver’s /home as /home on computemachine

I User mounts own terminal’s /dev/screen, /dev/sound devicesover those of compute machine

In this case, the application will work as expected, without theapplication needing to be aware of the network.

Kyle Liddell Plan 9 from Bell Labs

OutlineIntroduction

DesignImplementation

ConclusionReferences

OverviewDistributed Design AspectsUNIX Design Simplification

Hierarchical Namespace – Plan 9 Example

Processes can be debugged remotely with Plan 9, since systemscan export their /proc filesystem:

I User mounts /net/brokenbox/proc to /debug/proc

I User enters the appropriate /debug/proc/pid# directory

I User runs debugger ./mem image

Kyle Liddell Plan 9 from Bell Labs

OutlineIntroduction

DesignImplementation

ConclusionReferences

OverviewDistributed Design AspectsUNIX Design Simplification

Hierarchical Namespace

I Where do these namespaces exist?

I How long do they last?

I Are they private? Shared?

Kyle Liddell Plan 9 from Bell Labs

OutlineIntroduction

DesignImplementation

ConclusionReferences

OverviewDistributed Design AspectsUNIX Design Simplification

Hierarchical Namespace

I Namespaces exist in the context of a user’s login sessionI Namespaces are created on each login session in a default

stateI Namespaces are built up by the userI Namespace layouts can be savedI Created namespace is destroyed at the end of a session

I Namespaces are private, visible only to the creator

Kyle Liddell Plan 9 from Bell Labs

OutlineIntroduction

DesignImplementation

ConclusionReferences

OverviewDistributed Design AspectsUNIX Design Simplification

Union Mounts

In Plan 9, union mounts allow file namespaces to be stacked.

I Multiple program binary directories can be stacked, mergingarchitecture dependent binaries in the same tree as portablescripts

I Multiple filesystem trees can be stacked, using differing accessprivileges

I Import a source tree as read-onlyI Union mount a writable, empty directory over the sourceI Edit files, with changes only going to upper directoryI Unmount the filesystems, leaves original source unmodified

Kyle Liddell Plan 9 from Bell Labs

OutlineIntroduction

DesignImplementation

ConclusionReferences

OverviewDistributed Design AspectsUNIX Design Simplification

UNIX Design Simplification

I Standard method of user interaction is the GUI, not the TTY

I Standard method of system interaction is the file

Kyle Liddell Plan 9 from Bell Labs

OutlineIntroduction

DesignImplementation

ConclusionReferences

OverviewDistributed Design AspectsUNIX Design Simplification

GUI Design Effects

Plan9 assumes that any system will have a VGA graphical interfaceavailable, and that the teletype console will be used only inemergencies.

I No complex terminal drivers

I No complex terminal graphics packagesI No input processing needed in application

I GUI provides editing featuresI Input passed to application only after all user edits are

completed

Kyle Liddell Plan 9 from Bell Labs

OutlineIntroduction

DesignImplementation

ConclusionReferences

OverviewDistributed Design AspectsUNIX Design Simplification

Applications Are Fileservers

Plan 9 namespace design allows many applications to be given afile interface:

I Window manager is a file server/manager, since GUI windowsare special files

I Remote and local windows have consistent interfaceI Windows can be accessed while keeping the network hidden

I FTP client is a file serverI Remote directory is “mounted” in local namespaceI FTP client caches data, sends appropriate FTP protocol

commandsI Remote data can be used with standard system tools (ls, cp,

grep, cc)

I GUI “clipboard” is a file server

Kyle Liddell Plan 9 from Bell Labs

OutlineIntroduction

DesignImplementation

ConclusionReferences

Plan 9 KernelNetwork Protocol

Plan 9 Kernel

Plan 9 kernel is fairly simple, and small.

I About 45k lines of architecture independent code (includesnetwork protocols)

I About 70k lines of PC dependent code (drivers, boot code,etc)

I Small size, and minimal services allow the system to beviewed as a micro-kernel

Kyle Liddell Plan 9 from Bell Labs

OutlineIntroduction

DesignImplementation

ConclusionReferences

Plan 9 KernelNetwork Protocol

9P Network Protocol

Plan 9 uses the 9P network protocol.

I Network file access protocol

I 14 functions make up protocol

I Runs over TCP

I Files are accessed using a fid

Kyle Liddell Plan 9 from Bell Labs

OutlineIntroduction

DesignImplementation

ConclusionReferences

Plan 9 KernelNetwork Protocol

9P Network Protocol

9P consists of only 14 functions:

I version

I auth

I error

I flush

I attach

I walk

I open, create

I read, write

I clunk, remove

I stat, wstat

Kyle Liddell Plan 9 from Bell Labs

OutlineIntroduction

DesignImplementation

ConclusionReferences

Plan 9 KernelNetwork Protocol

9P Example

Consider writing ’Hello World’ to /dev/display:

version() begins session

auth() get authorization token

attach() register,authenticate access to serviceI At this point, we have an fid pointing to the

server’s root directory

walk() to ./dev (fid = /dev)

walk() to display (fid = /dev/display)

open(fid) causes the server to check for permission to write tothe fid, and allows the client to begin reading andwriting to the fid

write(fid) write “Hello World”

clunk(fid) closes the fid

Kyle Liddell Plan 9 from Bell Labs

OutlineIntroduction

DesignImplementation

ConclusionReferences

Usage

I Plan 9 is not appropriate for general useI OS has limited hardware supportI OS has few user programs - C compiler, mail client, text editorI OS doesn’t have a native web browser

I Plan 9 does provide UNIX/POSIX emulation layerI TEXI emacsI X

I Small, actively developed code base

Kyle Liddell Plan 9 from Bell Labs

OutlineIntroduction

DesignImplementation

ConclusionReferences

Effects

Many concepts in modern UNIX operating systems began in Plan9:

I /proc filesystem

I /sys filesystem

I Union and bind mounting

I FUSE

I rfork()/clone() thread creation mechanism

Kyle Liddell Plan 9 from Bell Labs

OutlineIntroduction

DesignImplementation

ConclusionReferences

References

Plan 9 from Bell Labs http://plan9.bell-labs.com/sys/doc/9.pdf

The Use of Name Spaces in Plan 9http://plan9.bell-labs.com/sys/doc/names.pdf

Plan 9 Manual http://plan9.bell-labs.com/sys/man/vol1.pdf

Kyle Liddell Plan 9 from Bell Labs