1CSE 120CSE 120Principles of Operating Principles of Operating SystemsSystemsFall 2000Fall 2000Lecture 3: Operating System Modules, Lecture 3: Operating System Modules, Interfaces, and StructureInterfaces, and StructureGeoffrey M. VoelkerGeoffrey M. VoelkerSeptember 27, 2000 CSE 120 -- Lecture 3 – Mods, Ints, Structure 2Modules, Interfaces, StructureModules, Interfaces, Structurel We roughly defined an OS as the layer of software between hardware and applicationsl We then looked in more detail at the support the hardware provides OSes to do their jobl Now we’re going to look the other direction and survey the support OSes provide to applicationsu Modules – OS services and abstractionsu Interfaces – operations supported by componentsu Structure – how components get hooked together2September 27, 2000 CSE 120 -- Lecture 3 – Mods, Ints, Structure 3OS Module OverviewOS Module Overviewl Common OS modulesu Processesu Memoryu I/Ou Secondary storageu Filesu Protectionu Accountingu Command interpreter (shell)l We’ll survey each module and discuss its interfaceu Remainder of class will focus on each module in detailSeptember 27, 2000 CSE 120 -- Lecture 3 – Mods, Ints, Structure 4Process ModuleProcess Modulel An OS executes many kinds of activitiesu User programsu Batch jobs or command scriptsu System programs (daemons): print spoolers, name servers, file servers, Web servers, etc.l Each “execution entity” is encapsulated in a processu A process includes both the program (code, data) and execution context (PC, regs, address space, resources, etc.)l Process module manages processesu Creation, scheduling, deletion, etc.3September 27, 2000 CSE 120 -- Lecture 3 – Mods, Ints, Structure 5ProcessesProcessesl A program is passive – a file on disk with code and data that is potentially runnablel A process is one instance of a program in executionu At any instance, multiple processes can be running copies of the same program (e.g., shell, editor)u These processes are separate and independentu Unix» “ps aux” (BSD) or “ps –edaf” (SYSV) will list all processes» Will see that multiple processes are executing the same programl Processes are fundament OS objectsu Processes are the OS abstraction for executionSeptember 27, 2000 CSE 120 -- Lecture 3 – Mods, Ints, Structure 6Process InterfaceProcess Interfacel Process module interfaceu Create a processu Delete a processu Suspend a processu Resume a processu Inter-process communication » Transfer, share datau Inter-process synchronizationu Process relationships» Parent, child, process groups4September 27, 2000 CSE 120 -- Lecture 3 – Mods, Ints, Structure 7MemoryMemoryl Primary memory is the direct access storage for CPUu Programs must be stored in memory to executeu Interacts with process modulel Operating systemsu Allocate memory for programs (explicitly and implicitly)u Deallocate memory when needed (by rest of system)u Maintain mappings from virtual to physical memory (page tables)u Decide how much memory to allocate to each process» Large space of policy decisionsu Decide when a process should be removed from memory» More policy decisionsSeptember 27, 2000 CSE 120 -- Lecture 3 – Mods, Ints, Structure 8I/OI/Ol Much of an OS deals with device I/Ou One of the main reasons we use OSesu Hundreds of thousands of lines of code in NT for I/O, driversl The OS provides a standard interface between programs (user or system) and devicesu File system (disks), sockets (network), frame buffer (video)l Device drivers are the routines responsible for controlling devicesu OS defines an interface for each class of devices (e.g., disks)u A driver implements interface, encapsulates device-specific knowledge (initiation and control, interrupt handling, errors)5September 27, 2000 CSE 120 -- Lecture 3 – Mods, Ints, Structure 9Secondary StorageSecondary Storagel Secondary storage (disk) is the persistent memoryu It endures system failures (for the most part)l Low-level OS routines are often responsible for low-level disk functionsu Read/write blocksu Schedule requests (optimize arm movement)u Device errorsl Usually independent of file systemu Although there might be cooperation (e.g., free space management)u Low-level knowledge can help FS performance (placement)September 27, 2000 CSE 120 -- Lecture 3 – Mods, Ints, Structure 10File SystemFile Systeml Secondary storage devices are too crude to use directly for long-term storageu Read/write physical device blocks too low-level for programsl The file system provides a much higher level, more convenient abstraction for persistent storageu Objects (files, directories) and interfaces (read, write, etc.)l Files are the basic storage entityu A file is a named collection of persistent informationl Directories are special files that contain the names of other files + metadata (data about files, attributes)u Directories have all properties of files (“inheritance”)6September 27, 2000 CSE 120 -- Lecture 3 – Mods, Ints, Structure 11File System InterfaceFile System Interfacel File system interface provides standard file operationsu Existence: File/directory creation, deletionu Manipulation: open, read, write, append, rename, close, etc.u Sometimes higher-level operations» File copy, change notification (NT)» Records (IBM)l File system also provides general servicesu Backupu Consistencyu Accounting and quotasSeptember 27, 2000 CSE 120 -- Lecture 3 – Mods, Ints, Structure 12ProtectionProtectionl Protection is general mechanism throughout OSl All objects (resources) need protectionu Processesu Memoryu Devicesu Filesl Protection mechanisms help to prevent errors as well as to prevent malicious destructionu E.g., running as root7September 27, 2000 CSE 120 -- Lecture 3 – Mods, Ints, Structure 13AccountingAccountingl General facility for keeping track of resource usage for all system objectsu Quotas in the file system (Unix: “quota –v”)u Memory usage (Unix: “man limit”)u Process resource usage (Unix: “rusage <command>”)l Resource usage might be used to bill customersu In world of PCs, might seem strangeu In world of mainframes and minicomputers, crucial» Departments, users billed for CPU timen IBM mainframe “turbo” switchSeptember 27, 2000 CSE 120 -- Lecture 3 – Mods, Ints, Structure 14Command Interpreter (Shell)Command Interpreter (Shell)l Process that handles u Handles user input (commands)u Manages subprocessesu Executes script files (files of commands)l
View Full Document