Research V6 development
[unix-history] / usr / doc / unix / p5
CommitLineData
9ddf7a71
DR
1.s1
27. Traps
3.es
4The \*sPDP\*n-11 hardware detects a number of program faults,
5such as references to non-existent memory, unimplemented instructions,
6and odd addresses used where an even address is required.
7Such faults cause the processor to trap to a system routine.
8When an illegal action is caught,
9unless other arrangements have been made,
10the system terminates the process and writes the
11user's image
12on file \fIcore\fR in the current directory.
13A debugger can be used to determine
14the state of the program at the time of the fault.
15.pg
16Programs which are looping, which produce unwanted output, or about which
17the user has second thoughts may be halted by the use of the
18.ft I
19interrupt
20.ft R
21signal, which is generated by typing the ``delete''
22character.
23Unless special action has been taken, this
24signal simply causes the program to cease execution
25without producing a core image file.
26.pg
27There is also a \fIquit\fR signal which
28is used to force a core image to be produced.
29Thus programs which loop unexpectedly may be
30halted and the core image examined without prearrangement.
31.pg
32The hardware-generated faults
33and the interrupt and quit signals
34can, by request, be either ignored or caught by the process.
35For example,
36the Shell ignores quits to prevent
37a quit from logging the user out.
38The editor catches interrupts and returns
39to its command level.
40This is useful for stopping long printouts
41without losing work in progress (the editor
42manipulates a copy of the file it is editing).
43In systems without floating point hardware,
44unimplemented instructions are caught
45and floating point instructions are
46interpreted.
47.s1
488. Perspective
49.es
50Perhaps paradoxically,
51the success of \*sUNIX\*n
52is largely due to the fact that it was not
53designed to meet any
54predefined objectives.
55The first version was written when one of us
56(Thompson),
57dissatisfied with the available computer facilities,
58discovered a little-used \*sPDP\*n-7
59and set out to create a more
60hospitable environment.
61This essentially personal effort was
62sufficiently successful
63to gain the interest of the remaining author
64and others,
65and later to justify the acquisition
66of the \*sPDP\*n-11/20, specifically to support
67a text editing and formatting system.
68When in turn the 11/20 was outgrown,
69\*sUNIX\*n
70had proved useful enough to persuade management to
71invest in the \*sPDP\*n-11/45.
72Our goals throughout the effort,
73when articulated at all, have always concerned themselves
74with building a comfortable relationship with the machine
75and with exploring ideas and inventions in operating systems.
76We have not been faced with the need to satisfy someone
77else's requirements,
78and for this freedom we are grateful.
79.pg
80Three considerations which influenced the design of \*sUNIX\*n
81are visible in retrospect.
82.pg
83First:
84since we are programmers,
85we naturally designed the system to make it easy to
86write, test, and run programs.
87The most important expression of our desire for
88programming convenience
89was that the system
90was arranged for interactive use,
91even though the original version only
92supported one user.
93We believe that a properly-designed
94interactive system is much more
95productive
96and satisfying to use than a ``batch'' system.
97Moreover such a system is rather easily
98adaptable to non-interactive use, while the converse is not true.
99.pg
100Second:
101there have always been fairly severe size constraints
102on the system and its software.
103Given the partially antagonistic desires for reasonable efficiency and
104expressive power,
105the size constraint has encouraged
106not only economy but a certain elegance of design.
107This may be a thinly disguised version of the ``salvation
108through suffering'' philosophy,
109but in our case it worked.
110.pg
111Third: nearly from the start, the system was able to, and did, maintain itself.
112This fact is more important than it might seem.
113If designers of a system are forced to use that system
114they quickly become aware of its functional and superficial deficiencies
115and are strongly motivated to correct them before it is too late.
116Since all source programs were always available
117and easily modified on-line,
118we were willing to revise and rewrite the system and its software
119when new ideas were invented, discovered,
120or suggested by others.
121.pg
122The aspects of \*sUNIX\*n
123discussed in this paper exhibit clearly
124at least the first two of these
125design considerations.
126The interface to the file
127system, for example, is extremely convenient from
128a programming standpoint.
129The lowest possible interface level is designed
130to eliminate distinctions
131between
132the various devices and files and between
133direct and sequential access.
134No large ``access method'' routines
135are required
136to insulate the programmer from the
137system calls;
138in fact all user programs either call the system
139directly or
140use a small library program, only tens of instructions long,
141which buffers a number of characters
142and reads or writes them all at once.
143.pg
144Another important aspect of programming
145convenience is that there are no ``control blocks''
146with a complicated structure partially maintained by
147and depended on by the file system or other system calls.
148Generally speaking, the contents of a program's address space
149are the property of the program, and we have tried to
150avoid placing restrictions
151on the data structures within that address space.
152.pg
153Given the requirement
154that all programs should be usable with any file or
155device as input or output,
156it is also desirable
157from a space-efficiency standpoint
158to push device-dependent considerations
159into the operating system itself.
160The only alternatives seem to be to load
161routines for dealing with each device
162with all programs, which is expensive in space,
163or to depend on some means of dynamically linking to
164the routine appropriate to each device when it is actually
165needed,
166which is expensive either in overhead or in hardware.
167.pg
168Likewise,
169the process control scheme and command interface
170have proved both convenient and efficient.
171Since the Shell operates as an ordinary, swappable
172user program,
173it consumes no wired-down space in the system proper,
174and it may be made as powerful as desired
175at little cost.
176In particular,
177given the framework in which the Shell executes
178as a process which spawns other processes to
179perform commands,
180the notions of I/O redirection, background processes,
181command files, and user-selectable system interfaces
182all become essentially trivial to implement.
183.s2
1848.1 Influences
185.es
186The success of \*sUNIX\*n lies
187not so much in new inventions
188but rather in the full exploitation of a carefully selected
189set of fertile ideas,
190and especially in showing that
191they can be keys to the implementation of a small
192yet powerful operating system.
193.pg
194The
195.it fork
196operation, essentially as we implemented it, was
197present in the Berkeley time sharing system\*r.
198On a number of points we were influenced by Multics,
199which suggested the particular form of the I/O system calls\*r
200and both the name of the Shell and its general functions.
201The notion that the Shell should create a process
202for each command was also suggested to us by
203the early design of Multics, although in that
204system it was later dropped for efficiency reasons.
205A similar scheme is used by \*sTENEX\*n\*r.