2330 lines · 82.7 KB · Text
RawDownload
.HTML "Plan 9 from Bell Labs".TLPlan 9 from Bell Labs.AURob PikeDave PresottoSean DorwardBob FlandrenaKen ThompsonHoward TrickeyPhil Winterbottom.AI.MHUSA.SHMotivation.PP.FSAppeared in a slightly different form in.IComputing Systems,.RVol 8 #3, Summer 1995, pp. 221-254..FEBy the mid 1980's, the trend in computing wasaway from large centralized time-shared computers towardsnetworks of smaller, personal machines,typically UNIX `workstations'.People had grown weary of overloaded, bureaucratic timesharing machinesand were eager to move to small, self-maintained systems, even if thatmeant a net loss in computing power.As microcomputers became faster, even that loss was recovered, andthis style of computing remains popular today..PPIn the rush to personal workstations, though, some of their weaknesseswere overlooked.First, the operating system they run, UNIX, is itself an old timesharing system andhas had trouble adapting to ideasborn after it.  Graphics and networking were added to UNIX well intoits lifetime and remain poorly integrated and difficult to administer.More important, the early focus on having private machinesmade it difficult for networks of machines to serve as seamlessly as the oldmonolithic timesharing systems.Timesharing centralized the managementand amortization of costs and resources;personal computing fractured, democratized, and ultimately amplifiedadministrative problems.The choice ofan old timesharing operating system to run those personal machinesmade it difficult to bind things together smoothly..PPPlan 9 began in the late 1980's as an attempt to have it bothways: to build a system that was centrally administered and cost-effectiveusing cheap modern microcomputers as its computing elements.The idea was to build a time-sharing system out of workstations, but in a novel way.Different computers would handledifferent tasks: small, cheap machines in people's offices would serveas terminals providing access to large, central, shared resources such as computingservers and file servers.  For the central machines, the coming wave ofshared-memory multiprocessors seemed obvious candidates.The philosophy is much like that of the CambridgeDistributed System [NeHe82].The early catch phrase was to build a UNIX out of a lot of little systems,not a system out of a lot of little UNIXes..PPThe problems with UNIX were too deep to fix, but some of its ideas could bebrought along.  The best was its use of the file system to coordinatenaming of and access to resources, even those, such as devices, not traditionallytreated as files.For Plan 9, we adopted this idea by designing a network-level protocol, called 9P,to enable machines to access files on remote systems.Above this, we built a namingsystem that lets people and their computing agents build customized viewsof the resources in the network.This is where Plan 9 first began to look different:a Plan 9 user builds a private computing environment and recreates it whereverdesired, rather than doing all computing on a private machine.It soon became clear that this model was richerthan we had foreseen, and the ideas of per-process name spacesand file-system-like resources were extended throughoutthe system\(emto processes, graphics, even the network itself..PPBy 1989 the system had become solid enoughthat some of us began using it as our exclusive computing environment.This meant bringing along many of the services and applications we hadused on UNIX.  We used this opportunity to revisit many issues, not justkernel-resident ones, that we felt UNIX addressed badly.Plan 9 has new compilers,languages,libraries,window systems,and many new applications.Many of the old tools were dropped, while those brought along havebeen polished or rewritten..PPWhy be so all-encompassing?The distinction between operating system, library, and applicationis important to the operating system researcher but uninteresting to theuser.  What matters is clean functionality.By building a complete new system,we were able to solve problems where we thought they should be solved.For example, there is no real `tty driver' in the kernel; that is the job of the windowsystem.In the modern world, multi-vendor and multi-architecture computingare essential, yet the usual compilers and tools assume the program is beingbuilt to run locally; we needed to rethink these issues.Most important, though, the test of a system is the computingenvironment it provides.Producing a more efficient way to run the old UNIX warhorsesis empty engineering;we were more interested in whether the new ideas suggested bythe architecture of the underlying system encourage a more effective way of working.Thus, although Plan 9 provides an emulation environment forrunning POSIX commands, it is a backwater of the system.The vast majorityof system software is developed in the `native' Plan 9 environment..PPThere are benefits to having an all-new system.First, our laboratory has a history of building experimental peripheral boards.To make it easy to write device drivers,we want a system that is available in source form(no longer guaranteed with UNIX, evenin the laboratory in which it was born).Also, we want to redistribute our work, which means the softwaremust be locally produced.  For example, we could have used some vendors'C compilers for our system, but even had we overcome the problems withcross-compilation, we would have difficultyredistributing the result..PPThis paper serves as an overview of the system.  It discusses the architecturefrom the lowest building blocks to the computing environment seen by users.It also serves as an introduction to the rest of the Plan 9 Programmer's Manual,which it accompanies.  More detail about topics in this papercan be found elsewhere in the manual..SHDesign.PPThe view of the system is built upon three principles.First, resources are named and accessed like files in a hierarchical file system.Second, there is a standard protocol, called 9P, for accessing theseresources.Third, the disjoint hierarchies provided by different services arejoined together into a single private hierarchical file name space.The unusual properties of Plan 9 stem from the consistent, aggressiveapplication of these principles..PPA large Plan 9 installation has a number of computers networkedtogether, each providing a particular class of service.Shared multiprocessor servers provide computing cycles;other large machines offer file storage.These machines are located in an air-conditioned machineroom and are connected by high-performance networks.Lower bandwidth networks such as Ethernet or ISDN connect theseservers to office- and home-resident workstations or PCs, called terminalsin Plan 9 terminology.Figure 1 shows the arrangement..KF.PS < network.pic.IP.ps -1.in .25i.ll -.25i.ps -1.vs -1.I "Figure 1. Structure of a large Plan 9 installation.CPU servers and file servers share fast local-area networks,while terminals use slower wider-area networks such as Ethernet,Datakit, or telephone lines to connect to them.Gateway machines, which are just CPU servers connected to multiplenetworks, allow machines on one network to see another..ps +1.vs +1.ll +.25i.in 0.ps.sp.KE.PPThe modern style of computing offers each user a dedicated workstation or PC.Plan 9's approach is different.The various machines with screens, keyboards, and mice all provideaccess to the resources of the network, so they are functionally equivalent,in the manner of the terminals attached to old timesharing systems.When someone uses the system, though,the terminal is temporarily personalized by that user.Instead of customizing the hardware, Plan 9 offers the ability to customizeone's view of the system provided by the software.That customization is accomplished by giving local, personal names for thepublicly visible resources in the network.Plan 9 provides the mechanism to assemble a personal view of the publicspace with local names for globally accessible resources.Since the most important resources of the network are files, the modelof that view is file-oriented..PPThe client's local name space provides a way to customize the user'sview of the network.  The services available in the network all export filehierarchies.Those important to the user are gathered together intoa custom name space; those of no immediate interest are ignored.This is a different style of use from the idea of a `uniform global name space'.In Plan 9, there are known names for services and uniform names forfiles exported by those services,but the view is entirely local.  As an analogy, consider the differencebetween the phrase `my house' and the precise address of the speaker'shome.  The latter may be used by anyone but the former is easier to say andmakes sense when spoken.It also changes meaning depending on who says it,yet that does not cause confusion.Similarly, in Plan 9 the name.CW /dev/consalways refers to the user's terminal and.CW /bin/datethe correct version of the datecommand to run,but which files those names represent depends on circumstances such as thearchitecture of the machine executing.CW date .Plan 9, then, has local name spaces that obey globally understoodconventions;it is the conventions that guarantee sane behavior in the presenceof local names..PPThe 9P protocol is structured as a set of transactions thatsend a request from a client to a (local or remote) server and return the result.9P controls file systems, not just files:it includes procedures to resolve file names and traverse the namehierarchy of the file system provided by the server.On the other hand,the client's name space is held by the client system alone, not on or with the server,a distinction from systems such as Sprite [OCDNW88].Also, file access is at the level of bytes, not blocks, which distinguishes9P from protocols like NFS and RFS.A paper by Welch compares Sprite, NFS, and Plan 9's network file system structures [Welc94]..PPThis approach was designed with traditional files in mind,but can be extendedto many other resources.Plan 9 services that export file hierarchies include I/O devices,backup services,the window system,network interfaces,and many others.One example is the process file system,.CW /proc ,which provides a clean wayto examine and control running processes.Precursor systems had a similar idea [Kill84], but Plan 9 pushes thefile metaphor much further [PPTTW93].The file system model is well-understood, both by system builders and general users,so services that present file-like interfaces are easy to build, easy to understand,and easy to use.Files come with agreed-upon rules forprotection,naming,and access both local and remote,so services built this way are ready-made for a distributed system.(This is a distinction from `object-oriented' models, where these issuesmust be faced anew for every class of object.)Examples in the sections that follow illustrate these ideas in action..SHThe Command-level View.PPPlan 9 is meant to be used from a machine with a screen runningthe window system.It has no notion of `teletype' in the UNIX sense.  The keyboard handling ofthe bare system is rudimentary, but once the window system, 8½ [Pike91],is running,text can be edited with `cut and paste' operations from a pop-up menu,copied between windows, and so on.8½ permits editing text from the past, not just on the current input line.The text-editing capabilities of 8½ are strong enough to displacespecial features such as history in the shell,paging and scrolling,and mail editors.8½ windows do not support cursor addressing and,except for one terminal emulator to simplify connecting to traditional systems,there is no cursor-addressing software in Plan 9..PPEach window is created in a separate name space.Adjustments made to the name space in a window do not affect other windowsor programs, making it safe to experiment with local modifications to the namespace, for exampleto substitute files from the dump file system when debugging.Once the debugging is done, the window can be deleted and all trace of theexperimental apparatus is gone.Similar arguments apply to the private space each window has for environmentvariables, notes (analogous to UNIX signals), etc..PPEach window is created running an application, such as the shell, withstandard input and output connected to the editable text of the window.Each window also has a private bitmap and multiplexed access to thekeyboard, mouse, and other graphical resources through files like.CW /dev/mouse ,.CW /dev/bitblt ,and.CW /dev/cons(analogous to UNIX's.CW /dev/tty ).These files are provided by 8½, which is implemented as a file server.Unlike X windows, where a new application typically creates a new windowto run in, an 8½ graphics application usually runs in the window where it starts.It is possible and efficient for an application to create a new window, butthat is not the style of the system.Again contrasting to X, in which a remote application makes a networkcall to the X server to start running,a remote 8½ application sees the.CW mouse ,.CW bitblt ,and.CW consfiles for the window as usual in.CW /dev ;it does not know whether the files are local.It just reads and writes them to control the window;the network connection is already there and multiplexed..PPThe intended style of use is to run interactive applications such as the windowsystem and text editor on the terminal and to run computation- or file-intensiveapplications on remote servers.Different windows may be running programs on different machines overdifferent networks, but by making the name space equivalent in all windows,this is transparent: the same commands and resources are available, with the same names,wherever the computation is performed..PPThe command set of Plan 9 is similar to that of UNIX.The commands fall into several broad classes.  Some are new programs forold jobs: programs like.CW ls ,.CW cat ,and.CW whohave familiar names and functions but are new, simpler implementations..CW Who ,for example, is a shell script, while.CW psis just 95 lines of C code.Some commands are essentially the same as their UNIX ancestors:.CW awk ,.CW troff ,and others have been converted to ANSI C and extended to handleUnicode, but are still the familiar tools.Some are entirely new programs for old niches: the shell.CW rc ,text editor.CW sam ,debugger.CW acid ,and othersdisplace the better-known UNIX tools with similar jobs.Finally, about half the commands are new..PPCompatibility was not a requirement for the system.Where the old commands or notation seemed good enough, wekept them.  When they didn't, we replaced them..SHThe File Server.PPA central file server stores permanent files and presents them to the networkas a file hierarchy exported using 9P.The server is a stand-alone system, accessible only over the network,designed to do its one job well.It runs no user processes, only a fixed set of routines compiled into theboot image.Rather than a set of disks or separate file systems,the main hierarchy exported by the server is a singletree, representing files on many disks.That hierarchy isshared by many users over a wide area on a variety of networks.Other file trees exported bythe server includespecial-purpose systems such as temporary storage and, as explainedbelow, a backup service..PPThe file server has three levels of storage.The central server in our installation hasabout 100 megabytes of memory buffers,27 gigabytes of magnetic disks,and 350 gigabytes ofbulk storage in a write-once-read-many (WORM) jukebox.The disk is a cache for the WORM and the memory is a cache for the disk;each is much faster, and sees about an order of magnitude more traffic,than the level it caches.The addressable data in the file system can be larger than the size of themagnetic disks, because they are only a cache;our main file server has about 40 gigabytes of active storage..PPThe most unusual feature of the file servercomes from its use of a WORM device forstable storage.Every morning at 5 o'clock, a.I dumpof the file system occurs automatically.The file system is frozen andall blocks modified since the last dumpare queued to be written to the WORM.Once the blocks are queued,service is restored andthe read-only root of the dumpedfile system appears in ahierarchy of all dumps ever taken, named by its date.For example, the directory.CW /n/dump/1995/0315is the root directory of an image of the file systemas it appeared in the early morning of March 15, 1995.It takes a few minutes to queue the blocks,but the process to copy blocks to the WORM, which runs in the background, may take hours..PPThere are two ways the dump file system is used.The first is by the users themselves, who can browse thedump file system directly or attach pieces ofit to their name space.For example, to track down a bug,it is straightforward to try the compiler from three months agoor to link a program with yesterday's library.With daily snapshots of all files,it is easy to find when a particular change wasmade or what changes were made on a particular date.People feel free to make large speculative changesto files in the knowledge that they can be backedout with a singlecopy command.There is no backup system as such;instead, because the dumpis in the file name space, backup problems can be solved withstandard toolssuch as.CW cp ,.CW ls ,.CW grep ,and.CW diff ..PPThe other (very rare) use is complete system backup.In the event of disaster,the active file system can be initialized from any dump by clearing thedisk cache and setting the root ofthe active file system to be a copyof the dumped root.Although easy to do, this is not to be taken lightly:besides losing any change made after the date of the dump, this recovery methodresults in a very slow system.The cache must be reloaded from WORM, which is muchslower than magnetic disks.The file system takes a few days to reload the workingset and regain its full performance..PPAccess permissions of files in the dump are the sameas they were when the dump was made.Normal utilities have normalpermissions in the dump without any special arrangement.The dump file system is read-only, though,which means that files in the dump cannot be written regardless of their permission bits;in fact, since directories are part of the read-only structure,even the permissions cannot be changed..PPOnce a file is written to WORM, it cannot be removed,so our users never see``please clean up your files''messages and there is no.CW dfcommand.We regard the WORM jukebox as an unlimited resource.The only issue is how long it will take to fill.Our WORM has served a community of about 50 usersfor five years and has absorbed daily dumps, consuming a total of65% of the storage in the jukebox.In that time, the manufacturer has improved the technology,doubling the capacity of the individual disks.If we were to upgrade to the new media,we would have more free space than in the original empty jukebox.Technology has created storage faster than we can use it..SHUnusual file servers.PPPlan 9 is characterized by a variety of servers that offera file-like interface to unusual services.Many of these are implemented by user-level processes, although the distinctionis unimportant to their clients; whether a service is provided by the kernel,a user process, or a remote server is irrelevant to the way it is used.There are dozens of such servers; in this section we present three representative ones..PPPerhaps the most remarkable file server in Plan 9 is 8½, the window system.It is discussed at length elsewhere [Pike91], but deserves a brief explanation here.8½ provides two interfaces: to the user seated at the terminal, it offers a traditionalstyle of interaction with multiple windows, each running an application, all controlledby a mouse and keyboard.To the client programs, the view is also fairly traditional:programs running in a window see a set of files in.CW /devwith names like.CW mouse ,.CW screen ,and.CW cons .Programs that want to print text to their window write to.CW /dev/cons ;to read the mouse, they read.CW /dev/mouse .In the Plan 9 style, bitmap graphics is implemented by providing a file

Lines 1–500 of 2330.