Preface

ƒ Goal ƒ Programming Interface to the ƒ System calls, e.g., open ƒ Functions in the standard C library, e.g., printf, fopen ƒ Why ANSI standard for C ƒ Proliferation of different Unix versions ƒ Portability

* All rights reserved, Tei-Wei Kuo & Chi-Sheng Shih, National Taiwan University, 2005.

UNIX Architecture user user user user useruser user User interface Shells, compilers, X, application programs, etc. interface CPU , signal handling, System Services virtual memory, paging, swapping, , disk drivers, caching/buffering, etc. Kernel interface to the hardware terminal controller, terminals, physical memory, device controller, devices such as disks, memory, etc. UNIX * All rights reserved, Tei-Wei Kuo & Chi-Sheng Shih, National Taiwan University, 2005.

5 UNIX Past

"...the number of UNIX installations has grown to 10, with more expected..." - Dennis Ritchie and Ken Thompson, June 1972 "... When BTL withdrew from the project, they needed to rewrite an (OS) in order to play space war on another smaller machine (a DEC PDP-7 [Programmed Data Processor] with 4K memory for user programs). The result was a system which a punning colleague called UNICS (UNiplexed Information and Computing Service)--an 'emasculated Multics'; no one recalls whose idea the change to UNIX was" Source: A brief look at the early history

* All rights reserved, Tei-Wei Kuo & Chi-Sheng Shih, National Taiwan University, 2005.

UNIX

ƒ Created by Ken Thompson & Dennis Ritchie at Bell Laboratories in 1969 & on PDP-7. ƒ ACM Turing award winners for the design of UNIX in 1983. ƒ C programming language inventor: Dennis Ritchie. ƒ Major Contributors: ƒ Bell Laboratories, Computer Systems Research Group (CSRG) of the University of California at Berkley (released in BSD), UNIX System Laboratories (USG/USDL/ATTIS/DSG/USO/USL), etc.

* All rights reserved, Tei-Wei Kuo & Chi-Sheng Shih, National Taiwan University, 2005.

6 UNIX

Berkley Bell Labs UNIX System Software Research Laboratories Distributions (USG/USDL/ First Edition ATTIS/DSG/ USO/USL) Sixth Edition Seventh Edition 1BSD,…, 4.0BSD System V XENIX Release 2,3 SUNOS Chorus UNIX Mach 4.3BSD System V Solaris Solaris 2 4.3BSD Tahoe Release 4 4.3BSD Reno 4.4BSD * POSIX.1 (IEEE, ISO) standard! * All rights reserved, Tei-Wei Kuo & Chi-Sheng Shih, National Taiwan University, 2005.

Standards/Implementati ons

ƒ Related Implementations ƒ 4.xBSD, SVRx (ATT), SunOS ƒ 4.3+BSD ƒ uname -a ƒ Standards ƒ POSIX.1 ƒ IEEE and ISO standards for the interface of Unix-like systems ƒ ANSI C ƒ XPG3 – X/Open Portability Guide, Issue 3

* All rights reserved, Tei-Wei Kuo & Chi-Sheng Shih, National Taiwan University, 2005.

7 UNIX

ƒ Influence ƒ fork() from Berkley’s GINIE, 4.2 BSD file-mapping virtual memory interface from TENEX/TOPS-20, 4.4BSD virtual memory interface from MACH. fcntl system call from System V. Disk quotas and 4.3 BSD time-zone-handling package from the user community. ƒ 4BSD job control, reliable signals, multiple file- access permission groups, and file system interface were adopted by AT&T UNIX System V, IEEE POSIX.1 standard, etc. 4BSD socket ported to AT&T System III. 4BSD implementation of TCP/IP networking protocol suite widely adopted!

* All rights reserved, Tei-Wei Kuo & Chi-Sheng Shih, National Taiwan University, 2005.

UNIX

ƒ Distinguishing Features ƒ Written nearly completely in a high-level language, i.e., C. ƒ High portability! ƒ Distributed in source form. ƒ Contributions and bug fixing from everywhere! ƒ Provide powerful primitives and functions such as concurrent processes.

* All rights reserved, Tei-Wei Kuo & Chi-Sheng Shih, National Taiwan University, 2005.

8 Design Principles

ƒ Simple Algorithms for Implementation ƒ Replaceable Standard User Interface ƒ Shell ƒ Time-Sharing ƒ Simple Priority-Driven CPU Scheduling ƒ Demand-Paging Virtual Memory (4.3BSD) ƒ Swapping ƒ Similar treatments of disk files and I/O devices

* All rights reserved, Tei-Wei Kuo & Chi-Sheng Shih, National Taiwan University, 2005.

ƒ Makefile ƒ Write a C program which reads a number of words from a file in argv[1], look for words with an initial ‘A’, sort them in the alphabetic order, and prints sorted words out at stdout. ƒ Explain “variable-length argument lists” ƒ void minprintf(char *fmt, …) ƒ vastart(ap, fmt), va_end(ap), va_arg(ap, int), va_list, ƒ Google it if you don’t know them.

9