1CSE 120CSE 120Principles of Operating Principles of Operating SystemsSystemsFall 2004Fall 2004Lecture 2: Operating System Modules Lecture 2: Operating System Modules and Interfacesand InterfacesGeoffrey M. VoelkerGeoffrey M. VoelkerSeptember 23, 2002 CSE 120 – Lecture 2 – Modules and Interfaces 2Modules, Interfaces, StructureModules, Interfaces, Structurez We roughly defined an OS as the layer of software between hardware and applicationsz Now we’re going to survey the support OSes provide to applications Modules – OS services and abstractions Interfaces – operations supported by components Structure – how components get hooked together» Will discuss in depth later in the quarter» Makes more sense after being exposed to much of the materialz This is all a high-level preview of what we are going to cover in the course2September 23, 2002 CSE 120 – Lecture 2 – Modules and Interfaces 3OS Module OverviewOS Module Overviewz Common OS modules Processes Memory I/O Secondary storage Files Protection Accounting Command interpreter (shell, window system)z We’ll survey each module and discuss its interfaceSeptember 23, 2002 CSE 120 – Lecture 2 – Modules and Interfaces 4Process ModuleProcess Modulez An OS executes many kinds of activities User programs Batch jobs or command scripts System programs (daemons): print spoolers, name servers, file servers, Web servers, etc. Run “ps -edaf” on Solaris – What is all that stuff?z Each “execution entity” is encapsulated in a process A process includes both the program (code, data) and execution context (PC, regs, address space, resources, etc.)z Process module manages processes Creation, scheduling, deletion, etc.3September 23, 2002 CSE 120 – Lecture 2 – Modules and Interfaces 5Process InterfaceProcess Interfacez Process module interface Create a process Delete a process Suspend a process Resume a process Inter-process communication » Transfer, share data Inter-process synchronization Process relationships» Parent, child, process groupsSeptember 23, 2002 CSE 120 – Lecture 2 – Modules and Interfaces 6MemoryMemoryz Primary memory is the direct access storage for CPU Programs must be stored in memory to execute Interacts with process modulez Operating systems Allocate memory for programs (explicitly and implicitly) Deallocate memory when needed (by rest of system) Maintain mappings from virtual to physical memory (page tables) Decide how much memory to allocate to each process» Large space of policy decisions Decide when a process should be removed from memory» More policy decisions4September 23, 2002 CSE 120 – Lecture 2 – Modules and Interfaces 7Input/Output (I/O)Input/Output (I/O)z Much of an OS deals with device I/O One of the main reasons we use OSes Hundreds of thousands of lines of code in NT for I/O, driversz The OS provides a standard interface between programs (user or system) and devices File system (disks), sockets (network), frame buffer (video)z Device drivers are the routines responsible for controlling I/O devices OS defines an interface for each class of devices (e.g., disks) A driver implements interface, encapsulates device-specific knowledge (initiation and control, interrupt handling, errors)September 23, 2002 CSE 120 – Lecture 2 – Modules and Interfaces 8Secondary StorageSecondary Storagez Secondary storage (disk) is the persistent memory It endures system failures (for the most part)z Low-level OS routines are often responsible for low-level disk functions Read/write blocks Schedule requests (optimize arm movement) Device errorsz Usually independent of file system Although there might be cooperation (e.g., free space management) Low-level knowledge can help FS performance (placement)5September 23, 2002 CSE 120 – Lecture 2 – Modules and Interfaces 9File SystemFile Systemz Secondary storage devices are too crude to use directly for long-term storage Read/write physical device blocks too low-level for programsz The file system provides a much higher-level, more convenient abstraction for persistent storage Objects (files, directories) and interfaces (read, write, etc.)z Files are the basic storage entity A file is a named collection of persistent informationz Directories are special files that contain the names of other files + metadata (data about files, attributes) Directories have all properties of files (“inheritance”)September 23, 2002 CSE 120 – Lecture 2 – Modules and Interfaces 10File System InterfaceFile System Interfacez File system interface provides standard file operations Existence: File/directory creation, deletion Manipulation: open, read, write, append, rename, close, etc. Sometimes higher-level operations» File copy, change notification (NT)» Records (IBM)z File system also provides general services Backup Consistency Compression Encryption Accounting and quotas6September 23, 2002 CSE 120 – Lecture 2 – Modules and Interfaces 11ProtectionProtectionz Protection is a general mechanism throughout OSz All objects (resources) need protection Processes Memory Devices Filesz Protection mechanisms help to prevent errors as well as prevent malicious destruction E.g., running as rootSeptember 23, 2002 CSE 120 – Lecture 2 – Modules and Interfaces 12AccountingAccountingz General facility for keeping track of resource usage for all system objects Quotas in the file system (Unix: “quota –v”) Memory usage (Unix: “man limit”) Process resource usage (Unix: “rusage <command>”)z Resource usage might be used to bill customers In world of PCs, might seem strange In world of mainframes and minicomputers, crucial» Departments, users billed for CPU time e.g., IBM mainframe “turbo” switch7September 23, 2002 CSE 120 – Lecture 2 – Modules and Interfaces 13Command Interpreter (Shell)Command Interpreter (Shell)z Process that: Handles user input (commands) Manages subprocesses Executes script files (files of commands)z On some systems, CI is part of OS Users constrained to use that CI (DOS)z Others, it is just another user-level process Unix shell Any program can be a CI (sh, csh, ksh, bash, etc.)z Or, there may not be a command language at all Original MacOS (hey, where’s the shell?) What about MacOS 10?September 23, 2002 CSE 120
View Full Document