
t ·,) DRAFT The UNIX Time-Sha.ring Syste:n D. M. Ritchie 1· ~oduction UNIX is a general-purpose, multi-user time sharing system in- ) plernented on several Digital Equip~ent Corporation PDP series machines. UNIX was written by K. L. Tho::ipson, who also wrote many of the command prograns. The author of this meraorandurn contributed several of the major corilinands, including the assembler and tne debugger. The file system was originally designed by Thom?son, the author, and R.H. Canaday. There are two versions of UNIX. The first, which has been in ex- istence about a year, rtins on the PDP-7 and -9 coraput~rs; a more modern version, a few months old, uses the PD?-11. This docu,f'.ent describes U:-HX-11, since it is more modern and many of the dif- ferences between it and UNIX-7 result from redesign of features found to be deficient or lacking in the earlier system. Although the PDP-7 and PDP-11 are both small computers, the design of UNIX is amenable to expansion for use on more powerful machines. Indeed, UNIX contains a number of features w,~ry selc.om offered even by larger syste~s, including 1 o A versatile, conveni<?nt file system with co:nplete integra- tion between disk files and I/0 devices; .. - 2 - i " 2. The ability to initiate asynchrously running processes. It must be said, however, that the most important features of UNIX are its simplicity, elegance, and ease of use. Besides the system proper, the major programs available under UNIX are an assembler, a text editor based on QED, a symbolic debugger for examining and patching faulty programs, and " B " t a higher level language resembling BCPL. UNIX-7 also has a version of the compiler writini:r language TMGL contributed by M. D. ·~~ Mcilroy, and besides its own assembler, there~~ is a PDP-11 assembler which was used to write UNIX-11. On the PDP-11 there is a version of BASIC ·[reference] adapted from the one supplied by DEC [reference]. All but the last of these programs were written locally, and except for the very first versions of the editor and assembler, using UNIX itself. £• B:ardware The PDP-11 on 'i~hich UNIX is implemented is a 16-bit 1 2K computer, and UNIX occupies BK words. More than half of this space, however, is utilized for a variable number of disk buffers; with ) some loss of speed the number of buffers could be cut significantly. The PDP-11 has a 256K word disk, almost all of which is used for ) file system storage. It is equipped with DECTAPE, a variety of magnetic tape facility in which individual rRcords may be addres- sed and rewritten at will. Also available are a high-speed paper tape reader and punch. Bes ides the standarcJ Teletype, there ar'::! .. - 3 - several variable-speed communications inter.=aces. d• The File System The most important role of UNIX is to provide a file system. From the point of view of the user, there are three kinds of files: ordinary disk files, directories, and special files. -\ J 1•1 Ordinary Files A file contains whatever information the user places there, for example symbolic or binary (object) programs. No particular structuring is expected by the system. Files of text ordinarily consist simply of a string of characters, with lines demarcated by the new-line character. Binary programs are sequences of words as they will appear in core memory when the program starts executing. A few user programs generate and expect files with more structure; for example, the assembler genera~es, and the debugger expec~s, a name list file in a particular format; however, the structure of files is controlled solely by the programs which use them, not by the system. l•I Directories Directories (sometimes, "catalogs"), provide the mapping between the names of files and the files themselves, and thus induce a structure on the file system as a whole. Each user has a direc- tory of his own files; he may also create subdirectories to con- tain qroups of files conveniently treated together. ~ - 4 - A directory is exactly like an ordinary file except that it can- not be written on by user programs, so that the system controls the contents of directories. However, anyone with appropriate -) permission may read a directory just like any other file. The system maintains several directories for its own use. One of these is the root directory. All files in the system can be found by tracing a path through a chain of directories until the ) / desired file is reached. The starting point for such searches is often the root, which contains an entry for each user's master directory. Another system directory contains all the programs provided as part of the system; that is, all the commands (elsewhere, "subsystems"). As will be seen, however, it is by no means necessary that a program reside in this directory for it to be used as a command. Files and directories are named by sequences of eight or fewer characters. ·when the name of a file is specified to t:he system, it may be in the form of a path~' which is a sequence of directory names separated by slashes and ending in a file nameo If the sequence begins with a slash, the search begins in the root directory. The name "/a/b/c" causes the system to search the root for directory ..a ... then to search ..a .. for "b .. and then to .. .. .. ' ' find " C " in b. " C may be an ordinary file, a directory, or a special file. As a limiting case, the name "/" refers to the root ) itself. The same non-directory file may appear in several directories un­ der possibly different names. This feature is called "linking"; a directory entry for a file is so:netimes called a link. UNIX dif- - 5 - fers from other systems in which linking is permitted in that all links to a file have equal status. That is, a file does not ex- ist within a particular directory; the directory entry for a file --) consists merely of its name and a pointer to the information ac-· tually describing the file. Thus a file exists independently of any directory entry, although in practice a file is made to disappear along with the last link to it. When a user logs into UNIX, he is assigned a default current directory, but he may change to any directory·readable by him. A path name not starting with"/" causes the system to begin the search in the user's current directory. Thus, the name "a/b" specifies the file named "b" in directory "a", which is found in the current working directory. The simplest kind of name, for ex- ample " a," refers to a file which itself is found in the working directory. Each directory always·has at least two entries. The ·name"." in each directory,refers to the directory itself. Thus a program may read the current directory under the name " • " without knowing. its II II actual path name. The name • • by convention refers to the parent of the directory in which it appears; that is, the direc- tory in which it was first created. The directory structure is constrained to have the form of a ti " rooted tree. Except for the special entries • and " .. " ' each directory must appear as an entry in exactly one other, which is its parent. The reason for this is to simplify the writing of programs which visit subtrees of the directory structure, and more important, to avoid the separation of portions of the - 6 - hierarchy. If arbitrary links to directories were permitted, it would be quite difficult to detect when the last connection fro~ the root to a directory was severed. l•l Special Files Special files constitute the most unusual feature of the UNIX file system. Each I/0 device supported by UNIX is associated with \ ) at least one special file. Special files are read and written just like ordinary disk files, but the result· is activation of the associated device. Entries for all special files reside in the root directory, so they may all be referred to by "/" fol- lowed by the appropriate name. The special files are discussed further in section 6 below. 3.,1 Protection The protection scheme in UNIX is quite simple. Each user of the system is assigned a uniq-µe user number. When a file ·is created, it is marked with the number of its creator. Also given for new \ files is a set of protection bits. Four of these specify indepen- ) dently permission to read or write for the owner of the file and for all other users. A fifth bit indicates permission to execute the file as a program. If the sixth bit is on, the system will temporarily change the user identification of the current user to that of the creator of the file whenever the file is executed as a program. This feature provides for privileged programs which may use files which should neither be read nor changed by other users. If the set-user-identification bit is on for a program, ., - 7 - the accounting file may be accessed during the program's execu- tion but not otherwise. ) 1-~ System I/Q Calls The system calls to do I/0 are designed to eliminate the dif- ferences between the various devices and styles of access. There is no distinction between "random" and sequential I/o, nor is any logical or physical record size imposed by the system.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages53 Page
-
File Size-