UNIX Case Study history and evolution -- quite the story UNIX mostly written in a high-level language (C), making it easier to port ran originally on popular hardware, PDP-11 many universities became interested early in UNIX, came with source code UCB ported UNIX to 32-bit VAX-11 hardware with virtual memory UCB added TCP/IP networking protocols Sun Microsystems started selling workstations running UNIX POSIX standard Open Software Foundation vs. UNIX International AT&T sold UNIX Systems Laboratories to Novell (which will? donate UNIX trademark to the public domain) user view goals interactive timesharing system for programmers for program development layers, Fig 7-2 hardware, kernel (system call handler, resource manager), standard library, utilities, users user interface through standard utilities, standard library, or system calls UNIX has user IDs and keeps track of who owns what files command interpreter is a user-level program running outside the kernel wildcard characters, redirection of input and output, pipes, background processes, programmable shell scripts files and directories, Fig 7-3 hierarchical file system of byte-stream files, protection bits utilities, Fig 7-4 fundamental concepts processes are single threaded, system is multiprogrammed creation with fork, parent and child, Fig 7-6 pipes signals (software interrupts), Fig 7-7 uid, superuser (root), setuid bit memory management text, initialized data, heap (uninitialized), stack segments, Fig 7-8 brk system call to grow or shrink heap shared text segments file system file descriptor returned by open, each process starts with three (stdin, stdout, stderr) path names, absolute and relative, working directory links, Fig 7-9 disk partitions and mounting file systems, Fig 7-10 locking, from one byte to whole file, shared and exclusive, blocking or non-blocking input and output devices are block and character special files in /dev, can open, read, write, close them sockets, endpoints of communication e.g. over network, Fig 7-12 TCP/IP, UDP, Internet domain naming, listen, connect, read, write system call interface, Fig 7-13 process management fork, waitpid, execve, exit, sigaction, kill, alarm, pause example in Fig 7-14 memory management brk files and directories creat, open, close, read, write, lseek, stat (Fig 7-15), mkdir, rmdir, link, unlink, chdir, chmod input and output get and set input and output speed and terminal attributes implementation kernel machine-dependent part: interrupt handlers, device drivers, memory management machine-independent part: system call handling, process management, scheduling, pipes, signals, paging, swapping, file system, high-level IO process table: info about all processes (info is always memory resident) scheduling parameters, memory image pointers, signal masks, process state, alarms, pid, parent pid, uid, gid user structure: other info not needed when process swapped out (so it is swapped out too) registers, system call in progress, file descriptor table, accounting, kernel stack CPU scheduling, Fig 7-16 swapper: high-level scheduler swaps processes in and out swap out a CPU hog, a long term memory resident, or a blocked process swap in those swapped out for a long time low-level scheduler gives high priority to processes that have just finished waiting for a system call to be completed, e.g. disk read paging and page replacement, Fig 7-17 demand paging, grab page from free list two-handed global clock daemon keeps free list from getting too small scans page frames, first hand clears usage bit, second hand puts page frames with clear usage bit on free list (where they can be reclaimed before they get to the top of the free list) swapper invoked if the hands move too fast or can't keep free list big enough file systems, Fig 7-18 block 0: boot block block 1: superblock (# i-nodes, # disk blocks, start of free list) blocks 2-x: i-nodes (owner, protection, data block addresses) blocks x+1-y: data blocks directories are (name, i-node #) pairs file descriptor table, open file description table, open i-node table, Fig 7-19 cylinder groups replicate superblock for reliability group some i-nodes and cylinders together to reduce seek time fragments are the last block of a file and can be smaller than usual file block size to reduce internal fragmentation yet have a large block size input and output, Fig 7-20 buffer cache for file IO C-lists for terminal IO containing 64 characters line discipline produces cooked character stream