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

Post on 19-Dec-2015

214 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

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

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

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

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.

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

Economics of the 1970s

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

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

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

The C Programming Language

System re-coded in C in summer, 1973

1/3 bigger than assembler language version

Observation

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

file system."

(Page 1907)

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

File Types

OrdinaryDirectorySpecial

CharacterBlock

Filesystem Representation

i-Number i-List i-Node

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

File Protection

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

--drwxwrxrwx

"Execute" permission on directories

Filesystem API

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

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()

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);

}

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”

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

Special File Naming

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

codeMinor Device Number: selects device

instance within class

File System Data Structure

Process Management API

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

Traps, Signals Minimalist, integrated process

synchronization

Process Control Data Structure

The Shell and Reusability

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

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.

Retrospective Design Considerations

Easy to write, test, run programsInteractive use

Constraints on sizeSelf-maintenance

Available source code

Easy Programming

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

Influences

fork () from GENIE time-sharing system

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

primitives from Multics

Unix Implementation

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

800 lines not possible in C200 lines for efficiency

Observation

"Throughout, simplicity has been substituted for

efficiency."

(Page 1932)

Observation

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

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

(Page 1945)

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

top related