cse350 software design and engineering university of pennsylvania professor jonathan m. smith jms...

33
CSE350 Software Design and Engineering University of Pennsylvania Professor Jonathan M. Smith http://www.cis.upenn.edu/~jms Office: 254 Moore GRW, Phone: 8- 9509 January 9th, 2001

Post on 19-Dec-2015

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CSE350 Software Design and Engineering University of Pennsylvania Professor Jonathan M. Smith jms Office: 254 Moore GRW, Phone:

CSE350 Software Design and

Engineering

University of Pennsylvania

Professor Jonathan M. Smith

http://www.cis.upenn.edu/~jms

Office: 254 Moore GRW, Phone: 8-9509

January 9th, 2001

Page 2: CSE350 Software Design and Engineering University of Pennsylvania Professor Jonathan M. Smith jms Office: 254 Moore GRW, Phone:

Administrative

First group assignment Tuesday, 1/15

Groups will be formed todayWe will use

http://www.cis.upenn.edu/~cse350 as the class web site

It’s currently outdated – will fix

Page 3: CSE350 Software Design and Engineering University of Pennsylvania Professor Jonathan M. Smith jms Office: 254 Moore GRW, Phone:

What is an operating system?

An operating system manages hardware resources

Typically, for multiple users Protection, services such as file systems

(structure), concurrent execution, buffering, etc.

In UNIX (for example), OS functions are privileged – behind a protection boundary

Page 4: CSE350 Software Design and Engineering University of Pennsylvania Professor Jonathan M. Smith jms Office: 254 Moore GRW, Phone:

The Unix Time-sharing System(slides from J.R. Davin)

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.

Page 5: CSE350 Software Design and Engineering University of Pennsylvania Professor Jonathan M. Smith jms Office: 254 Moore GRW, Phone:

Features

A hierarchical filesystem incorporating demountable volumes

Compatible file, device, interprocess communication

The ability to initiate asynchronous processesSystem command language selectable on a

per-user basisOver 100 subsystems including a dozen

languagesHigh degree of portability

Page 6: CSE350 Software Design and Engineering University of Pennsylvania Professor Jonathan M. Smith jms Office: 254 Moore GRW, Phone:

Economics of the 1970s

Hardware cost: $40,000Software cost: two man-yearsCost recovery for disk space

Page 7: CSE350 Software Design and Engineering University of Pennsylvania Professor Jonathan M. Smith jms Office: 254 Moore GRW, Phone:

PDP-11/70 Platform

16-bit word (8-bit byte)768 KBytes core memorySystem kernel 90 KBytesMinimal system 96 KbytesTwo 200 MByte moving-head disks20 variable speed (300 to 1200 baud) communication

interfaces12 communication lines (9600 baud)Synchronous interfaces (2400 and 4800 baud) for inter-

machine file transferNine-track tape, line printer, phototypesetterVoice synthesizer, digital switching network, chess

machine

Page 8: CSE350 Software Design and Engineering University of Pennsylvania Professor Jonathan M. Smith jms Office: 254 Moore GRW, Phone:

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

Page 9: CSE350 Software Design and Engineering University of Pennsylvania Professor Jonathan M. Smith jms Office: 254 Moore GRW, Phone:

The C Programming Language

System re-coded in C in summer, 1973

1/3 bigger than assembler language version

Page 10: CSE350 Software Design and Engineering University of Pennsylvania Professor Jonathan M. Smith jms Office: 254 Moore GRW, Phone:

Observation

"The most important role of the system is to provide a

file system."

(Page 1907)

Page 11: CSE350 Software Design and Engineering University of Pennsylvania Professor Jonathan M. Smith jms Office: 254 Moore GRW, Phone:

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

Page 12: CSE350 Software Design and Engineering University of Pennsylvania Professor Jonathan M. Smith jms Office: 254 Moore GRW, Phone:

File Types

OrdinaryDirectorySpecial

CharacterBlock

Page 13: CSE350 Software Design and Engineering University of Pennsylvania Professor Jonathan M. Smith jms Office: 254 Moore GRW, Phone:

Filesystem Representation

i-Number i-List i-Node

Page 14: CSE350 Software Design and Engineering University of Pennsylvania Professor Jonathan M. Smith jms Office: 254 Moore GRW, Phone:

File Properties

Owner user-idOwner group-idProtection bitsPhysical disk (or tape) address of contentsSizeTime of creationTime of last useTime of last modificationNumber of linksFile type

Page 15: CSE350 Software Design and Engineering University of Pennsylvania Professor Jonathan M. Smith jms Office: 254 Moore GRW, Phone:

File Protection

User (owner) read, write, execute Group read, write, execute Others read, write, execute Set-user-id

--drwxwrxrwx

"Execute" permission on directories

Page 16: CSE350 Software Design and Engineering University of Pennsylvania Professor Jonathan M. Smith jms Office: 254 Moore GRW, Phone:

Filesystem API

filep = open (name, flag) filep = creat (name)n = read (filep, buffer, count)n = write (filep, buffer, count) location = lseek (filep, offset, base)

Page 17: CSE350 Software Design and Engineering University of Pennsylvania Professor Jonathan M. Smith jms Office: 254 Moore GRW, Phone:

Why file descriptors?

Consider open(“/home/jms/cse350.txt”)Consider read(“/home/jms/cse350.txt”)open() happens once, read() many

timesPay cost of name lookup, permissions

checks (existence!) at open(), reuse results, repetitively, at read()

open() returns a descriptor, used by read()

Page 18: CSE350 Software Design and Engineering University of Pennsylvania Professor Jonathan M. Smith jms Office: 254 Moore GRW, Phone:

Example: copy a file from one place to another

main()

{

char c;

int r_fd = 0, w_fd = 1;

while( read(r_fd, &c, 1) > 0 )

write(w_fd, &c, 1);

}

Page 19: CSE350 Software Design and Engineering University of Pennsylvania Professor Jonathan M. Smith jms Office: 254 Moore GRW, Phone:

Crossing protection boundary

How does a program access services?

It does so through entry points called system calls

These include read(), write(), open(), close() and creat()

Appear to be subroutines calls in “C”

Page 20: CSE350 Software Design and Engineering University of Pennsylvania Professor Jonathan M. Smith jms Office: 254 Moore GRW, Phone:

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 read-ahead

Page 21: CSE350 Software Design and Engineering University of Pennsylvania Professor Jonathan M. Smith jms Office: 254 Moore GRW, Phone:

Special File Naming

Example Name: /dev/fooMajor Device Number: selects driver

codeMinor Device Number: selects device

instance within class

Page 22: CSE350 Software Design and Engineering University of Pennsylvania Professor Jonathan M. Smith jms Office: 254 Moore GRW, Phone:

File System Data Structure

Page 23: CSE350 Software Design and Engineering University of Pennsylvania Professor Jonathan M. Smith jms Office: 254 Moore GRW, Phone:

Process Management API

processid = fork () execute (file, arg1, ..., argN) processid = wait (& status) exit (status) filep = pipe ()

Traps, Signals Minimalist, integrated process

synchronization

Page 24: CSE350 Software Design and Engineering University of Pennsylvania Professor Jonathan M. Smith jms Office: 254 Moore GRW, Phone:

Process Control Data Structure

Page 25: CSE350 Software Design and Engineering University of Pennsylvania Professor Jonathan M. Smith jms Office: 254 Moore GRW, Phone:

The Shell and Reusability

RedirectionStdin, stdout, stderrPipes and filtersArgument parsing and globbingMultitaskingBasic control structures

Page 26: CSE350 Software Design and Engineering University of Pennsylvania Professor Jonathan M. Smith jms Office: 254 Moore GRW, Phone:

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.

Page 27: CSE350 Software Design and Engineering University of Pennsylvania Professor Jonathan M. Smith jms Office: 254 Moore GRW, Phone:

Retrospective Design Considerations

Easy to write, test, run programsInteractive use

Constraints on sizeSelf-maintenance

Available source code

Page 28: CSE350 Software Design and Engineering University of Pennsylvania Professor Jonathan M. Smith jms Office: 254 Moore GRW, Phone:

Easy Programming

Device-independent file abstractionNo "access methods"Few system constraints on program

Page 29: CSE350 Software Design and Engineering University of Pennsylvania Professor Jonathan M. Smith jms Office: 254 Moore GRW, Phone:

Influences

fork () from GENIE time-sharing system

I/O API from MulticsShell concept from Multics Implementing "system" code as user

primitives from Multics

Page 30: CSE350 Software Design and Engineering University of Pennsylvania Professor Jonathan M. Smith jms Office: 254 Moore GRW, Phone:

Unix Implementation

10,000 lines of C code1,000 lines of assembler code

800 lines not possible in C200 lines for efficiency

Page 31: CSE350 Software Design and Engineering University of Pennsylvania Professor Jonathan M. Smith jms Office: 254 Moore GRW, Phone:

Observation

"Throughout, simplicity has been substituted for

efficiency."

(Page 1932)

Page 32: CSE350 Software Design and Engineering University of Pennsylvania Professor Jonathan M. Smith jms Office: 254 Moore GRW, Phone:

Observation

"The UNIX kernel is an I/O multiplexer more than a

complete operating system. This is as it should be."

(Page 1945)

Page 33: CSE350 Software Design and Engineering University of Pennsylvania Professor Jonathan M. Smith jms Office: 254 Moore GRW, Phone:

Unsupported (unwanted?) features:File access methodsFile dispositionFile formatsFile maximum sizeSpoolingCommand languageLogical recordsPhysical recordsLogical file namesMultiple character setsOperator and operator consoleLogin and logout