TheUNIXTime-SharingSystem* D.M.RitchieandK.Thompson ABSTRACT UNIX◯risageneral-purpose,multi-user,interactiveoperatingsystemforthe largerDigitalEquipmentCorporationPDP-11andtheInterdata8/32computers. Itoffersanumberoffeaturesseldomfoundeveninlargeroperatingsystems, including iAhierarchicalfilesystemincorporatingdemountablevolumes, iiCompatiblefile,device,andinter-processI/O, iiiTheabilitytoinitiateasynchronousprocesses, ivSystemcommandlanguageselectableonaper-userbasis, vOver100subsystemsincludingadozenlanguages, viHighdegreeofportability. Thispaperdiscussesthenatureandimplementationofthefilesystemandofthe usercommandinterface. 1.INTRODUCTION TherehavebeenfourversionsoftheUNIXtime-sharingsystem.Theearliest(circa1969-70) ranontheDigitalEquipmentCorporationPDP-7and-9computers.Thesecondversionranon theunprotectedPDP-11/20computer.Thethirdincorporatedmultiprogrammingandranonthe PDP-11/34,/40,/45,/60,and/70computers;itistheonedescribedinthepreviouslypublished versionofthispaper,andisalsothemostwidelyusedtoday.Thispaperdescribesonlythe fourth,currentsystemthatrunsonthePDP-11/70andtheInterdata8/32computers.Infact,the differencesamongthevarioussystemsisrathersmall;mostoftherevisionsmadetotheoriginally publishedversionofthispaper,asidefromthoseconcernedwithstyle,hadtodowithdetailsof theimplementationofthefilesystem. SincePDP-11UNIXbecameoperationalinFebruary,1971,over600installationshavebeen putintoservice.Mostofthemareengagedinapplicationssuchascomputerscienceeducation, thepreparationandformattingofdocumentsandothertextualmaterial,thecollectionandprocessingoftroubledatafromvariousswitchingmachineswithintheBellSystem,andrecordingand checkingtelephoneserviceorders.Ourowninstallationisusedmainlyforresearchinoperating systems,languages,computernetworks,andothertopicsincomputerscience,andalsofordocumentpreparation. PerhapsthemostimportantachievementofUNIXistodemonstratethatapowerfuloperatingsystemforinteractiveuseneednotbeexpensiveeitherinequipmentorinhumaneffort:itcan runonhardwarecostingaslittleas$40,000,andlessthantwoman-yearswerespentonthemain systemsoftware.Wehope,however,thatusersfindthatthemostimportantcharacteristicsofthe systemareitssimplicity,elegance,andeaseofuse. *Copyright1974,AssociationforComputingMachinery,Inc.,reprintedbypermission.Thisisa revisedversionofanarticlethatappearedinCommunicationsoftheACM,17,No.7(July1974),pp. 365-375.ThatarticlewasarevisedversionofapaperpresentedattheFourthACMSymposiumon OperatingSystemsPrinciples,IBMThomasJ.WatsonResearchCenter,YorktownHeights,NewYork, October15-17,1973.

-2-Besidestheoperatingsystemproper,somemajorprogramsavailableunderUNIXare Ccompiler TexteditorbasedonQED1 Assembler,linkingloader,symbolicdebugger Phototypesettingandequationsettingprograms2,3 DozensoflanguagesincludingFortran77,Basic,Snobol,APL,Algol68,M6,TMG, Pascal Thereisahostofmaintenance,utility,recreationandnoveltyprograms,allwrittenlocally.The UNIXusercommunity,whichnumbersinthethousands,hascontributedmanymoreprogramsand languages.Itisworthnotingthatthesystemistotallyself-supporting.AllUNIXsoftwareis maintainedonthesystem;likewise,thispaperandallotherdocumentsinthisissueweregeneratedandformattedbytheUNIXeditorandtextformattingprograms. II.HARDWAREANDSOFTWAREENVIRONMENT ThePDP-11/70onwhichtheResearchUNIXsystemisinstalledisa16-bitword(8-bitbyte) computerwith768Kbytesofcorememory;thesystemkerneloccupies90Kbytesaboutequally dividedbetweencodeanddatatables.Thissystem,however,includesaverylargenumberof devicedriversandenjoysagenerousallotmentofspaceforI/Obuffersandsystemtables;aminimalsystemcapableofrunningthesoftwarementionedabovecanrequireaslittleas96Kbytesof corealtogether.Thereareevenlargerinstallations;seethedescriptionofthePWB/UNIXsystems,4, 5forexample.Therearealsomuchsmaller,thoughsomewhatrestricted,versionsofthesystem.6 OurownPDP-11hastwo200-Mbmoving-headdisksforfilesystemstorageandswapping. Thereare20variable-speedcommunicationsinterfacesattachedto300-and1200-bauddatasets, andanadditional12communicationlineshard-wiredto9600-baudterminalsandsatellitecom-puters.Therearealsoseveral2400-and4800-baudsynchronouscommunicationinterfacesused formachine-to-machinefiletransfer.Finally,thereisavarietyofmiscellaneousdevicesincluding nine-trackmagnetictape,alineprinter,avoicesynthesizer,aphototypesetter,adigitalswitching network,andachessmachine. ThepreponderanceofUNIXsoftwareiswrittenintheabovementionedClanguage.7Early versionsoftheoperatingsystemwerewritteninassemblylanguage,butduringthesummerof 1973,itwasrewritteninC.Thesizeofthenewsystemwasaboutone-thirdgreaterthanthatof theold.Sincethenewsystemnotonlybecamemucheasiertounderstandandtomodifybutalso includedmanyfunctionalimprovements,includingmultiprogrammingandtheabilitytoshare reentrantcodeamongseveraluserprograms,weconsiderthisincreaseinsizequiteacceptable. III.THEFILESYSTEM Themostimportantroleofthesystemistoprovideafilesystem.Fromthepointofviewof theuser,therearethreekindsoffiles:ordinarydiskfiles,directories,andspecialfiles. 3.1Ordinaryfiles Afilecontainswhateverinformationtheuserplacesonit,forexample,symbolicorbinary (object)programs.Noparticularstructuringisexpectedbythesystem.Afileoftextconsists simplyofastringofcharacters,withlinesdemarcatedbythenewlinecharacter.Binaryprograms aresequencesofwordsastheywillappearincorememorywhentheprogramstartsexecuting.A fewuserprogramsmanipulatefileswithmorestructure;forexample,theassemblergenerates,and theloaderexpects,anobjectfileinaparticularformat.However,thestructureoffilesiscontrolledbytheprogramsthatusethem,notbythesystem. 3.2Directories Directoriesprovidethemappingbetweenthenamesoffilesandthefilesthemselves,and thusinduceastructureonthefilesystemasawhole.Eachuserhasadirectoryofhisownfiles; hemayalsocreatesubdirectoriestocontaingroupsoffilesconvenientlytreatedtogether.A -3-directorybehavesexactlylikeanordinaryfileexceptthatitcannotbewrittenonbyunprivileged programs,sothatthesystemcontrolsthecontentsofdirectories.However,anyonewithappropriatepermissionmayreadadirectoryjustlikeanyotherfile. Thesystemmaintainsseveraldirectoriesforitsownuse.Oneoftheseistherootdirectory. Allfilesinthesystemcanbefoundbytracingapaththroughachainofdirectoriesuntilthe desiredfileisreached.Thestartingpointforsuchsearchesisoftentheroot.Othersystemdirectoriescontainalltheprogramsprovidedforgeneraluse;thatis,allthecommands.Aswillbe seen,however,itisbynomeansnecessarythataprogramresideinoneofthesedirectoriesforit tobeexecuted. Filesarenamedbysequencesof14orfewercharacters.Whenthenameofafileisspecified tothesystem,itmaybeintheformofapathname,whichisasequenceofdirectorynamesseparatedbyslashes,‘‘/’’,andendinginafilename.Ifthesequencebeginswithaslash,thesearch beginsintherootdirectory.Thename/alpha/beta/gammacausesthesystemtosearchthe rootfordirectoryalpha,thentosearchalphaforbeta,finallytofindgammainbeta.gamma maybeanordinaryfile,adirectory,oraspecialfile.Asalimitingcase,thename‘‘/’’refersto therootitself. Apathnamenotstartingwith‘‘/’’causesthesystemtobeginthesearchintheuser’scurrentdirectory.Thus,thenamealpha/betaspecifiesthefilenamedbetainsubdirectoryalpha ofthecurrentdirectory.Thesimplestkindofname,forexample,alpha,referstoafilethatitself isfoundinthecurrentdirectory.Asanotherlimitingcase,thenullfilenamereferstothecurrent directory. Thesamenon-directoryfilemayappearinseveraldirectoriesunderpossiblydifferentnames. Thisfeatureiscalledlinking;adirectoryentryforafileissometimescalledalink.TheUNIXsystemdiffersfromothersystemsinwhichlinkingispermittedinthatalllinkstoafilehaveequal status.Thatis,afiledoesnotexistwithinaparticulardirectory;thedirectoryentryforafile consistsmerelyofitsnameandapointertotheinformationactuallydescribingthefile.Thusa fileexistsindependentlyofanydirectoryentry,althoughinpracticeafileismadetodisappear alongwiththelastlinktoit. Eachdirectoryalwayshasatleasttwoentries.Thename‘‘.’’ineachdirectoryreferstothe directoryitself.Thusaprogrammayreadthecurrentdirectoryunderthename‘‘.’’without knowingitscompletepathname.Thename‘‘..’’byconventionreferstotheparentofthedirectoryinwhichitappears,thatis,tothedirectoryinwhichitwascreated. Thedirectorystructureisconstrainedtohavetheformofarootedtree.Exceptforthespecialentries‘‘.’’and‘‘..’’,eachdirectorymustappearasanentryinexactlyoneotherdirectory, whichisitsparent.Thereasonforthisistosimplifythewritingofprogramsthatvisitsubtrees ofthedirectorystructure,andmoreimportant,toavoidtheseparationofportionsofthehierarchy.Ifarbitrarylinkstodirectorieswerepermitted,itwouldbequitedifficulttodetectwhenthe lastconnectionfromtheroottoadirectorywassevered. 3.3Specialfiles SpecialfilesconstitutethemostunusualfeatureoftheUNIXfilesystem.Eachsupported I/Odeviceisassociatedwithatleastonesuchfile.Specialfilesarereadandwrittenjustlike ordinarydiskfiles,butrequeststoreadorwriteresultinactivationoftheassociateddevice.An entryforeachspecialfileresidesindirectory/dev,althoughalinkmaybemadetooneofthese filesjustasitmaytoanordinaryfile.Thus,forexample,towriteonamagnetictapeonemay writeonthefile/dev/mt.Specialfilesexistforeachcommunicationline,eachdisk,eachtape drive,andforphysicalmainmemory.Ofcourse,theactivedisksandthememoryspecialfileare protectedfromindiscriminateaccess. ThereisathreefoldadvantageintreatingI/Odevicesthisway:fileanddeviceI/Oareas similaraspossible;fileanddevicenameshavethesamesyntaxandmeaning,sothataprogram expectingafilenameasaparametercanbepassedadevicename;finally,specialfilesaresubject tothesameprotectionmechanismasregularfiles.

-4-3.4Removablefilesystems Althoughtherootofthefilesystemisalwaysstoredonthesamedevice,itisnotnecessary thattheentirefilesystemhierarchyresideonthisdevice.Thereisamountsystemrequestwith twoarguments:thenameofanexistingordinaryfile,andthenameofaspecialfilewhoseassociatedstoragevolume(e.g.,adiskpack)shouldhavethestructureofanindependentfilesystem containingitsowndirectoryhierarchy.Theeffectofmountistocausereferencestotheheretoforeordinaryfiletoreferinsteadtotherootdirectoryofthefilesystemontheremovablevolume. Ineffect,mountreplacesaleafofthehierarchytree(theordinaryfile)byawholenewsubtree (thehierarchystoredontheremovablevolume).Afterthemount,thereisvirtuallynodistinctionbetweenfilesontheremovablevolumeandthoseinthepermanentfilesystem.Inourinstallation,forexample,therootdirectoryresidesonasmallpartitionofoneofourdiskdrives,while theotherdrive,whichcontainstheuser’sfiles,ismountedbythesysteminitializationsequence. Amountablefilesystemisgeneratedbywritingonitscorrespondingspecialfile.Autilityprogramisavailabletocreateanemptyfilesystem,oronemaysimplycopyanexistingfilesystem. Thereisonlyoneexceptiontotheruleofidenticaltreatmentoffilesondifferentdevices:no linkmayexistbetweenonefilesystemhierarchyandanother.Thisrestrictionisenforcedsoasto avoidtheelaboratebookkeepingthatwouldotherwiseberequiredtoassureremovalofthelinks whenevertheremovablevolumeisdismounted. 3.5Protection Althoughtheaccesscontrolschemeisquitesimple,ithassomeunusualfeatures.Eachuser ofthesystemisassignedauniqueuseridentificationnumber.Whenafileiscreated,itismarked withtheuserIDofitsowner.Alsogivenfornewfilesisasetoftenprotectionbits.Nineofthese specifyindependentlyread,write,andexecutepermissionfortheownerofthefile,forothermembersofhisgroup,andforallremainingusers. Ifthetenthbitison,thesystemwilltemporarilychangetheuseridentification(hereafter, userID)ofthecurrentusertothatofthecreatorofthefilewheneverthefileisexecutedasaprogram.ThischangeinuserIDiseffectiveonlyduringtheexecutionoftheprogramthatcallsfor it.Theset-user-IDfeatureprovidesforprivilegedprogramsthatmayusefilesinaccessibletoother users.Forexample,aprogrammaykeepanaccountingfilethatshouldneitherbereadnor changedexceptbytheprogramitself.Iftheset-user-IDbitisonfortheprogram,itmayaccess thefilealthoughthisaccessmightbeforbiddentootherprogramsinvokedbythegivenprogram’s user.SincetheactualuserIDoftheinvokerofanyprogramisalwaysavailable,set-user-IDpro-gramsmaytakeanymeasuresdesiredtosatisfythemselvesastotheirinvoker’scredentials.This mechanismisusedtoallowuserstoexecutethecarefullywrittencommandsthatcallprivileged systementries.Forexample,thereisasystementryinvokableonlybythe‘‘super-user’’(below) thatcreatesanemptydirectory.Asindicatedabove,directoriesareexpectedtohaveentriesfor ‘‘.’’and‘‘..’’.Thecommandwhichcreatesadirectoryisownedbythesuper-userandhasthe set-user-IDbitset.Afteritchecksitsinvoker’sauthorizationtocreatethespecifieddirectory,it createsitandmakestheentriesfor‘‘.’’and‘‘..’’. Becauseanyonemaysettheset-user-IDbitononeofhisownfiles,thismechanismisgener-allyavailablewithoutadministrativeintervention.Forexample,thisprotectionschemeeasily solvestheMOOaccountingproblemposedby‘‘Aleph-null.’’8 ThesystemrecognizesoneparticularuserID(thatofthe‘‘super-user’’)asexemptfromthe usualconstraintsonfileaccess;thus(forexample),programsmaybewrittentodumpandreload thefilesystemwithoutunwantedinterferencefromtheprotectionsystem. 3.6I/Ocalls ThesystemcallstodoI/Oaredesignedtoeliminatethedifferencesbetweenthevarious devicesandstylesofaccess.Thereisnodistinctionbetween‘‘random’’and‘‘sequential’’I/O,nor isanylogicalrecordsizeimposedbythesystem.Thesizeofanordinaryfileisdeterminedbythe numberofbyteswrittenonit;nopredeterminationofthesizeofafileisnecessaryorpossible.

-5-ToillustratetheessentialsofI/O,someofthebasiccallsaresummarizedbelowinan anonymouslanguagethatwillindicatetherequiredparameterswithoutgettingintotheunderlyingcomplexities.Eachcalltothesystemmaypotentiallyresultinanerrorreturn,whichforsimplicityisnotrepresentedinthecallingsequence. Toreadorwriteafileassumedtoexistalready,itmustbeopenedbythefollowingcall: filep=open(name,flag) wherenameindicatesthenameofthefile.Anarbitrarypathnamemaybegiven.Theflag argumentindicateswhetherthefileistoberead,written,or‘‘updated,’’thatis,readandwritten simultaneously. Thereturnedvaluefilepiscalledafiledescriptor.Itisasmallintegerusedtoidentifythe fileinsubsequentcallstoread,write,orotherwisemanipulatethefile. Tocreateanewfileorcompletelyrewriteanoldone,thereisacreatesystemcallthatcreatesthegivenfileifitdoesnotexist,ortruncatesittozerolengthifitdoesexist;createalso opensthenewfileforwritingand,likeopen,returnsafiledescriptor. Thefilesystemmaintainsnolocksvisibletotheuser,noristhereanyrestrictiononthe numberofuserswhomayhaveafileopenforreadingorwriting.Althoughitispossibleforthe contentsofafiletobecomescrambledwhentwouserswriteonitsimultaneously,inpracticedifficultiesdonotarise.Wetaketheviewthatlocksareneithernecessarynorsufficient,inourenvironment,topreventinterferencebetweenusersofthesamefile.Theyareunnecessarybecausewe arenotfacedwithlarge,single-filedatabasesmaintainedbyindependentprocesses.Theyare insufficientbecauselocksintheordinarysense,wherebyoneuserispreventedfromwritingona filethatanotheruserisreading,cannotpreventconfusionwhen,forexample,bothusersareeditingafilewithaneditorthatmakesacopyofthefilebeingedited. Thereare,however,sufficientinternalinterlockstomaintainthelogicalconsistencyofthe filesystemwhentwousersengagesimultaneouslyinactivitiessuchaswritingonthesamefile, creatingfilesinthesamedirectory,ordeletingeachother’sopenfiles. Exceptasindicatedbelow,readingandwritingaresequential.Thismeansthatifaparticularbyteinthefilewasthelastbytewritten(orread),thenextI/Ocallimplicitlyreferstothe immediatelyfollowingbyte.Foreachopenfilethereisapointer,maintainedinsidethesystem, thatindicatesthenextbytetobereadorwritten.Ifnbytesarereadorwritten,thepointer advancesbynbytes. Onceafileisopen,thefollowingcallsmaybeused: n=read(filep,buffer,count) n=write(filep,buffer,count) Uptocountbytesaretransmittedbetweenthefilespecifiedbyfilepandthebytearrayspecified bybuffer.Thereturnedvaluenisthenumberofbytesactuallytransmitted.Inthewritecase, nisthesameascountexceptunderexceptionalconditions,suchasI/Oerrorsorendofphysical mediumonspecialfiles;inaread,however,nmaywithouterrorbelessthancount.Iftheread pointerissoneartheendofthefilethatreadingcountcharacterswouldcausereadingbeyond theend,onlysufficientbytesaretransmittedtoreachtheendofthefile;also,typewriter-liketer-minalsneverreturnmorethanonelineofinput.Whenareadcallreturnswithnequaltozero, theendofthefilehasbeenreached.Fordiskfilesthisoccurswhenthereadpointerbecomes equaltothecurrentsizeofthefile.Itispossibletogenerateanend-of-filefromaterminalbyuse ofanescapesequencethatdependsonthedeviceused. Byteswrittenaffectonlythosepartsofafileimpliedbythepositionofthewritepointer andthecount;nootherpartofthefileischanged.Ifthelastbyteliesbeyondtheendofthefile, thefileismadetogrowasneeded. Todorandom(direct-access)I/Oitisonlynecessarytomovethereadorwritepointerto theappropriatelocationinthefile.

-6-location=lseek(filep,offset,base) Thepointerassociatedwithfilepismovedtoapositionoffsetbytesfromthebeginningofthe file,fromthecurrentpositionofthepointer,orfromtheendofthefile,dependingonbase. offsetmaybenegative.Forsomedevices(e.g.,papertapeandterminals)seekcallsareignored. Theactualoffsetfromthebeginningofthefiletowhichthepointerwasmovedisreturnedin location. ThereareseveraladditionalsystementrieshavingtodowithI/Oandwiththefilesystem thatwillnotbediscussed.Forexample:closeafile,getthestatusofafile,changetheprotection modeortheownerofafile,createadirectory,makealinktoanexistingfile,deleteafile. IV.IMPLEMENTATIONOFTHEFILESYSTEM AsmentionedinSection3.2above,adirectoryentrycontainsonlyanamefortheassociated fileandapointertothefileitself.Thispointerisanintegercalledthei-number(forindexnum-ber)ofthefile.Whenthefileisaccessed,itsi-numberisusedasanindexintoasystemtable (thei-list)storedinaknownpartofthedeviceonwhichthedirectoryresides.Theentryfound thereby(thefile’si-node)containsthedescriptionofthefile: itheuserandgroup-IDofitsowner iiitsprotectionbits iiithephysicaldiskortapeaddressesforthefilecontents ivitssize vtimeofcreation,lastuse,andlastmodification vithenumberoflinkstothefile,thatis,thenumberoftimesitappearsinadirectory viiacodeindicatingwhetherthefileisadirectory,anordinaryfile,oraspecialfile. Thepurposeofanopenorcreatesystemcallistoturnthepathnamegivenbytheuserintoan i-numberbysearchingtheexplicitlyorimplicitlynameddirectories.Onceafileisopen,its device,i-number,andread/writepointerarestoredinasystemtableindexedbythefiledescrip-torreturnedbytheopenorcreate.Thus,duringasubsequentcalltoreadorwritethefile,the descriptormaybeeasilyrelatedtotheinformationnecessarytoaccessthefile. Whenanewfileiscreated,ani-nodeisallocatedforitandadirectoryentryismadethat containsthenameofthefileandthei-nodenumber.Makingalinktoanexistingfileinvolves creatingadirectoryentrywiththenewname,copyingthei-numberfromtheoriginalfileentry, andincrementingthelink-countfieldofthei-node.Removing(deleting)afileisdonebydecre-mentingthelink-countofthei-nodespecifiedbyitsdirectoryentryanderasingthedirectory entry.Ifthelink-countdropsto0,anydiskblocksinthefilearefreedandthei-nodeisde-allocated. Thespaceonalldisksthatcontainafilesystemisdividedintoanumberof512-byteblocks logicallyaddressedfrom0uptoalimitthatdependsonthedevice.Thereisspaceinthei-node ofeachfilefor13deviceaddresses.Fornonspecialfiles,thefirst10deviceaddressespointatthe first10blocksofthefile.Ifthefileislargerthan10blocks,the11deviceaddresspointstoan indirectblockcontainingupto128addressesofadditionalblocksinthefile.Stilllargerfilesuse thetwelfthdeviceaddressofthei-nodetopointtoadouble-indirectblocknaming128indirect blocks,eachpointingto128blocksofthefile.Ifrequired,thethirteenthdeviceaddressisa triple-indirectblock.Thusfilesmayconceptuallygrowto[(10+128+1282+1283).512]bytes. Onceopened,bytesnumberedbelow5120canbereadwithasinglediskaccess;bytesintherange 5120to70,656requiretwoaccesses;bytesintherange70,656to8,459,264requirethreeaccesses; bytesfromtheretothelargestfile(1,082,201,088)requirefouraccesses.Inpractice,adevice cachemechanism(seebelow)proveseffectiveineliminatingmostoftheindirectfetches. Theforegoingdiscussionappliestoordinaryfiles.WhenanI/Orequestismadetoafile whosei-nodeindicatesthatitisspecial,thelast12deviceaddresswordsareimmaterial,andthe firstspecifiesaninternaldevicename,whichisinterpretedasapairofnumbersrepresenting, -7-respectively,adevicetypeandsubdevicenumber.Thedevicetypeindicateswhichsystemroutine willdealwithI/Oonthatdevice;thesubdevicenumberselects,forexample,adiskdriveattached toaparticularcontrolleroroneofseveralsimilarterminalinterfaces. Inthisenvironment,theimplementationofthemountsystemcall(Section3.4)isquite straightforward.mountmaintainsasystemtablewhoseargumentisthei-numberanddevice nameoftheordinaryfilespecifiedduringthemount,andwhosecorrespondingvalueisthedevice nameoftheindicatedspecialfile.Thistableissearchedforeachi-number/devicepairthatturns upwhileapathnameisbeingscannedduringanopenorcreate;ifamatchisfound,theinumberisreplacedbythei-numberoftherootdirectoryandthedevicenameisreplacedbythe tablevalue. Totheuser,bothreadingandwritingoffilesappeartobesynchronousandunbuffered. Thatis,immediatelyafterreturnfromareadcallthedataareavailable;conversely,afterawrite theuser’sworkspacemaybereused.Infact,thesystemmaintainsarathercomplicatedbuffering mechanismthatreducesgreatlythenumberofI/Ooperationsrequiredtoaccessafile.Supposea writecallismadespecifyingtransmissionofasinglebyte.Thesystemwillsearchitsbuffersto seewhethertheaffecteddiskblockcurrentlyresidesinmainmemory;ifnot,itwillbereadin fromthedevice.Thentheaffectedbyteisreplacedinthebufferandanentryismadeinalistof blockstobewritten.Thereturnfromthewritecallmaythentakeplace,althoughtheactual I/Omaynotbecompleteduntilalatertime.Conversely,ifasinglebyteisread,thesystem determineswhetherthesecondarystorageblockinwhichthebyteislocatedisalreadyinoneof thesystem’sbuffers;ifso,thebytecanbereturnedimmediately.Ifnot,theblockisreadintoa bufferandthebytepickedout. Thesystemrecognizeswhenaprogramhasmadeaccessestosequentialblocksofafile,and asynchronouslypre-readsthenextblock.Thissignificantlyreducestherunningtimeofmostpro-gramswhileaddinglittletosystemoverhead. Aprogramthatreadsorwritesfilesinunitsof512byteshasanadvantageoveraprogram thatreadsorwritesasinglebyteatatime,butthegainisnotimmense;itcomesmainlyfromthe avoidanceofsystemoverhead.IfaprogramisusedrarelyordoesnogreatvolumeofI/O,itmay quitereasonablyreadandwriteinunitsassmallasitwishes. Thenotionofthei-listisanunusualfeatureofUNIX.Inpractice,thismethodoforganizing thefilesystemhasprovedquitereliableandeasytodealwith.Tothesystemitself,oneofits strengthsisthefactthateachfilehasashort,unambiguousnamerelatedinasimplewaytothe protection,addressing,andotherinformationneededtoaccessthefile.Italsopermitsaquite simpleandrapidalgorithmforcheckingtheconsistencyofafilesystem,forexample,verification thattheportionsofeachdevicecontainingusefulinformationandthosefreetobeallocatedare disjointandtogetherexhaustthespaceonthedevice.Thisalgorithmisindependentofthedirectoryhierarchy,becauseitneedonlyscanthelinearlyorganizedi-list.Atthesametimethenotion ofthei-listinducescertainpeculiaritiesnotfoundinotherfilesystemorganizations.Forexample, thereisthequestionofwhoistobechargedforthespaceafileoccupies,becausealldirectory entriesforafilehaveequalstatus.Chargingtheownerofafileisunfairingeneral,foroneuser maycreateafile,anothermaylinktoit,andthefirstusermaydeletethefile.Thefirstuseris stilltheownerofthefile,butitshouldbechargedtotheseconduser.Thesimplestreasonably fairalgorithmseemstobetospreadthechargesequallyamonguserswhohavelinkstoafile. Manyinstallationsavoidtheissuebynotcharginganyfeesatall. V.PROCESSESANDIMAGES Animageisacomputerexecutionenvironment.Itincludesamemoryimage,generalregistervalues,statusofopenfiles,currentdirectoryandthelike.Animageisthecurrentstateofa pseudo-computer. Aprocessistheexecutionofanimage.Whiletheprocessorisexecutingonbehalfofaprocess,theimagemustresideinmainmemory;duringtheexecutionofotherprocessesitremainsin mainmemoryunlesstheappearanceofanactive,higher-priorityprocessforcesittobeswapped -8-outtothedisk. Theuser-memorypartofanimageisdividedintothreelogicalsegments.Theprogramtext segmentbeginsatlocation0inthevirtualaddressspace.Duringexecution,thissegmentiswriteprotectedandasinglecopyofitissharedamongallprocessesexecutingthesameprogram.At thefirsthardwareprotectionbyteboundaryabovetheprogramtextsegmentinthevirtual addressspacebeginsanon-shared,writabledatasegment,thesizeofwhichmaybeextendedbya systemcall.Startingatthehighestaddressinthevirtualaddressspaceisastacksegment,which automaticallygrowsdownwardasthestackpointerfluctuates. 5.1Processes Exceptwhilethesystemisbootstrappingitselfintooperation,anewprocesscancomeinto existenceonlybyuseoftheforksystemcall: processid=fork() Whenforkisexecuted,theprocesssplitsintotwoindependentlyexecutingprocesses.Thetwo processeshaveindependentcopiesoftheoriginalmemoryimage,andshareallopenfiles.The newprocessesdifferonlyinthatoneisconsideredtheparentprocess:intheparent,thereturned processidactuallyidentifiesthechildprocessandisnever0,whileinthechild,thereturned valueisalways0. Becausethevaluesreturnedbyforkintheparentandchildprocessaredistinguishable, eachprocessmaydeterminewhetheritistheparentorchild. 5.2Pipes Processesmaycommunicatewithrelatedprocessesusingthesamesystemreadandwrite callsthatareusedforfile-systemI/O.Thecall: filep=pipe() returnsafiledescriptorfilepandcreatesaninter-processchannelcalledapipe.Thischannel,like otheropenfiles,ispassedfromparenttochildprocessintheimagebytheforkcall.Aread usingapipefiledescriptorwaitsuntilanotherprocesswritesusingthefiledescriptorforthesame pipe.Atthispoint,dataarepassedbetweentheimagesofthetwoprocesses.Neitherprocess needknowthatapipe,ratherthananordinaryfile,isinvolved. Althoughinter-processcommunicationviapipesisaquitevaluabletool(seeSection6.2),it isnotacompletelygeneralmechanism,becausethepipemustbesetupbyacommonancestorof theprocessesinvolved. 5.3Executionofprograms Anothermajorsystemprimitiveisinvokedby execute(file,arg1,arg2,...,argn) whichrequeststhesystemtoreadinandexecutetheprogramnamedbyfile,passingitstring argumentsarg1,arg2,...,argn.Allthecodeanddataintheprocessinvokingexecuteis replacedfromthefile,butopenfiles,currentdirectory,andinter-processrelationshipsareunal-tered.Onlyifthecallfails,forexamplebecausefilecouldnotbefoundorbecauseitsexecute-permissionbitwasnotset,doesareturntakeplacefromtheexecuteprimitive;itresemblesa ‘‘jump’’machineinstructionratherthanasubroutinecall. 5.4Processsynchronization Anotherprocesscontrolsystemcall: processid=wait(status) causesitscallertosuspendexecutionuntiloneofitschildrenhascompletedexecution.Then -9-waitreturnstheprocessidoftheterminatedprocess.Anerrorreturnistakenifthecallingpro-cesshasnodescendants.Certainstatusfromthechildprocessisalsoavailable. 5.5Termination Lastly: exit(status) terminatesaprocess,destroysitsimage,closesitsopenfiles,andgenerallyobliteratesit.The parentisnotifiedthroughthewaitprimitive,andstatusismadeavailabletoit.Processesmay alsoterminateasaresultofvariousillegalactionsoruser-generatedsignals(SectionVIIbelow). VI.THESHELL Formostusers,communicationwiththesystemiscarriedonwiththeaidofaprogram calledtheshell.Theshellisacommand-lineinterpreter:itreadslinestypedbytheuserand interpretsthemasrequeststoexecuteotherprograms.(Theshellisdescribedfullyelsewhere,9so thissectionwilldiscussonlythetheoryofitsoperation.)Insimplestform,acommandlineconsistsofthecommandnamefollowedbyargumentstothecommand,allseparatedbyspaces: commandarg1arg2...argn Theshellsplitsupthecommandnameandtheargumentsintoseparatestrings.Thenafilewith namecommandissought;commandmaybeapathnameincludingthe‘‘/’’charactertospecify anyfileinthesystem.Ifcommandisfound,itisbroughtintomemoryandexecuted.Theargumentscollectedbytheshellareaccessibletothecommand.Whenthecommandisfinished,the shellresumesitsownexecution,andindicatesitsreadinesstoacceptanothercommandbytyping apromptcharacter. Iffilecommandcannotbefound,theshellgenerallyprefixesastringsuchas/bin/to commandandattemptsagaintofindthefile.Directory/bincontainscommandsintendedto begenerallyused.(Thesequenceofdirectoriestobesearchedmaybechangedbyuserrequest.) 6.1StandardI/O ThediscussionofI/OinSectionIIIaboveseemstoimplythateveryfileusedbyaprogram mustbeopenedorcreatedbytheprograminordertogetafiledescriptorforthefile.Programs executedbytheshell,however,startoffwiththreeopenfileswithfiledescriptors0,1,and2.As suchaprogrambeginsexecution,file1isopenforwriting,andisbestunderstoodasthestandard outputfile.Exceptundercircumstancesindicatedbelow,thisfileistheuser’sterminal.Thus programsthatwishtowriteinformativeinformationordinarilyusefiledescriptor1.Conversely, file0startsoffopenforreading,andprogramsthatwishtoreadmessagestypedbytheuserread thisfile. Theshellisabletochangethestandardassignmentsofthesefiledescriptorsfromtheuser’s terminalprinterandkeyboard.Ifoneoftheargumentstoacommandisprefixedby‘‘>’’,file descriptor1will,forthedurationofthecommand,refertothefilenamedafterthe‘‘>’’.For example: ls ordinarilylists,onthetypewriter,thenamesofthefilesinthecurrentdirectory.Thecommand: ls>there createsafilecalledthereandplacesthelistingthere.Thustheargument>theremeans‘‘place outputonthere.’’Ontheotherhand: ed ordinarilyenterstheeditor,whichtakesrequestsfromtheuserviahiskeyboard.Thecommand -10-ed<script interpretsscriptasafileofeditorcommands;thus<scriptmeans‘‘takeinputfromscript.’’ Althoughthefilenamefollowing‘‘<’’or‘‘>’’appearstobeanargumenttothecommand,in factitisinterpretedcompletelybytheshellandisnotpassedtothecommandatall.Thusno specialcodingtohandleI/Oredirectionisneededwithineachcommand;thecommandneed merelyusethestandardfiledescriptors0and1whereappropriate. Filedescriptor2is,likefile1,ordinarilyassociatedwiththeterminaloutputstream.When anoutput-diversionrequestwith‘‘>’’isspecified,file2remainsattachedtotheterminal,sothat commandsmayproducediagnosticmessagesthatdonotsilentlyendupintheoutputfile. 6.2Filters AnextensionofthestandardI/Onotionisusedtodirectoutputfromonecommandtothe inputofanother.Asequenceofcommandsseparatedbyverticalbarscausestheshelltoexecute allthecommandssimultaneouslyandtoarrangethatthestandardoutputofeachcommandbe deliveredtothestandardinputofthenextcommandinthesequence.Thusinthecommandline: ls|pr−2|opr lsliststhenamesofthefilesinthecurrentdirectory;itsoutputispassedtopr,whichpaginates itsinputwithdatedheadings.(Theargument‘‘−2’’requestsdouble-columnoutput.)Likewise, theoutputfromprisinputtoopr;thiscommandspoolsitsinputontoafileforoff-lineprinting. Thisprocedurecouldhavebeencarriedoutmoreclumsilyby: ls>temp1 pr−2<temp1>temp2 opr<temp2 followedbyremovalofthetemporaryfiles.Intheabsenceoftheabilitytoredirectoutputand input,astillclumsiermethodwouldhavebeentorequirethelscommandtoacceptuserrequests topaginateitsoutput,toprintinmulti-columnformat,andtoarrangethatitsoutputbedeliv-eredoff-line.Actuallyitwouldbesurprising,andinfactunwiseforefficiencyreasons,toexpect authorsofcommandssuchaslstoprovidesuchawidevarietyofoutputoptions. Aprogramsuchasprwhichcopiesitsstandardinputtoitsstandardoutput(withprocessing)iscalledafilter.Somefiltersthatwehavefoundusefulperformcharactertransliteration, selectionoflinesaccordingtoapattern,sortingoftheinput,andencryptionanddecryption. 6.3Commandseparators;multitasking Anotherfeatureprovidedbytheshellisrelativelystraightforward.Commandsneednotbe ondifferentlines;insteadtheymaybeseparatedbysemicolons: ls;ed willfirstlistthecontentsofthecurrentdirectory,thenentertheeditor. Arelatedfeatureismoreinteresting.Ifacommandisfollowedby‘‘&,’’theshellwillnot waitforthecommandtofinishbeforepromptingagain;instead,itisreadyimmediatelytoaccept anewcommand.Forexample: assource>output& causessourcetobeassembled,withdiagnosticoutputgoingtooutput;nomatterhowlongthe assemblytakes,theshellreturnsimmediately.Whentheshelldoesnotwaitforthecompletionof acommand,theidentificationnumberoftheprocessrunningthatcommandisprinted.This identificationmaybeusedtowaitforthecompletionofthecommandortoterminateit.The ‘‘&’’maybeusedseveraltimesinaline:

-11-assource>output&ls>files& doesboththeassemblyandthelistinginthebackground.Intheseexamples,anoutputfileother thantheterminalwasprovided;ifthishadnotbeendone,theoutputsofthevariouscommands wouldhavebeenintermingled. Theshellalsoallowsparenthesesintheaboveoperations.Forexample: (date;ls)>x& writesthecurrentdateandtimefollowedbyalistofthecurrentdirectoryontothefilex.The shellalsoreturnsimmediatelyforanotherrequest. 6.4Theshellasacommand;commandfiles Theshellisitselfacommand,andmaybecalledrecursively.Supposefiletryoutcontains thelines: assource mva.outtestprog testprog Themvcommandcausesthefilea.outtoberenamedtestprog.a.outisthe(binary)outputof theassembler,readytobeexecuted.Thusifthethreelinesaboveweretypedonthekeyboard, sourcewouldbeassembled,theresultingprogramrenamedtestprog,andtestprogexecuted. Whenthelinesareintryout,thecommand: sh<tryout wouldcausetheshellshtoexecutethecommandssequentially. Theshellhasfurthercapabilities,includingtheabilitytosubstituteparametersandtoconstructargumentlistsfromaspecifiedsubsetofthefilenamesinadirectory.Italsoprovidesgeneralconditionalandloopingconstructions. 6.5Implementationoftheshell Theoutlineoftheoperationoftheshellcannowbeunderstood.Mostofthetime,theshell iswaitingfortheusertotypeacommand.Whenthenewlinecharacterendingthelineistyped, theshell’sreadcallreturns.Theshellanalyzesthecommandline,puttingtheargumentsina formappropriateforexecute.Thenforkiscalled.Thechildprocess,whosecodeofcourseis stillthatoftheshell,attemptstoperformanexecutewiththeappropriatearguments.Ifsuccessful,thiswillbringinandstartexecutionoftheprogramwhosenamewasgiven.Meanwhile, theotherprocessresultingfromthefork,whichistheparentprocess,waitsforthechildprocess todie.Whenthishappens,theshellknowsthecommandisfinished,soittypesitspromptand readsthekeyboardtoobtainanothercommand. Giventhisframework,theimplementationofbackgroundprocessesistrivial;whenevera commandlinecontains‘‘&,’’theshellmerelyrefrainsfromwaitingfortheprocessthatitcreated toexecutethecommand. Happily,allofthismechanismmeshesverynicelywiththenotionofstandardinputand outputfiles.Whenaprocessiscreatedbytheforkprimitive,itinheritsnotonlythememory imageofitsparentbutalsoallthefilescurrentlyopeninitsparent,includingthosewithfile descriptors0,1,and2.Theshell,ofcourse,usesthesefilestoreadcommandlinesandtowrite itspromptsanddiagnostics,andintheordinarycaseitschildren—thecommandprograms— inheritthemautomatically.Whenanargumentwith‘‘<’’or‘‘>’’isgiven,however,theoffspring process,justbeforeitperformsexecute,makesthestandardI/Ofiledescriptor(0or1,respectively)refertothenamedfile.Thisiseasybecause,byagreement,thesmallestunusedfile descriptorisassignedwhenanewfileisopened(orcreated);itisonlynecessarytoclosefile0 (or1)andopenthenamedfile.Becausetheprocessinwhichthecommandprogramrunssimply terminateswhenitisthrough,theassociationbetweenafilespecifiedafter‘‘<’’or‘‘>’’andfile -12-descriptor0or1isendedautomaticallywhentheprocessdies.Thereforetheshellneednotknow theactualnamesofthefilesthatareitsownstandardinputandoutput,becauseitneednever reopenthem. FiltersarestraightforwardextensionsofstandardI/Oredirectionwithpipesusedinsteadof files. Inordinarycircumstances,themainloopoftheshellneverterminates.(Themainloop includesthebranchofthereturnfromforkbelongingtotheparentprocess;thatis,thebranch thatdoesawait,thenreadsanothercommandline.)Theonethingthatcausestheshelltoterminateisdiscoveringanend-of-fileconditiononitsinputfile.Thus,whentheshellisexecutedas acommandwithagiveninputfile,asin: sh<comfile thecommandsincomfilewillbeexecuteduntiltheendofcomfileisreached;thentheinstance oftheshellinvokedbyshwillterminate.Becausethisshellprocessisthechildofanother instanceoftheshell,thewaitexecutedinthelatterwillreturn,andanothercommandmaythen beprocessed. 6.6Initialization Theinstancesoftheshelltowhichuserstypecommandsarethemselveschildrenofanother process.Thelaststepintheinitializationofthesystemisthecreationofasingleprocessandthe invocation(viaexecute)ofaprogramcalledinit.Theroleofinitistocreateoneprocessfor eachterminalchannel.Thevarioussubinstancesofinitopentheappropriateterminalsforinput andoutputonfiles0,1,and2,waiting,ifnecessary,forcarriertobeestablishedondial-uplines. Thenamessageistypedoutrequestingthattheuserlogin.Whentheusertypesanameor otheridentification,theappropriateinstanceofinitwakesup,receivesthelog-inline,andreadsa passwordfile.Iftheuser’snameisfound,andifheisabletosupplythecorrectpassword,init changestotheuser’sdefaultcurrentdirectory,setstheprocess’suserIDtothatofthepersonloggingin,andperformsanexecuteoftheshell.Atthispoint,theshellisreadytoreceivecommandsandthelogging-inprotocoliscomplete. Meanwhile,themainstreampathofinit(theparentofallthesubinstancesofitselfthatwill laterbecomeshells)doesawait.Ifoneofthechildprocessesterminates,eitherbecauseashell foundanendoffileorbecauseausertypedanincorrectnameorpassword,thispathofinitsimplyrecreatesthedefunctprocess,whichinturnreopenstheappropriateinputandoutputfiles andtypesanotherlog-inmessage.Thusausermaylogoutsimplybytypingtheend-of-file sequencetotheshell. 6.7Otherprogramsasshell Theshellasdescribedaboveisdesignedtoallowusersfullaccesstothefacilitiesofthesystem,becauseitwillinvoketheexecutionofanyprogramwithappropriateprotectionmode. Sometimes,however,adifferentinterfacetothesystemisdesirable,andthisfeatureiseasily arrangedfor. Recallthatafterauserhassuccessfullyloggedinbysupplyinganameandpassword,init ordinarilyinvokestheshelltointerpretcommandlines.Theuser’sentryinthepasswordfilemay containthenameofaprogramtobeinvokedafterlog-ininsteadoftheshell.Thisprogramisfree tointerprettheuser’smessagesinanywayitwishes. Forexample,thepasswordfileentriesforusersofasecretarialeditingsystemmightspecify thattheeditoredistobeusedinsteadoftheshell.Thuswhenusersoftheeditingsystemlogin, theyareinsidetheeditorandcanbeginworkimmediately;also,theycanbepreventedfrom invokingprogramsnotintendedfortheiruse.Inpractice,ithasproveddesirabletoallowatemporaryescapefromtheeditortoexecutetheformattingprogramandotherutilities. Severalofthegames(e.g.,chess,blackjack,3Dtic-tac-toe)availableonthesystemillustrate amuchmoreseverelyrestrictedenvironment.Foreachofthese,anentryexistsinthepassword -13-filespecifyingthattheappropriategame-playingprogramistobeinvokedinsteadoftheshell. Peoplewhologinasaplayerofoneofthesegamesfindthemselveslimitedtothegameand unabletoinvestigatethe(presumablymoreinteresting)offeringsoftheUNIXsystemasawhole. VII.TRAPS ThePDP-11hardwaredetectsanumberofprogramfaults,suchasreferencestonon-existent memory,unimplementedinstructions,andoddaddressesusedwhereanevenaddressisrequired. Suchfaultscausetheprocessortotraptoasystemroutine.Unlessotherarrangementshavebeen made,anillegalactioncausesthesystemtoterminatetheprocessandtowriteitsimageonfile coreinthecurrentdirectory.Adebuggercanbeusedtodeterminethestateoftheprogramat thetimeofthefault. Programsthatarelooping,thatproduceunwantedoutput,oraboutwhichtheuserhassecondthoughtsmaybehaltedbytheuseoftheinterruptsignal,whichisgeneratedbytypingthe ‘‘delete’’character.Unlessspecialactionhasbeentaken,thissignalsimplycausestheprogramto ceaseexecutionwithoutproducingacorefile.Thereisalsoaquitsignalusedtoforceanimage filetobeproduced.Thusprogramsthatloopunexpectedlymaybehaltedandtheremains inspectedwithoutprearrangement. Thehardware-generatedfaultsandtheinterruptandquitsignalscan,byrequest,beeither ignoredorcaughtbyaprocess.Forexample,theshellignoresquitstopreventaquitfromloggingtheuserout.Theeditorcatchesinterruptsandreturnstoitscommandlevel.Thisisuseful forstoppinglongprintoutswithoutlosingworkinprogress(theeditormanipulatesacopyofthe fileitisediting).Insystemswithoutfloating-pointhardware,unimplementedinstructionsare caughtandfloating-pointinstructionsareinterpreted. VIII.PERSPECTIVE Perhapsparadoxically,thesuccessoftheUNIXsystemislargelyduetothefactthatitwas notdesignedtomeetanypredefinedobjectives.Thefirstversionwaswrittenwhenoneofus (Thompson),dissatisfiedwiththeavailablecomputerfacilities,discoveredalittle-usedPDP-7and setouttocreateamorehospitableenvironment.This(essentiallypersonal)effortwassufficiently successfultogaintheinterestoftheotherauthorandseveralcolleagues,andlatertojustifythe acquisitionofthePDP-11/20,specificallytosupportatexteditingandformattingsystem.When inturnthe11/20wasoutgrown,thesystemhadprovedusefulenoughtopersuademanagementto investinthePDP-11/45,andlaterinthePDP-11/70andInterdata8/32machines,uponwhichit developedtoitspresentform.Ourgoalsthroughouttheeffort,whenarticulatedatall,have alwaysbeentobuildacomfortablerelationshipwiththemachineandtoexploreideasandinventionsinoperatingsystemsandothersoftware.Wehavenotbeenfacedwiththeneedtosatisfy someoneelse’srequirements,andforthisfreedomwearegrateful. ThreeconsiderationsthatinfluencedthedesignofUNIXarevisibleinretrospect. First:becauseweareprogrammers,wenaturallydesignedthesystemtomakeiteasyto write,test,andrunprograms.Themostimportantexpressionofourdesireforprogrammingconveniencewasthatthesystemwasarrangedforinteractiveuse,eventhoughtheoriginalversion onlysupportedoneuser.Webelievethataproperlydesignedinteractivesystemismuchmore productiveandsatisfyingtousethana‘‘batch’’system.Moreover,suchasystemisrathereasily adaptabletononinteractiveuse,whiletheconverseisnottrue. Second:therehavealwaysbeenfairlyseveresizeconstraintsonthesystemanditssoftware. Giventhepartiallyantagonisticdesiresforreasonableefficiencyandexpressivepower,thesize constrainthasencouragednotonlyeconomy,butalsoacertaineleganceofdesign.Thismaybea thinlydisguisedversionofthe‘‘salvationthroughsuffering’’philosophy,butinourcaseitworked. Third:nearlyfromthestart,thesystemwasableto,anddid,maintainitself.Thisfactis moreimportantthanitmightseem.Ifdesignersofasystemareforcedtousethatsystem,they quicklybecomeawareofitsfunctionalandsuperficialdeficienciesandarestronglymotivatedto correctthembeforeitistoolate.Becauseallsourceprogramswerealwaysavailableandeasily -14-modifiedon-line,wewerewillingtoreviseandrewritethesystemanditssoftwarewhennewideas wereinvented,discovered,orsuggestedbyothers. TheaspectsofUNIXdiscussedinthispaperexhibitclearlyatleastthefirsttwoofthese designconsiderations.Theinterfacetothefilesystem,forexample,isextremelyconvenientfrom aprogrammingstandpoint.Thelowestpossibleinterfacelevelisdesignedtoeliminatedistinctionsbetweenthevariousdevicesandfilesandbetweendirectandsequentialaccess.Nolarge ‘‘accessmethod’’routinesarerequiredtoinsulatetheprogrammerfromthesystemcalls;infact, alluserprogramseithercallthesystemdirectlyoruseasmalllibraryprogram,lessthanapage long,thatbuffersanumberofcharactersandreadsorwritesthemallatonce. Anotherimportantaspectofprogrammingconvenienceisthatthereareno‘‘controlblocks’’ withacomplicatedstructurepartiallymaintainedbyanddependedonbythefilesystemorother systemcalls.Generallyspeaking,thecontentsofaprogram’saddressspacearethepropertyof theprogram,andwehavetriedtoavoidplacingrestrictionsonthedatastructureswithinthat addressspace. Giventherequirementthatallprogramsshouldbeusablewithanyfileordeviceasinputor output,itisalsodesirabletopushdevice-dependentconsiderationsintotheoperatingsystem itself.Theonlyalternativesseemtobetoload,withallprograms,routinesfordealingwitheach device,whichisexpensiveinspace,ortodependonsomemeansofdynamicallylinkingtothe routineappropriatetoeachdevicewhenitisactuallyneeded,whichisexpensiveeitherinoverheadorinhardware. Likewise,theprocess-controlschemeandthecommandinterfacehaveprovedbothcon-venientandefficient.Becausetheshelloperatesasanordinary,swappableuserprogram,itcon-sumesno‘‘wired-down’’spaceinthesystemproper,anditmaybemadeaspowerfulasdesiredat littlecost.Inparticular,giventheframeworkinwhichtheshellexecutesasaprocessthatspawns otherprocessestoperformcommands,thenotionsofI/Oredirection,backgroundprocesses,commandfiles,anduser-selectablesysteminterfacesallbecomeessentiallytrivialtoimplement. Influences ThesuccessofUNIXliesnotsomuchinnewinventionsbutratherinthefullexploitationof acarefullyselectedsetoffertileideas,andespeciallyinshowingthattheycanbekeystothe implementationofasmallyetpowerfuloperatingsystem. Theforkoperation,essentiallyasweimplementedit,waspresentintheGENIEtime-sharing system.10OnanumberofpointswewereinfluencedbyMultics,whichsuggestedtheparticular formoftheI/Osystemcalls11andboththenameoftheshellanditsgeneralfunctions.The notionthattheshellshouldcreateaprocessforeachcommandwasalsosuggestedtousbythe earlydesignofMultics,althoughinthatsystemitwaslaterdroppedforefficiencyreasons.A similarschemeisusedbyTENEX.12 IX.STATISTICS ThefollowingnumbersarepresentedtosuggestthescaleoftheResearchUNIXoperation. Thoseofourusersnotinvolvedindocumentpreparationtendtousethesystemforprogram development,especiallylanguagework.Therearefewimportant‘‘applications’’programs. Overall,wehavetoday: 125userpopulation 33maximumsimultaneoususers 1,630directories 28,300files 301,700512-bytesecondarystorageblocksused Thereisa‘‘background’’processthatrunsatthelowestpossiblepriority;itisusedtosoakupany idleCPUtime.Ithasbeenusedtoproduceamillion-digitapproximationtotheconstante,and -15-othersemi-infiniteproblems.Notcountingthisbackgroundwork,weaveragedaily: 13,500commands 9.6CPUhours 230connecthours 62differentusers 240log-ins X.ACKNOWLEDGMENTS ThecontributorstoUNIXare,inthetraditionalbuthereespeciallyappositephrase,too numeroustomention.Certainly,collectivesalutesareduetoourcolleaguesintheComputing ScienceResearchCenter.R.H.Canadaycontributedmuchtothebasicdesignofthefilesystem. Weareparticularlyappreciativeoftheinventiveness,thoughtfulcriticism,andconstantsupportof R.Morris,M.D.McIlroy,andJ.F.Ossanna. References 1. 2. 3.Thisissue. 4. 5.Thisissue. 6.Thisissue. 7. 8. 9.Thisissue. 10. 11. 12.