The Unix Time-Sharing System

Download Report

Transcript The Unix Time-Sharing System

The Unix Time-sharing System
Chuck Davin
Software Design & Engineering
CSE 350
Spring 2001
CSE 350, Spring 2001
JMS 1
The Unix Time-sharing System
• D. M. Ritchie and K. Thompson.
The Unix time-sharing system.
BSTJ, 57:6 (July-August, 1978), 1905-1929.
• K. Thompson.
Unix implementation.
BSTJ, 57:6 (July-August, 1978), 1931-1946.
CSE 350, Spring 2001
JMS 2
Features
• A hierarchical filesystem incorporating
demountable volumes
• Compatible file, device, interprocess
communication
• The ability to initiate asynchronous
processes
• System command language selectable on a
per-user basis
• Over 100 subsystems including a dozen
languages
• High degree of portability
CSE 350, Spring 2001
JMS 3
Unix History
• First version (ca. 1969-70) on DEC PDP-7 and
PDP-9.
• Second version on unprotected DEC PDP11/20.
• Third version with multiprogramming on PDP11/34, 40, 45, 60, 70.
• Fourth version on DEC PDP-11/70 and
Interdata 8/32.
February, 1971: PDP-11 Unix first operational.
Familiar epoch: midnight, January 1, 1970.
CSE 350, Spring 2001
JMS 4
Economics of the 1970s
• Hardware cost: $40,000
• Software cost: two man-years
• Cost recovery for disk space
CSE 350, Spring 2001
JMS 5
PDP-11/70 Platform
•
•
•
•
•
•
•
•
•
•
16-bit word (8-bit byte)
768 KBytes core memory
System kernel 90 KBytes
Minimal system 96 Kbytes
Two 200 MByte moving-head disks
20 variable speed (300 to 1200 baud) communication
interfaces
12 communication lines (9600 baud)
Synchronous interfaces (2400 and 4800 baud) for intermachine file transfer
Nine-track tape, line printer, phototypesetter
Voice synthesizer, digital switching network, chess
machine
CSE 350, Spring 2001
JMS 6
A Unix System in 1978
•
•
•
•
•
•
•
•
User population: 125
Maximum simultaneous users: 33
Directories: 1630
Files: 28300
Disk blocks (512-byte) used: 301,700
Daily command invocations: 13500
Daily (non-idle) CPU hours: 9.6
Daily connect hours: 230
CSE 350, Spring 2001
JMS 7
The C Programming Language
• System re-coded in C in summer, 1973
• 1/3 bigger than assembler language version
CSE 350, Spring 2001
JMS 8
Observation
"The most important role of the
system is to provide a file
system."
(Page 1907)
CSE 350, Spring 2001
JMS 9
Filesystem Properties
• Internal file structure controlled by
application programs
• Internal file structure not imposed by system
• Hierarchy
• Directories as files
• "." and ".." convention
• Links
• Restrictions on namespace topology
• Mountable volumes
CSE 350, Spring 2001
JMS 10
File Types
• Ordinary
• Directory
• Special
– Character
– Block
CSE 350, Spring 2001
JMS 11
Filesystem Representation
• i-Number
• i-List
• i-Node
CSE 350, Spring 2001
JMS 12
File Properties
•
•
•
•
•
•
•
•
•
•
Owner user-id
Owner group-id
Protection bits
Physical disk (or tape) address of contents
Size
Time of creation
Time of last use
Time of last modification
Number of links
File type
CSE 350, Spring 2001
JMS 13
File Protection
•
•
•
•
User (owner) read, write, execute
Group read, write, execute
Others read, write, execute
Set-user-id
--drwxwrxrwx
• "Execute" permission on directories
CSE 350, Spring 2001
JMS 14
Filesystem API
•
•
•
•
•
filep = open (name, flag)
filep = create (name)
n = read (filep, buffer, count)
n = write (filep, buffer, count)
location = lseek (filep, offset, base)
CSE 350, Spring 2001
JMS 15
File Space Management
• Blocks 0 through 9 indicated in i-Node
• Blocks 10 through 137 indicated indirectly
• Blocks 138 through 16521 indicated doubly
indirectly
• Blocks 16522 and higher indicated triply
indirectly
Performance Techniques: caching and readahead
CSE 350, Spring 2001
JMS 16
Special File Naming
• Example Name: /dev/foo
• Major Device Number: selects driver code
• Minor Device Number: selects device
instance within class
CSE 350, Spring 2001
JMS 17
File System Data Structure
CSE 350, Spring 2001
JMS 18
Process Management API
•
•
•
•
•
processid = fork ()
execute (file, arg1, ..., argN)
processid = wait (& status)
exit (status)
filep = pipe ()
• Traps, Signals
• Minimalist, integrated process
synchronization
CSE 350, Spring 2001
JMS 19
Process Control Data Structure
CSE 350, Spring 2001
JMS 20
The Shell and Reusability
•
•
•
•
•
•
Redirection
Stdin, stdout, stderr
Pipes and filters
Argument parsing and globbing
Multitasking
Basic control structures
CSE 350, Spring 2001
JMS 21
Perspective
"The success of the Unix
system is largely due to the
fact that it was not designed
to meet any predefined
objectives.“
(Page 1926)
Motivation: dissatisfaction with existing
facilities.
CSE 350, Spring 2001
JMS 22
Retrospective Design
Considerations
• Easy to write, test, run programs
– Interactive use
• Constraints on size
• Self-maintenance
– Available source code
CSE 350, Spring 2001
JMS 23
Easy Programming
• Device-independent file abstraction
• No "access methods"
• Few system constraints on program
CSE 350, Spring 2001
JMS 24
Influences
•
•
•
•
fork () from GENIE time-sharing system
I/O API from Multics
Shell concept from Multics
Implementing "system" code as user
primitives from Multics
CSE 350, Spring 2001
JMS 25
Unix Implementation
• 10,000 lines of C code
• 1,000 lines of assembler code
– 800 lines not possible in C
– 200 lines for efficiency
CSE 350, Spring 2001
JMS 26
Observation
"Throughout, simplicity has
been substituted for
efficiency."
(Page 1932)
CSE 350, Spring 2001
JMS 27
Observation
"The UNIX kernel is an I/O
multiplexer more than a
complete operating system.
This is as it should be."
(Page 1945)
CSE 350, Spring 2001
JMS 28
Unsupported Features
•
•
•
•
•
•
•
•
•
•
•
•
File access methods
File disposition
File formats
File maximum size
Spooling
Command language
Logical records
Physical records
Logical file names
Multiple character sets
Operator and operator console
Login and logout
CSE 350, Spring 2001
JMS 29