1 / 29

CS 423 – Operating Systems Design Lecture 4 – UNIX History and Architecture

CS 423 – Operating Systems Design Lecture 4 – UNIX History and Architecture. Klara Nahrstedt/Sam King Fall 2007. Overview. Administrative Issues History of UNIX (T.10.1) Overview of UNIX (T.10.2) . Administrative . MP1 posted, deadline September 10, 8am. UNICS.

shel
Download Presentation

CS 423 – Operating Systems Design Lecture 4 – UNIX History and Architecture

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS 423 – Operating Systems DesignLecture 4 – UNIX History and Architecture Klara Nahrstedt/Sam King Fall 2007 CS 423 - Fall 2007

  2. Overview • Administrative Issues • History of UNIX (T.10.1) • Overview of UNIX (T.10.2) CS 423 - Fall 2007

  3. Administrative • MP1 posted, deadline September 10, 8am CS 423 - Fall 2007

  4. UNICS • 1940-1950 – one person machines – huge • 1960 – batch systems • Time-consuming process of entering punch card, debugging, etc. • Timesharing – invented at Dartmouth and MIT • MIT system – CTSS • MIT&Bell Labs&GE -> MULTICS (MULTiplexed Information and Computing Service) • Bell Labs pulled out of MULTICS, Ken Thompson stripped MULTICS on PDP-7 • UNICS (UNiplexed Information and Computing Service) • Name later changed to UNIX CS 423 - Fall 2007

  5. PDP-11 UNIX • 1970s - UNIX moved to PDP-11/20 and then PDP-11/45 and PDP-11/70 (powerful machines at the time – 256K and 2 MB main memory space, 16-bit machines) • Memory hardware protection, hence multiple users could be run • Limitation: individual processes were limited to 64KB instruction and data space • Problem: language in which UNIX was written • Thompson rewrites UNIX in high-level language, called B (simplified version of BCPL) • BCPL (Basic Combined Programming Language), developed by Martin Richards at U. Cambridge in 1966 • B – lack of structures – attempt unsuccessful • Ritchie designed successor to B – language called C and compiler • Thompson and Ritchie rewrote UNIX in C CS 423 - Fall 2007

  6. PDP-11 UNIX • 1974 –landmark paper by Ritchie and Thompson about UNIX (for this paper they got ACM Turing Award) • PDP-11 was computer of choice at nearly all universities at the time and UNIX got deployed quickly • Version 7 UNIX was the first portable version of UNIX • 1980s – UNIX was widely spread on minicomputers and engineering workstations CS 423 - Fall 2007

  7. Portable UNIX • First port beyond PDP-11 was to Interdata 8/32 minicomputer • Porting required: • write a C compiler for the new machine, • write device drivers for the new machine’s I/O devices such as printers, terminals, disks • Small amount of machine-dependent code such as the interrupt handlers, memory management routines must be rewritten, usually in assembly code • Problem: Ritchie’s compiler – good, but produced PDP-11 object code. • Steve Johnson at Bell Labs implemented portable C compiler, called also Johnson’s compiler • 1984 – AT&T released UNIX as a commercial product, first System III, then System V. CS 423 - Fall 2007

  8. Berkeley UNIX • UNIX Version 6 • First produced on PDP-11, called 1BSD (First Berkeley Software Distribution) • Most famous - 4BSD for VAX (Similar to AT&T Version 7) • Virtual memory, paging • File names longer than 14 characters • File system implementation changed (faster) • Signal handling more reliable • Introduction of networking, using TCP/IP • Berkeley UNIX added substantial number of utility programs • Editor – vi • Shell – csh • Pascal and Lisp compilers • Last Berkeley version – 4.4BSD – later FreeBSD CS 423 - Fall 2007

  9. Standard UNIX • Late 1980s – two version of UNIX • 4.3BSD • System V Release 3 • Standardizing Efforts • Initial efforts failed • Successful effort – POSIX (Portable Operating System) • POSIX committee produced standard 1003.1 • Set of library procedures – open, read, fork, … • Committee took intersection of System V and BSD • Industrial Split • IBM, DEC, HP – consortium OSF (Open Software Foundation) met IEEE standard and included also windowing system X11, graphical user interface MOTIF, distributed computing DCE and others • AT&T – consortium UI (UNIX International) was based on System V • Multiple UNIX implementations: HP-UX, AIX, Solaris CS 423 - Fall 2007

  10. MINIX • 1987 - New UNIX-like system • Small enough and open with source code available • Functionally almost equivalent to Version 7 UNIX • Based on micro-kernel design, i.e., minimal functionality in the kernel to make it reliable and efficient • Memory management and file system in user processes • Easy to understand • Easy to maintain due to their highly modular structure • Other Micro-kernels • Mach – CMU – 1986 • ChorusOS – INRIA - 1988 (for embedded systems) CS 423 - Fall 2007

  11. LINUX • 1991 - Linus Torvalds – Finland • UNIX clone – Linux • Linux 0.01 • came from MINIX ideas, ranging from structure of the source tree to the layout of the file system • Monolithic (not micro-kernel design) • Originally run on 386 architecture • 1994 – Linux 1.0 • New file system, memory-mapped files, BSD-like networking with sockets and TCP/IP • New device drivers • 1996 – Linux 2.0 • Support for 64-bit architectures, symmetric multiprogramming, new networking protocols • Business Model – free software • 80% of ca. 150 Linux system calls are exact copies of the corresponding system calls in POSIX, BSD or System V. CS 423 - Fall 2007

  12. Linux Version 2.6 • Compliant with IEEE POSIX standard • All features of a modern UNIX OS • Virtual memory, virtual file system, lightweight processes, Unix signals, SVR4 (System V, Release 4) inter-process communications, support for Symmetric Multiprocessors (SMP) • Monolithic kernel • Most commercial UNIX variants are monolithic • Exceptions: Apple MAC OS X and GNU Hurd OS (both derived from CMU Mach OS) follow microkernel approach • Support for modules on demand – automatic load and unload of modules on demand • Only SVR4.2 and Solaris kernel have similar feature • Kernel threading • Kernel organized as a set of kernel threads • Only Solaris and SVR4.2 are organized like this CS 423 - Fall 2007

  13. Linux Version 2.6 • Multithreaded application support • Multi-threaded user application could be composed of many light-weight processes (LWP) which are processes that can operate in common address space, common physical memory pages, common opened files, etc. • Linux defines its own LWP different from SVR4 and Solaris • Preemptive kernel • If kernel 2.6 is compiled with “preemptible kernel” option, kernel can arbitrarily interleave execution flows while they are in privileged mode • Only Solaris and Mach 3.0 have preemptible kernels • Multi-processor support • Support of SMP for different memory models • File System • Linux has several standard file systems • Old Ext2 file system (if no specific needs) • Ext3 file system (if one wants to avoid lengthy file system checks after system crash) • ReiserFS file system (for small files) • STREAMS • No analog to STREAMS I/O subsystem introduced by SVR4 CS 423 - Fall 2007

  14. UNIX Overview • Designed as an interactive OS • Handles multiple processes and multiple users at the same time • Designed by programmers and for programmers with assumptions that • Majority of users are relatively sophisticated • Majority of users are engaged in software development CS 423 - Fall 2007

  15. What do good programmers want from a system? • Simple, elegant, consistent • Example • Simple format: File at the lowest level as a collection of bytes • Having different classes of files for sequential access, random access, keyed access, remote access, etc just gets in the way (this is the approach mainframes take) • Consistent commands: • ls A* means list files beginning with ‘A’ • rm A* means remove files beginning with ‘A’ • Principle of least surprise CS 423 - Fall 2007

  16. What do good programmers want from a system? • Power and Flexibility • Small number of basic elements that can be combined in an infinite variety of ways to suit the application • Every program should do just one thing and do it well • Remove useless redundancy • Example • Why type copy when cp is enough? • Efficient extracting all lines containing the string “ard” from file f > grep ard f CS 423 - Fall 2007

  17. UNIX Interfaces UserInterface The layers of a UNIX system. CS 423 - Fall 2007

  18. UNIX Shell • Graphical User Interface at MAC and Windows • UNIX – command line interface, called shell • UNIX Graphical environment – X Windows • Bourne shell (sh) Protocol • Shell starts up and initializes itself • Shell types a prompt character (percent or dollar sign) and waits for user to type a command line • User types a command line • Shell extracts first word and assumes the name of a program to be run • Shell searches for this program • If it finds it, runs the program • Shell suspends itself until the program terminates • Shell waits for another command CS 423 - Fall 2007

  19. UNIX Shell • Shell is an ordinary user program – needs the ability to read from and write to the terminal, and execute other programs • Commands may take arguments, which are passed to the called program as character strings • Example • cp src dest • Shell accepts magic characters, called wild cards • Example: ls *.c • Shell does not have to open terminal, but it has access automatically to a file ‘standard input’ (for reading), file ‘standard output’ (for writing normal output), and file ‘standard error’ (for writing error messages) • Shell can redirect standard input/output to files • Example: sort <in >out CS 423 - Fall 2007

  20. UNIX Shell • Pipe symbol • Example: grep ter *.t | sort >out • Possible pipeline – sequence of pipe symbols • Single user can run several programs at once • Shell syntax for running a program in the background – use & • Example: wc –l <a >b & • Shell scripts – files containing shell commands CS 423 - Fall 2007

  21. UNIX Utility Programs • Large number of utility programs • Divided into six categories • File and directory manipulation commands • Example: cp a b | ls *.* • Filters • Example: grep (extracts lines containing patterns), cut, paste, • Program development tools such as editors/compilers • Example: cc (C compiler), make (maintain large programs whose source code consists of multiple files) • Text processing • Example: vi • System administration • Example: mount (mount file system) • Miscellaneous • Example: kill 1325 (kill a process), chmod (change privileges of a file) CS 423 - Fall 2007

  22. UNIX Utility Programs CS 423 - Fall 2007

  23. UNIX Kernel Approximate structure of generic UNIX kernel CS 423 - Fall 2007

  24. Kernel Structure • All UNIX drivers are classified as either character device drivers (mouse, keyboard) or block device drivers (disk) • Network device drivers (possible character devices, but handled very differently) • Process dispatching – when interrupt happens, context switch happens between processes CS 423 - Fall 2007

  25. Kernel Structure • Editors such as vi/emacs need raw tty • Shell is line oriented, hence uses cooked mode and line disciplines • Networking software is layered with MAC/Routing/Transport layers and Socket interface • On top of buffer cache sits file system • Most UNIX systems support multiple file systems • Berkeley fast file system • Log-structured file system • Various System V file systems CS 423 - Fall 2007

  26. Kernel Structure • On top of file system comes file naming, directory management, hard link and symbolic link management, etc • On top page cache sits virtual memory (VM) • All paging logic is here, such as replacement algorithm • On top of VM is mapping files onto VM and high level page fault management code • Figure out what to do when a page fault occurs • On top of process dispatching is process management • Process scheduler to choose which process to run next • If threads are managed in the kernel, thread management is also here • Note in some UNIX systems, threads are managed in user space • On top of scheduling we have signal processing and process creation and termination CS 423 - Fall 2007

  27. Kernel Structure • Top layer has the system call interface • All system calls are directed to one of the lower modules, depending on the nature of the call • Top layer also has entrance to interrupts and traps • Entrance to signals, page faults, processor exceptions of all kinds, I/O interrupts CS 423 - Fall 2007

  28. Summary • Most UNIX kernels are monolithic: each kernel layer is integrated into the whole kernel program and runs in Kernel Mode on behalf of current process • Some kernels use micro-kernel approach • Very small set of functions from the kernel • Few synchronization primitives • Simple scheduler • Inter-process communication mechanism • Several system processes run on top of micro-kernel • Memory allocators, device drivers, system call handlers • Disadvantage: Microkernels are generally slower than monolithic ones due to explicit message passing between different layers of the OS • Advantage: microkernels force system programmers to adopt a modularized approach since OS layer is relatively independent program that must interact with the other layers through well-defined and clean software interfaces • Advantage: Microkernels are easily ported to other architectures CS 423 - Fall 2007

  29. Summary • Linux – wants to achieve theoretical advantages of micro-kernels without introducing performance penalties • Linux kernel offers modules • Module is an object file whose code can be linked to kernel at runtime • Advantages of modules: • Modularized approach • Platform independence • Frugal memory usage • No performance penalty CS 423 - Fall 2007

More Related