710 likes | 743 Views
Understanding Operating Systems Sixth Edition. Chapter 13 UNIX Operating System. Learning Objectives. After completing this chapter, you should be able to describe: The goals of UNIX designers The significance of using files to manipulate devices
E N D
Understanding Operating SystemsSixth Edition Chapter 13 UNIX Operating System
Learning Objectives After completing this chapter, you should be able to describe: • The goals of UNIX designers • The significance of using files to manipulate devices • The strengths and weaknesses of having competing versions of UNIX • The advantages of command-driven user interfaces • The roles of the Memory, Processor, Device, and File Managers in UNIX Understanding Operating Systems, Sixth Edition
Overview • Three major advantages of UNIX • Portability • Code written in high-level language (C language) • Powerful utilities • Brief, single operation commands • Combinable into single command • Application device independence • Configurable to operate on any device type • Disadvantages • No single standardized version • Brief, cryptic commands difficult for novice learner Understanding Operating Systems, Sixth Edition
History • Research project originally in 1965 • Joint venture between Bell Labs, AT&T, General Electric, and MIT • Goal • Develop MULTICS • MULTICS ambition • Serve diverse user group needs • Too intricate, complex, large for commercial value • Bell labs withdrew in 1969 Understanding Operating Systems, Sixth Edition
History (cont'd.) Understanding Operating Systems, Sixth Edition
History (cont'd.) Understanding Operating Systems, Sixth Edition
The Evolution of UNIX • Original language • DEC PDP-7 assembly language • First official version: 1971 • Design • Do one thing well • Ran on DEC PDP-11 • No pipes or filters • Added in version 2 • Thompson and Ritchie: version 3 • New programming language (C language) Understanding Operating Systems, Sixth Edition
The Evolution of UNIX (cont'd.) • AT&T forbidden to sell software • Universities and developers advanced software • Commercial transformation • Berkley BSD version: 1973-1975 • 1984: government deregulation • AT&T personal computer with UNIX System 4 • Contained additional Berkley version features • AT&T System 4 promotion as standard fails • 1990: two dozen versions Understanding Operating Systems, Sixth Edition
The Evolution of UNIX (cont'd.) • 1991: AT&T UNIX system laboratories • Develops System V release 4 • Features • System V release 3, BSD 4.3, SunOS, Xenix • “The Open Group” formed • Owns UNIX trademark • 1993: Berkeley • 4.4 BSD: based on AT&T’s UNIX (AT&T license) • Novell acquires UNIX from AT&T Understanding Operating Systems, Sixth Edition
The Evolution of UNIX (cont'd.) • Current releases • Modify “do one thing well” position • Commands more difficult to use • Pipelines preserved • Adaptable to new situations with ease • Meet new user needs • Full local area network support • Comply with international standards • Security improved • Uses Common Desktop Environment (CDE) • ISO/IEC 9945:2003 Standard Understanding Operating Systems, Sixth Edition
Design Goals • Thompson and Ritchie vision • UNIX operating system • Created by programmers for programmers • Fast, flexible, easy-to-use • Immediate goals • Support software development • Included utilities for customized code • Utilities designed for simplicity: do one thing well • Small manageable sections of code • Keep algorithms simple • Based on simplicity, not sophistication Understanding Operating Systems, Sixth Edition
Design Goals (cont'd.) • Long-term goal • Portability • Reduces conversion costs • Application packages not obsolete • Achieved with UNIX version 4 • Hardware independent • POSIX • Portable operating system interface for computer environments • IEEE standards defining portable operating system interface • IEEE STD. 1003.1 (2004 edition) Understanding Operating Systems, Sixth Edition
Memory Management • Multiprogramming systems • Swapping (small jobs) • Entire program in main memory before execution • Program size restriction • Round robin policy • Demand paging (large jobs) • More complicated hardware • Increases system overhead • Thrashing (under heavy loads) • Advantage: implements virtual memory concept Understanding Operating Systems, Sixth Edition
Memory Management (cont'd.) • Typical internal memory layout (single user) • Program code • Data segment • Stack Understanding Operating Systems, Sixth Edition
Memory Management (cont'd.) • Program code • Sharable portion of program • Reentrant code • Physically shared by several processes • Code protected: instructions not modified during normal execution • Data references: without absolute physical address • Space allocation • Program cannot release until all processes completed • Text table: tracks processes using program code Understanding Operating Systems, Sixth Edition
Memory Management (cont'd.) • Data segment • After program code • Grows towardhigher memory locations • Nonsharable section of memory • Stack • Starts athighest memory address • Grows downward • Subroutine calls and interruptsadd information • Main memory • Process informationsaved when process interrupted • Nonsharable section ofmemory Understanding Operating Systems, Sixth Edition 16
Memory Management (cont'd.) • UNIX kernel • Implements “system calls” • Memory boundaries for process coexistence • System calls • File Manager interaction and request of I/O services • Implements most primitive system functions • Permanently resides in memory • Uses LRU page replacement algorithm • Network PCs, single-user, and multi-user systems • Use same memory management concepts Understanding Operating Systems, Sixth Edition
Process Management • Handles • CPU allocation • Process scheduling • Satisfaction of process requests • Kernel maintains tables • Coordinates process execution • Device allocation • Uses predefined policies • Select process from READY queue • Begin execution • Give time slice Understanding Operating Systems, Sixth Edition
Process Management (cont'd.) • Process scheduling algorithm • Selects highest priority process to runfirst • Priority value: accumulated CPU time • Processes with large CPU time get lower priority • Compute-to-total-time ratio • System updates for each job everysecond • Total time process in system divided by used process CPU time • Ratio = one • CPU-bound job Understanding Operating Systems, Sixth Edition
Process Management (cont'd.) • Process scheduling algorithm (cont'd.) • Processes with same computed priority • Handled by round robin • Interactive processes: low ratio (no special policies) • Balance I/O-bound jobs with CPU-bound jobs • Keeps processor busy • Minimizes waiting processes overhead Understanding Operating Systems, Sixth Edition
Process Management (cont'd.) • Process scheduling algorithm (cont'd.) • Loading process from READY queue • Process with longest secondary storage time • Swap out process • Process waiting longest (disk I/O, idle) • When processor becomesavailable • Process selected may not be ready (waiting on I/O) • Determineinactive but ready for execution • Process priorities recalculated • Handled dynamically Understanding Operating Systems, Sixth Edition
Process Table Versus User Table • Simple processes (nonsharable code) • Tables • Keep system running smoothly • Process table • Always resides in memory • Maintains text table • User table • Resides in memory while process is active • User table, process data segment, code segment • Swapped as needed Understanding Operating Systems, Sixth Edition
Process Table Versus User Table (cont'd.) • Process table • Each entry contains: • Process identificationnumber • User identification number • Process memory address or secondary storageaddress • Process size and scheduling information • Set up when process is created • Deleted when process terminates Understanding Operating Systems, Sixth Edition
Process Table Versus User Table (cont'd.) • Text table • Sharable code processes • Process table maintains • Contains: • Memory address or secondarystorage address of text segment (sharable code) • Count: tracks number of processes using code • Increased by one when process starts using code • Decreased by one when process stops using code • Count = 0: implies code no longer needed Understanding Operating Systems, Sixth Edition
Process Table Versus User Table (cont'd.) • User table • Allocated to each active process • Stored in transient memory area • Contains: • User and group identification numbers • Determine file access privileges • Pointers to system’s file table • Every file process uses • Pointer to current directory • List of responses for various interrupts • All information accessible when process running Understanding Operating Systems, Sixth Edition
Synchronization • UNIX • True multitasking operating system • Requires processes wait for certain events • Each event represented by integers • Equal to address oftable associated with event • Race occurs • Event happens during process transition decision • Wait for event and entering WAIT state Understanding Operating Systems, Sixth Edition
Synchronization (cont'd.) • fork • Execute oneprogram from another program • Secondprogram • Given all first program attributes (open files) • Savefirst program in original form • Split program: two copies • Both run from statement after fork command • fork executed • “Process id” (pid) generated • Ensure each process has unique ID number Understanding Operating Systems, Sixth Edition
Synchronization (cont'd.) Understanding Operating Systems, Sixth Edition
Synchronization (cont'd.) • wait • Synchronize process execution • Suspend parent until child finished • Program IF-THEN-ELSE structure • Controlled by pid value • pid > zero: parent process • pid = zero: child process • pid < zero: error in fork call Understanding Operating Systems, Sixth Edition
Synchronization (cont'd.) Understanding Operating Systems, Sixth Edition
Synchronization (cont'd.) • exec • Start new program execution from another program • execl, execv, execls, execlp, and execvp • Successful exec call • Overlay second program over first • Only second program in memory • No return from successful exec call • Parent-child concept: does not hold • Each exec call • Followed by test ensuring successful completion Understanding Operating Systems, Sixth Edition
Synchronization (cont'd.) Understanding Operating Systems, Sixth Edition
Device Management • Device independence to applications • I/O device treated as special file type • Device files given name • Descriptors called “iodes” • Identifies devices, contains device information, stored in device directory • Device drivers • Subroutines working with operating system • Supervise data transmission • Between main memory and peripheral unit • Most common drivers included in UNIX Understanding Operating Systems, Sixth Edition
Device Management (cont'd.) • Device driver kernel incorporation • During systemconfiguration • Recent UNIX versions • Program called config • Automatically creates conf.c • For any hardware configuration • conf.c contains parameters controlling resources • Number of internal kernel buffers and swap space size • conf.c contains twotables • bdevsw (“block I/O switch”) • cdevsw (“character I/O switch”) Understanding Operating Systems, Sixth Edition
Device Classifications • Divide I/O system • “Block I/O” system (“structured I/O” system) • “Character I/O” system (“unstructured I/O” system) • Physical device identification • Minor device number • Major device number • Class: block or character Understanding Operating Systems, Sixth Edition
Device Classifications (cont'd.) Understanding Operating Systems, Sixth Edition
Device Classifications (cont'd.) • Class: block or character • Each has configuration table • Array of entry points intodevice drivers • Major device number • Index to array to access appropriate code (specific driver) • Minor device number • Passed as an argument to device driver • Access one of several identical physical devices • Block I/O system • Devices addressed as 512-byte block sequences • Allows device manager to buffer (reduce I/O traffic) Understanding Operating Systems, Sixth Edition
Device Classifications (cont'd.) • Character class devices • Device drivers handle implementing characterlists • Example: terminal • Typical character device • Two input queues and one outputqueue • I/O procedure synchronized through hardware completion interrupts • Some devices belong to both classes • Examples: disk drives, tape drives Understanding Operating Systems, Sixth Edition
Device Drivers • Special section in kernel • Includes instructions • Allows operating system communication with device • Disk drive’s device drivers • Use seek strategy tominimize arm movement • Kept in set of files • Loaded as needed • Case of seldomused devices • Kept in memory all the time • Loaded at boot time • Kept in /dev directory by default and convention Understanding Operating Systems, Sixth Edition
File Management • Three file types • Directories • Ordinary files • Special files • Each enjoys certain privileges • Directories • Maintain hierarchical structure of file system • Users allowed to read information in directory files • Only system allowed directory file modification Understanding Operating Systems, Sixth Edition
File Management (cont'd.) • Ordinary files • Users store information • Protection based onuser requests • Related to read, write, execute, delete functions performed on file • Special files • Device drivers providing I/O hardware interface • Appear as entries in directories • Part of file system (most in /dev directory) • Special filename indicates type of deviceassociation Understanding Operating Systems, Sixth Edition
File Management (cont'd.) • Files stored as sequences of bytes • No structure imposed • Text files • Character strings • Linesdelimited by line feed, new line, character • Binary files • Sequences of binarydigits • Grouped into words as they appear in memory during program execution • Structure of files • Controlled by programs using them: not by system Understanding Operating Systems, Sixth Edition
File Management (cont'd.) • Organizes disk into blocks of 512 bytes each • Divides disk into four basic regions • First region (address 0): reservedfor booting • Second region: contains disk size and other regions’ boundaries • Third region includes: file definitions called “i-list” • Remaining region: free blocks availablefor file storage • Files stored in contiguous empty blocks • Simple allocation and no need to compact Understanding Operating Systems, Sixth Edition
File Management (cont'd.) • “i-node” • Each entry in i-list called an “i-node” (or inode) • Contains 13 disk addresses • Contains specific file information • Owner’s identification • Protection bits, physical address, file size • Time of creation, last use, and last update • Number of links • File type • Directory, ordinary file, or special file Understanding Operating Systems, Sixth Edition
File Naming Conventions • Case-sensitive filenames • 255 character length • No file naming conventions • Some compilers expect specific suffixes • Supports hierarchical tree file structure • Root directory identified by slash (/) Understanding Operating Systems, Sixth Edition
File Naming Conventions (cont'd.) Understanding Operating Systems, Sixth Edition
File Naming Conventions (cont'd.) • Path name rules • Path name starting with slash • Root directory • Path name • One name or list of names: separated by slashes • Last name on list: filename requested • Two periods (..) in path name • Moves upward in hierarchy(closer to root) • Only way to go up hierarchy • All other pathnames go down tree • Spaces not allowed within path names Understanding Operating Systems, Sixth Edition
Directory Listings • “long listing” • Eight pieces of informationfor each file • First column • Shows file type and access privileges for each file • Firstcharacter: nature of file or directory • Next three characters: access privileges granted file owner • Next three characters: access privileges granted otheruser’s group members • Last three characters: access privileges grantedto users at large (system-wide) Understanding Operating Systems, Sixth Edition
Directory Listings (cont'd.) • Second column • Indicates number of links (number of aliases) • Referring to same physical file • Aliases • ImportantUNIX feature: support file sharing • Several users work together on same project • Shared files appear in different directoriesbelonging to different users • Filename: may be different fromdirectory to directory • Eventually number will indicate when file no longer needed: canbe deleted Understanding Operating Systems, Sixth Edition
Directory Listings (cont'd.) Understanding Operating Systems, Sixth Edition