CSE 120 Principles of Operating Systems Fall 2000 Lecture 3 Operating System Modules Interfaces and Structure Geoffrey M Voelker Modules Interfaces Structure l l l We roughly defined an OS as the layer of software between hardware and applications We then looked in more detail at the support the hardware provides OSes to do their job Now we re going to look the other direction and survey the support OSes provide to applications u Modules OS services and abstractions Interfaces operations supported by components u Structure how components get hooked together u September 27 2000 CSE 120 Lecture 3 Mods Ints Structure 2 1 OS Module Overview l Common OS modules u u u u u u u u l Processes Memory I O Secondary storage Files Protection Accounting Command interpreter shell We ll survey each module and discuss its interface u Remainder of class will focus on each module in detail September 27 2000 CSE 120 Lecture 3 Mods Ints Structure 3 Process Module l An OS executes many kinds of activities u u u l Each execution entity is encapsulated in a process u l User programs Batch jobs or command scripts System programs daemons print spoolers name servers file servers Web servers etc A process includes both the program code data and execution context PC regs address space resources etc Process module manages processes u Creation scheduling deletion etc September 27 2000 CSE 120 Lecture 3 Mods Ints Structure 4 2 Processes l l A program is passive a file on disk with code and data that is potentially runnable A process is one instance of a program in execution u u u At any instance multiple processes can be running copies of the same program e g shell editor These processes are separate and independent Unix ps aux BSD or ps edaf SYSV will list all processes Will see that multiple processes are executing the same program l Processes are fundament OS objects u Processes are the OS abstraction for execution September 27 2000 CSE 120 Lecture 3 Mods Ints Structure 5 Process Interface l Process module interface u u u u u Create a process Delete a process Suspend a process Resume a process Inter process communication Transfer share data u u Inter process synchronization Process relationships Parent child process groups September 27 2000 CSE 120 Lecture 3 Mods Ints Structure 6 3 Memory l Primary memory is the direct access storage for CPU u u l Programs must be stored in memory to execute Interacts with process module Operating systems u u u u 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 u Decide when a process should be removed from memory More policy decisions September 27 2000 CSE 120 Lecture 3 Mods Ints Structure 7 I O l Much of an OS deals with device I O u u l The OS provides a standard interface between programs user or system and devices u l One of the main reasons we use OSes Hundreds of thousands of lines of code in NT for I O drivers File system disks sockets network frame buffer video Device drivers are the routines responsible for controlling devices u u 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 27 2000 CSE 120 Lecture 3 Mods Ints Structure 8 4 Secondary Storage l Secondary storage disk is the persistent memory u l Low level OS routines are often responsible for lowlevel disk functions u u u l It endures system failures for the most part Read write blocks Schedule requests optimize arm movement Device errors Usually independent of file system u u Although there might be cooperation e g free space management Low level knowledge can help FS performance placement September 27 2000 CSE 120 Lecture 3 Mods Ints Structure 9 File System l Secondary storage devices are too crude to use directly for long term storage u l The file system provides a much higher level more convenient abstraction for persistent storage u l Objects files directories and interfaces read write etc Files are the basic storage entity u l Read write physical device blocks too low level for programs A file is a named collection of persistent information Directories are special files that contain the names of other files metadata data about files attributes u Directories have all properties of files inheritance September 27 2000 CSE 120 Lecture 3 Mods Ints Structure 10 5 File System Interface l File system interface provides standard file operations u u u Existence File directory creation deletion Manipulation open read write append rename close etc Sometimes higher level operations File copy change notification NT Records IBM l File system also provides general services u u u Backup Consistency Accounting and quotas September 27 2000 CSE 120 Lecture 3 Mods Ints Structure 11 Protection l l Protection is general mechanism throughout OS All objects resources need protection u u u u l Processes Memory Devices Files Protection mechanisms help to prevent errors as well as to prevent malicious destruction u E g running as root September 27 2000 CSE 120 Lecture 3 Mods Ints Structure 12 6 Accounting l General facility for keeping track of resource usage for all system objects u u u l Quotas in the file system Unix quota v Memory usage Unix man limit Process resource usage Unix rusage command Resource usage might be used to bill customers u In world of PCs might seem strange u In world of mainframes and minicomputers crucial Departments users billed for CPU time n IBM mainframe turbo switch September 27 2000 CSE 120 Lecture 3 Mods Ints Structure 13 Command Interpreter Shell l Process that handles u u u l On some systems CI is part of OS u l l Handles user input commands Manages subprocesses Executes script files files of commands Users constrained to use that CI DOS Others it is just another user level process u Unix shell u Any program can be a CI sh csh ksh bash etc Or there may not be a command language at all u MacOS hey where s the shell September 27 2000 CSE 120 Lecture 3 Mods Ints Structure 14 7 The Challenge of Structure l l It is clear what modules an OS should provide Not so clear how to hook them together well Command Interpreter Process Management File System Memory Management Protection Secondary Storage September 27 2000 I O Subsystem Accounting CSE 120 Lecture 3 Mods Ints
View Full Document
Unlocking...