Silberschatz, Galvin and Gagne \uf6d92002A.1Operating System Concepts Module A: The FreeBSD System \ufffd History \ufffd Design Principles \ufffd Programmer Interface \ufffd User Interface \ufffd Process Management \ufffd Memory Management \ufffd File System \ufffd I/O System \ufffd Interprocess Communication Silberschatz, Galvin and Gagne \uf6d92002A.2Operating System Concepts History \ufffd First developed in 1969 by Ken Thompson and Dennis Ritchie of the Research Group at Bell Laboratories; incorporated features of other operating systems, especially MULTICS. \ufffd The third version was written in C, which was developed at Bell Labs specifically to support UNIX. \ufffd The most influential of the non-Bell Labs and non-AT&T UNIX development groups \u2014 University of California at Berkeley (Berkeley Software Distributions). \u2726 4BSD UNIX resulted from DARPA funding to develop a standard UNIX system for government use. \u2726 Developed for the VAX, 4.3BSD is one of the most influential versions, and has been ported to many other platforms. \ufffd Several standardization projects seek to consolidate the variant flavors of UNIX leading to one programming interface to UNIX. Silberschatz, Galvin and Gagne \uf6d92002A.3Operating System Concepts History of UNIX Versions Silberschatz, Galvin and Gagne \uf6d92002A.4Operating System Concepts Early Advantages of UNIX \ufffd Written in a high-level language. \ufffd Distributed in source form. \ufffd Provided powerful operating-system primitives on an inexpensive platform. \ufffd Small size, modular, clean design. Silberschatz, Galvin and Gagne \uf6d92002A.5Operating System Concepts UNIX Design Principles \ufffd Designed to be a time-sharing system. \ufffd Has a simple standard user interface (shell) that can be replaced. \ufffd File system with multilevel tree-structured directories. \ufffd Files are supported by the kernel as unstructured sequences of bytes. \ufffd Supports multiple processes; a process can easily create new processes. \ufffd High priority given to making system interactive, and providing facilities for program development. Silberschatz, Galvin and Gagne \uf6d92002A.6Operating System Concepts Programmer Interface \ufffd Kernel: everything below the system-call interface and above the physical hardware. \u2726 Provides file system, CPU scheduling, memory management, and other OS functions through system calls. \ufffd Systems programs: use the kernel-supported system calls to provide useful functions, such as compilation and file manipulation. Like most computer systems, UNIX consists of two separable parts: Silberschatz, Galvin and Gagne \uf6d92002A.7Operating System Concepts 4.4BSD Layer Structure Silberschatz, Galvin and Gagne \uf6d92002A.8Operating System Concepts System Calls \ufffd System calls define the programmer interface to UNIX \ufffd The set of systems programs commonly available defines the user interface. \ufffd The programmer and user interface define the context that the kernel must support. \ufffd Roughly three categories of system calls in UNIX. \u2726 File manipulation (same system calls also support device manipulation) \u2726 Process control \u2726 Information manipulation. Silberschatz, Galvin and Gagne \uf6d92002A.9Operating System Concepts File Manipulation \ufffd A file is a sequence of bytes; the kernel does not impose a structure on files. \ufffd Files are organized in tree-structured directories. \ufffd Directories are files that contain information on how to find other files. \ufffd Path name: identifies a file by specifying a path through the directory structure to the file. \u2726 Absolute path names start at root of file system \u2726 Relative path names start at the current directory \ufffd System calls for basic file manipulation: create, open, read, write, close, unlink, trunc. Silberschatz, Galvin and Gagne \uf6d92002A.10Operating System Concepts Typical UNIX Directory Structure Silberschatz, Galvin and Gagne \uf6d92002A.11Operating System Concepts Process Control \ufffd A process is a program in execution. \ufffd Processes are identified by their process identifier, an integer. \ufffd Process control system calls \u2726 fork creates a new process \u2726 execve is used after a fork to replace on of the two processes\u2019s virtual memory space with a new program \u2726 exit terminates a process \u2726 A parent may wait for a child process to terminate; wait provides the process id of a terminated child so that the parent can tell which child terminated. \u2726 wait3 allows the parent to collect performance statistics about the child \ufffd A zombie process results when the parent of a defunct child process exits before the terminated child. Silberschatz, Galvin and Gagne \uf6d92002A.12Operating System Concepts Illustration of Process Control Calls Silberschatz, Galvin and Gagne \uf6d92002A.13Operating System Concepts Process Control (Cont.) \ufffd Processes communicate via pipes; queues of bytes between two processes that are accessed by a file descriptor. \ufffd All user processes are descendants of one original process, init. \ufffd init forks a getty process: initializes terminal line parameters and passes the user\u2019s login name to login. \u2726 login sets the numeric user identifier of the process to that of the user \u2726 executes a shell which forks subprocesses for user commands. Silberschatz, Galvin and Gagne \uf6d92002A.14Operating System Concepts Process Control (Cont.) \ufffd setuid bit sets the effective user identifier of the process to the user identifier of the owner of the file, and leaves the real user identifier as it was. \ufffd setuid scheme allows certain processes to have more than ordinary privileges while still being executable by ordinary users. Silberschatz, Galvin and Gagne \uf6d92002A.15Operating System Concepts Signals \ufffd Facility for handling exceptional conditions similar to software interrupts. \ufffd The interrupt signal, SIGINT, is used to stop a command before that command completes (usually produced by ^C). \ufffd Signal use has expanded beyond dealing with exceptional events. \u2726 Start and stop subprocesses on demand \u2726 SIGWINCH informs a process that the window in which output is being displayed has changed size. \u2726 Deliver urgent data from network connections. Silberschatz, Galvin and Gagne \uf6d92002A.16Operating System Concepts Process Groups \ufffd Set of related processes that cooperate to accomplish a common task. \ufffd Only one process group may use a terminal device for I/O at any time. \u2726 The foreground job has the attention of the user on the terminal. \u2726 Background jobs \u2013 nonattached jobs that perform their function without user interaction. \ufffd Access to the terminal is controlled by process group signals. Silberschatz, Galvin and Gagne \uf6d92002A.17Operating System Concepts Process Groups (Cont.) \ufffd Each job inherits a controlling terminal from its parent. \u2726 If the process group of the controlling terminal matches the group of a process, that process is in the foreground. \u2726 SIGTTIN or SIGTTOU freezes a background process that attempts to perform I/O; if the user foregrounds that process, SIGCONT indicates that the process can now perform I/O. \u2726 SIGSTOP freezes a foreground process. Silberschatz, Galvin and Gagne \uf6d92002A.18Operating System Concepts Information Manipulation \ufffd System calls to set and return an interval timer: getitmer/setitmer. \ufffd Calls to set and return the current time: gettimeofday/settimeofday. \ufffd Processes can ask for \u2726 their process identifier: getpid \u2726 their group identifier: getgid \u2726 the name of the machine on which they are executing: gethostname Silberschatz, Galvin and Gagne \uf6d92002A.19Operating System Concepts Library Routines \ufffd The system-call interface to UNIX is supported and augmented by a large collection of library routines \ufffd Header files provide the definition of complex data structures used in system calls. \ufffd Additional library support is provided for mathematical functions, network access, data conversion, etc. Silberschatz, Galvin and Gagne \uf6d92002A.20Operating System Concepts User Interface \ufffd Programmers and users mainly deal with already existing systems programs: the needed system calls are embedded within the program and do not need to be obvious to the user.