Professional Documents
Culture Documents
Understanding Operating Systems Fifth Edition
Understanding Operating Systems Fifth Edition
Understanding Operating Systems Fifth Edition
Learning Objectives
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
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
Disadvantage
No single standardized version Brief, cryptic commands difficult for novice learner
Understanding Operating Systems, Fifth Edition 3
History
Research project originally in 1965
Joint venture between Bell Labs, AT&T, General Electric, and MIT
Goal
Develop MULTICS for GE-645 mainframe
MULTICS ambition
Serve diverse user group needs
Too intricate, complex, large for commercial value
Bell labs withdrew in 1969 Ken Thompson and Dennis Ritchie continued the project
Understanding Operating Systems, Fifth Edition 4
History (continued)
1993: Berkeley
4.4 BSD: based on AT&Ts UNIX (AT&T license) Novell acquires UNIX from AT&T
Full local area network support Comply with international standards Security improved Uses Common Desktop Environment (CDE) ISO/IEC 9945:2003 Standard
9
Design Goals
Thompson and Ritchie vision
UNIX operating system
Created by programmers for programmers
Immediate goals
Support software development
Included utilities for customized code Utilities designed for simplicity: do one thing well Small manageable sections of code
POSIX
Portable operating system interface for computer environments
IEEE standards defining portable operating system interface IEEE STD. 1003.1 (2004 edition)
Understanding Operating Systems, Fifth Edition 11
Memory Management
Multiprogramming systems
Swapping (small jobs)
Entire program in main memory before execution Program size restriction Round robin policy
12
13
Space allocation
Program cannot release until all processes completed Text table: tracks processes using program code
14
Stack
Starts at highest memory address
Grows downward Subroutine calls and interrupts add information Main memory Process information saved when process interrupted
System calls
File Manager interaction and request of I/O services
Process Management
Handles
CPU allocation Process scheduling Satisfaction of process requests
Compute-to-total-time ratio
System updates for each job every second Total time process in system divided by used process CPU time
Ratio = one
CPU-bound job
18
Interactive processes: low ratio (no special policies) Balance I/O-bound jobs with CPU-bound jobs
Keeps processor busy Minimizes waiting processes overhead
19
20
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, Fifth Edition 21
22
23
Contains:
Memory address or secondary storage 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, Fifth Edition 24
Contains:
User and group identification numbers
Determine file access privileges
Pointer to current directory List of responses for various interrupts All information accessible when process running
Understanding Operating Systems, Fifth Edition 25
Synchronization
UNIX
True multitasking operating system
Race occurs
Event happens during process transition decision
Wait for event and entering WAIT state
26
Synchronization (continued)
fork
Execute one program from another program Second program
Given all first program attributes (open files)
fork executed
Process id (pid) generated Ensure each process has unique ID number
Understanding Operating Systems, Fifth Edition 27
Synchronization (continued)
28
Synchronization (continued)
wait
Synchronize process execution
Suspend parent until child finished
29
Synchronization (continued)
30
Synchronization (continued)
exec
Start new program execution from another program
execl, execv, execls, execlp, and execvp
31
Synchronization (continued)
32
Device Management
Device independence to applications
I/O device treated as special file type
Device drivers
Subroutines working with operating system Supervise data transmission
Between main memory and peripheral unit
Device Classifications
Divide I/O system
Block I/O system (structured I/O system) Character I/O system (unstructured I/O system)
35
36
I/O procedure synchronized through hardware completion interrupts Some devices belong to both classes
Examples: disk drives, tape drives
38
Device Drivers
Special section in kernel
Includes instructions
Allows operating system communication with device
File Management
Three file types
Directories Ordinary files Special files
40
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 device association
41
Text files
Character strings
Lines delimited by line feed, new line, character
Binary files
Sequences of binary digits
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, Fifth Edition 42
45
46
Path name
One name or list of names: separated by slashes Last name on list: filename requested
Directory Listings
long listing
Eight pieces of information for each file
First column
Shows file type and access privileges for each file
First character: nature of file or directory Next three characters: access privileges granted file owner Next three characters: access privileges granted other users group members Last three characters: access privileges granted to users at large (system-wide)
Understanding Operating Systems, Fifth Edition 48
Aliases
Important UNIX feature: support file sharing
Several users work together on same project
Shared files appear in different directories belonging to different users Filename: may be different from directory to directory Eventually number will indicate when file no longer needed: can be deleted
Understanding Operating Systems, Fifth Edition 49
50
Data Structures
File descriptors divided into parts
Hierarchical directories
Contain filename and i-number Pointer to another location: i-node
i-node
Contains rest of information
51
52
53
54
User Interface
Command-driven system User commands
Very short
One character or a group of characters (acronym)
55
56
command
Any legal operating system command
Interpreted and executed by shell
arguments
Required for some commands, optional for others
file_name
Relative or absolute path name
57
58
Script Files
Automate repetitious tasks
Command files
Often called shell files or script files
59
60
Redirection
Send output to file or another device
Symbol: > (between command and destination) Examples:
ls > myfiles cat chapt1 chapt2 > sectiona, cat chapt* > sectiona
61
Redirection (continued)
Reverse redirection (<)
Takes input for program from existing file instead of keyboard Example:
mail ann roger < memo
62
Redirection (continued)
Redirection (>)
Combined with system commands to achieve any desired results Example: who > temporary
Store in temporary file: all user names logged on
Pipes
Provide possibility to redirect output or input to selected files or devices
Connect output from one program to input of another No need for temporary or intermediate files Example: who | sort
Pipeline
Several programs simultaneously processing same I/O stream Example: who | sort | lpr
64
Filters
Program
Read some input, manipulate it, generate output wc (word count):
Example: wc journal System response: 10 140 700
65
Filters (continued)
Sort list in alphabetical order ignoring letter case
sort f > sortednames
66
Additional Commands
man
Displays operating system online manual Example: man cmp
Displays page for compare (cmp) command
grep
global regular expression and print Look for specific character patterns Examples:
grep Pittsburgh maillist grep -v Pittsburgh maillist grep -c Pittsburgh maillist
Understanding Operating Systems, Fifth Edition 67
nohup
Log off the system without program completion Example:
nohup cp oldlargefile newlargefile and
Understanding Operating Systems, Fifth Edition 68
69
Summary
UNIX: major force in operating system field
Written by programmers for programmers Quite popular among programmers
Advantages
Spare user interface, device independence, portability, lack of verbosity, powerful command combinations
Disadvantages
Learning command-driven interface, brief commands