📄 p5
字号:
.s17. Traps.esThe \*sPDP\*n-11 hardware detects a number of program faults,such as references to non-existent memory, unimplemented instructions,and odd addresses used where an even address is required.Such faults cause the processor to trap to a system routine.When an illegal action is caught,unless other arrangements have been made,the system terminates the process and writes theuser's imageon file \fIcore\fR in the current directory.A debugger can be used to determinethe state of the program at the time of the fault..pgPrograms which are looping, which produce unwanted output, or about whichthe user has second thoughts may be halted by the use of the.ft Iinterrupt.ft Rsignal, which is generated by typing the ``delete''character.Unless special action has been taken, thissignal simply causes the program to cease executionwithout producing a core image file..pgThere is also a \fIquit\fR signal whichis used to force a core image to be produced.Thus programs which loop unexpectedly may behalted and the core image examined without prearrangement..pgThe hardware-generated faultsand the interrupt and quit signalscan, by request, be either ignored or caught by the process.For example,the Shell ignores quits to preventa quit from logging the user out.The editor catches interrupts and returnsto its command level.This is useful for stopping long printoutswithout losing work in progress (the editormanipulates a copy of the file it is editing).In systems without floating point hardware,unimplemented instructions are caughtand floating point instructions areinterpreted..s18. Perspective.esPerhaps paradoxically,the success of \*sUNIX\*nis largely due to the fact that it was notdesigned to meet anypredefined objectives.The first version was written when one of us(Thompson),dissatisfied with the available computer facilities,discovered a little-used \*sPDP\*n-7and set out to create a morehospitable environment.This essentially personal effort wassufficiently successfulto gain the interest of the remaining authorand others,and later to justify the acquisitionof the \*sPDP\*n-11/20, specifically to supporta text editing and formatting system.When in turn the 11/20 was outgrown,\*sUNIX\*nhad proved useful enough to persuade management toinvest in the \*sPDP\*n-11/45.Our goals throughout the effort,when articulated at all, have always concerned themselveswith building a comfortable relationship with the machineand with exploring ideas and inventions in operating systems.We have not been faced with the need to satisfy someoneelse's requirements,and for this freedom we are grateful..pgThree considerations which influenced the design of \*sUNIX\*nare visible in retrospect..pgFirst:since we are programmers,we naturally designed the system to make it easy towrite, test, and run programs.The most important expression of our desire forprogramming conveniencewas that the systemwas arranged for interactive use,even though the original version onlysupported one user.We believe that a properly-designedinteractive system is much moreproductiveand satisfying to use than a ``batch'' system.Moreover such a system is rather easilyadaptable to non-interactive use, while the converse is not true..pgSecond:there have always been fairly severe size constraintson the system and its software.Given the partially antagonistic desires for reasonable efficiency andexpressive power,the size constraint has encouragednot only economy but a certain elegance of design.This may be a thinly disguised version of the ``salvationthrough suffering'' philosophy,but in our case it worked..pgThird: nearly from the start, the system was able to, and did, maintain itself.This fact is more important than it might seem.If designers of a system are forced to use that systemthey quickly become aware of its functional and superficial deficienciesand are strongly motivated to correct them before it is too late.Since all source programs were always availableand easily modified on-line,we were willing to revise and rewrite the system and its softwarewhen new ideas were invented, discovered,or suggested by others..pgThe aspects of \*sUNIX\*ndiscussed in this paper exhibit clearlyat least the first two of thesedesign considerations.The interface to the filesystem, for example, is extremely convenient froma programming standpoint.The lowest possible interface level is designedto eliminate distinctionsbetweenthe various devices and files and betweendirect and sequential access.No large ``access method'' routinesare requiredto insulate the programmer from thesystem calls;in fact all user programs either call the systemdirectly oruse a small library program, only tens of instructions long,which buffers a number of charactersand reads or writes them all at once..pgAnother important aspect of programmingconvenience is that there are no ``control blocks''with a complicated structure partially maintained byand depended on by the file system or other system calls.Generally speaking, the contents of a program's address spaceare the property of the program, and we have tried toavoid placing restrictionson the data structures within that address space..pgGiven the requirementthat all programs should be usable with any file ordevice as input or output,it is also desirablefrom a space-efficiency standpointto push device-dependent considerationsinto the operating system itself.The only alternatives seem to be to loadroutines for dealing with each devicewith all programs, which is expensive in space,or to depend on some means of dynamically linking tothe routine appropriate to each device when it is actuallyneeded,which is expensive either in overhead or in hardware..pgLikewise,the process control scheme and command interfacehave proved both convenient and efficient.Since the Shell operates as an ordinary, swappableuser program,it consumes no wired-down space in the system proper,and it may be made as powerful as desiredat little cost.In particular,given the framework in which the Shell executesas a process which spawns other processes toperform commands,the notions of I/O redirection, background processes,command files, and user-selectable system interfacesall become essentially trivial to implement..s28.1 Influences.esThe success of \*sUNIX\*n liesnot so much in new inventionsbut rather in the full exploitation of a carefully selectedset of fertile ideas,and especially in showing thatthey can be keys to the implementation of a smallyet powerful operating system..pgThe.it forkoperation, essentially as we implemented it, waspresent in the Berkeley time sharing system\*r.On a number of points we were influenced by Multics,which suggested the particular form of the I/O system calls\*rand both the name of the Shell and its general functions.The notion that the Shell should create a processfor each command was also suggested to us bythe early design of Multics, although in thatsystem it was later dropped for efficiency reasons.A similar scheme is used by \*sTENEX\*n\*r.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -