Professional Documents
Culture Documents
tm09-15
tm09-15
g Background
g Demand Paging
g Page Replacement
g Page-Replacement Algorithms
g Allocation of Frames
g Thrashing
g Other Considerations
g Demand Segmentation
- Demand paging
- Demand segmentation
Operating System Concepts, Addison-Wesley 1994 9.1 Silberschatz & Galvin 1994
Demand Paging
- Faster response
- More users
Operating System Concepts, Addison-Wesley 1994 9.2 Silberschatz & Galvin 1994
Valid−Invalid bit
0
0
page table
Operating System Concepts, Addison-Wesley 1994 9.3 Silberschatz & Galvin 1994
Page Fault
6. Restart instruction:
- block move
Operating System Concepts, Addison-Wesley 1994 9.4 Silberschatz & Galvin 1994
What happens if there is no free frame?
⇒ algorithm
Operating System Concepts, Addison-Wesley 1994 9.5 Silberschatz & Galvin 1994
Performance of Demand Paging
g Example:
- memory access time = 1 microsecond
- 50% of the time the page that is being replaced
has been modified and therefore needs to be
swapped out.
- Swap Page Time = 10 msec = 10,000 msec
- EAT = (1 - p ) × 1 + p (15000)
= 1 + 15000P (in msec)
Operating System Concepts, Addison-Wesley 1994 9.6 Silberschatz & Galvin 1994
Page Replacement
Operating System Concepts, Addison-Wesley 1994 9.7 Silberschatz & Galvin 1994
Page-Replacement Algorithms
1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5.
Operating System Concepts, Addison-Wesley 1994 9.8 Silberschatz & Galvin 1994
First-In-First-Out (FIFO) Algorithm
Reference string: 1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5
c c
1 iiii
1 4 5
c c
2 2
ciiiic 1 3 9 page faults
c c
3 c
3
iiii c
2 4
g 4 frames
iiii
c c
1 iiii
1 5 4
c c
2 ciiiic 2 1 5
c c
3 3
iiii
2 10 page faults
c c
4 ciiii
c cc4 3
Operating System Concepts, Addison-Wesley 1994 9.9 Silberschatz & Galvin 1994
Optimal Algorithm
g 4 frames example
1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4, 5
iiii
c c
iiii
1 4
c c
2
ciiiic 6 page faults
c c
iiii
3
c c
4
cciiiicc 5
Operating System Concepts, Addison-Wesley 1994 9.10 Silberschatz & Galvin 1994
Least Recently Used (LRU) Algorithm
iiii
c c
iiii
1 5
c c
2
ciiiic
c c
3
iiii
5 4
c c
4
cciiiicc 3
g Counter implementation
- Every page entry has a counter; every time
page is referenced through this entry, copy the
clock into the counter.
- When a page needs to be changed, look at the
counters to determine which are to change
Operating System Concepts, Addison-Wesley 1994 9.11 Silberschatz & Galvin 1994
LRU Approximation Algorithms
g Reference bit
- With each page associate a bit, initially = 0.
- When page is referenced bit set to 1.
- Replace the one which is 0 (if one exists). We
do not know the order, however.
g Second chance
- Need reference bit.
- Clock replacement.
- If page to be replaced (in clock order) has
reference bit = 1, then:
Operating System Concepts, Addison-Wesley 1994 9.12 Silberschatz & Galvin 1994
g Counting Algorithms − keep a counter of the
number of references that have been made to each
page.
Operating System Concepts, Addison-Wesley 1994 9.13 Silberschatz & Galvin 1994
Allocation of Frames
- fixed allocation
- priority allocation
Operating System Concepts, Addison-Wesley 1994 9.14 Silberschatz & Galvin 1994
g Fixed allocation
- Equal allocation
If 100 frames and 5 processes, give each 20
pages.
- Proportional allocation
Allocate according to the size of process.
b
si = size of process pi
b
S = Σ si
b
m = total number of frames
si
b
ai = allocation for pi = h
hh
×m
S
Example : m = 64
s 1 = 10
s 2 = 127
10
a 1 = hhhh × 64 ∼
∼5
137
127
a2 = hhhh
× 64 ∼
∼ 59
137
Operating System Concepts, Addison-Wesley 1994 9.15 Silberschatz & Galvin 1994
g Priority allocation
Operating System Concepts, Addison-Wesley 1994 9.16 Silberschatz & Galvin 1994
Global versus local allocation
Operating System Concepts, Addison-Wesley 1994 9.17 Silberschatz & Galvin 1994
Thrashing
Operating System Concepts, Addison-Wesley 1994 9.18 Silberschatz & Galvin 1994
CPU
utilization
degree of multiprogramming
Locality model
- Process migrates from one locality to another.
- Localities may overlap.
Operating System Concepts, Addison-Wesley 1994 9.19 Silberschatz & Galvin 1994
Working-Set Model
g If D > m ⇒ thrashing.
Operating System Concepts, Addison-Wesley 1994 9.20 Silberschatz & Galvin 1994
How do you keep track of the working set?
g Approximate with:
interval timer + a reference bit
g Example:
∆ = 10,000
Operating System Concepts, Addison-Wesley 1994 9.21 Silberschatz & Galvin 1994
Page-Fault Frequency Scheme
increase
number of
frames
page
upper bound
fault
rate
lower bound
decrease
number of
frames
number of frames
Operating System Concepts, Addison-Wesley 1994 9.22 Silberschatz & Galvin 1994
Other Considerations
1. Prepaging
2. Page size selection
- fragmentation
- table size
- I/O overhead
- locality
3. Program structure
- Array A[1024,1024] of integer
- Each row is stored in one page
- One frame
- Program 1 for j := 1 to 1024 do
for i := 1 to 1024 do
A[i , j ] := 0;
1024 × 1024 page faults
- Program 2 for i := 1 to 1024 do
for j := 1 to 1024 do
A[i , j ] := 0;
1024 page faults
4. I/O interlock and addressing
Operating System Concepts, Addison-Wesley 1994 9.23 Silberschatz & Galvin 1994
Demand Segmentation − used when insufficient
hardware to implement demand paging.
Operating System Concepts, Addison-Wesley 1994 9.24 Silberschatz & Galvin 1994
CHAPTER 10: FILE-SYSTEM INTERFACE
g File Concept
g Access Methods
g Directory Structure
g Protection
g Consistency Semantics
g Types:
- Data
numeric
character
binary
- Program
source
object (load image)
- Documents
Operating System Concepts, Addison-Wesley 1994 10.1 Silberschatz & Galvin 1994
File Structure
g Complex Structures
- Formatted document
- Relocatable load file
Who decides:
Operating system
Program
Operating System Concepts, Addison-Wesley 1994 10.2 Silberschatz & Galvin 1994
g File Attributes
Operating System Concepts, Addison-Wesley 1994 10.3 Silberschatz & Galvin 1994
File Operations
g create
g write
g read
g reposition within file − file seek
g delete
g truncate
Operating System Concepts, Addison-Wesley 1994 10.4 Silberschatz & Galvin 1994
File Types − name.extension
i
iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
c c c c
c
Executable c
exe, com, bin c
ready-to-run machine- c
ci
or none language program
iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
c c c
c c c c
Object obj, o
compiled, machine lan-
c c c c
i
guage, not linked
iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
c c c c
c
i
c asm, a c guages
iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
c
c c c c
c
Batch c c
bat, sh
commands to the com- c
ci c c mand interpreter
iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii c
c c c c
i
Text txt, doc
iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
textual data, documents
c c c c
c
i
c etc c formats
iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
c
c c c c
c
Library c c
lib, a
libraries of routines for c
ci c c programmers
iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii c
c c c c
Print or view ps, dvi, gif ASCII or binary file in a
c c c c
c c c
format for printing or c
i c c
viewing
c iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii c
c c c
Archive related files grouped into c
arc, zip, tar
c c c
one file, sometimes com- c
c c c c
c c c
pressed, for archiving c
ci c
or storage
iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
c c
Operating System Concepts, Addison-Wesley 1994 10.5 Silberschatz & Galvin 1994
Access Methods
g Sequential Access
read next
write next
reset
no read after last write
(rewrite)
g Direct Access
read n
write n
position to n
read next
write next
rewrite n
Operating System Concepts, Addison-Wesley 1994 10.6 Silberschatz & Galvin 1994
Directory Structure − a collection of nodes contain-
ing information about all files.
Directory
Files
F1 F2 F3 F4
Fn
Operating System Concepts, Addison-Wesley 1994 10.7 Silberschatz & Galvin 1994
Information in a device directory:
g Name
g Type
g Address
g Current length
g Maximum length
Operating System Concepts, Addison-Wesley 1994 10.8 Silberschatz & Galvin 1994
Operations performed on directory:
g Create a file
g Delete a file
g List a directory
g Rename a file
Operating System Concepts, Addison-Wesley 1994 10.9 Silberschatz & Galvin 1994
Organize the directory (logically) to obtain:
Operating System Concepts, Addison-Wesley 1994 10.10 Silberschatz & Galvin 1994
Single-Level Directory − a single directory for all
users.
directory
name
type of file . ..
location
...
files
g Naming problem
g Grouping problem
Operating System Concepts, Addison-Wesley 1994 10.11 Silberschatz & Galvin 1994
Two-Level Directory − separate directory for each
user.
root
avi jim
subdirectories
A B C A B
avi/A jim/A
g Path name
g Efficient searching
g No grouping capability
Operating System Concepts, Addison-Wesley 1994 10.12 Silberschatz & Galvin 1994
Tree-Structured Directories
avi
ch1 ch16
g Efficient searching
g Grouping capability
Operating System Concepts, Addison-Wesley 1994 10.13 Silberschatz & Galvin 1994
g Absolute or relative path name
g Delete a file
rm <file-name>
books
os db modula
Operating System Concepts, Addison-Wesley 1994 10.14 Silberschatz & Galvin 1994
Acyclic-Graph Directories − have shared subdirec-
tories and files.
A X
B Y
C
link
D
Operating System Concepts, Addison-Wesley 1994 10.15 Silberschatz & Galvin 1994
General Graph Directory
- Garbage collection.
Operating System Concepts, Addison-Wesley 1994 10.16 Silberschatz & Galvin 1994
Protection
g Types of access
- Read
- Write
- Execute
- Append
- Delete
- List
Operating System Concepts, Addison-Wesley 1994 10.17 Silberschatz & Galvin 1994
Access Lists and Groups
Operating System Concepts, Addison-Wesley 1994 10.18 Silberschatz & Galvin 1994
CHAPTER 11: FILE-SYSTEM IMPLEMENTATION
g File-System Structure
g Allocation Methods
g Free-Space Management
g Directory Implementation
g Recovery
g File structure
- Logical storage unit
- Collection of related information
Operating System Concepts, Addison-Wesley 1994 11.1 Silberschatz & Galvin 1994
Contiguous Allocation − each file occupies a set of
contiguous blocks on the disk.
g Random access.
Operating System Concepts, Addison-Wesley 1994 11.2 Silberschatz & Galvin 1994
Linked Allocation − each file is a linked list of disk
blocks; blocks may be scattered anywhere on the
disk.
block = pointer
1: 10
0: 2:
16 25
8: 9: 10:
1
16: 17: 18:
-1
24: 25: 26:
Operating System Concepts, Addison-Wesley 1994 11.3 Silberschatz & Galvin 1994
Linked Allocation (continued)
g No random access
g Mapping
Q
LA/511
R
Operating System Concepts, Addison-Wesley 1994 11.4 Silberschatz & Galvin 1994
Indexed Allocation − brings all pointers together
into the index block.
index table
9
16 1: 2:
0:
1
10 8: 9: 10:
25
16: 17: 18:
-1
index table
Operating System Concepts, Addison-Wesley 1994 11.5 Silberschatz & Galvin 1994
Indexed Allocation (continued)
g Random access
Operating System Concepts, Addison-Wesley 1994 11.6 Silberschatz & Galvin 1994
Indexed Allocation − mapping (continued)
b
Q 1 = block of index table
b
R 1 is used as follows:
Q2
R 1/512 < R2
b
Q 2 = displacement into block of index table
b
R 2 = displacement into block of file
Operating System Concepts, Addison-Wesley 1994 11.7 Silberschatz & Galvin 1994
Indexed Allocation − mapping (continued)
- Two-level index (maximum file size is 5123)
Q1
LA/(512×512)
R1
<
Q 1 = displacement into outer-index
b
R 1 is used as follows:
b
Q2
R 1/512
R2
<
Q 2 = displacement into block of index table
b
..
.
outer-index
Operating System Concepts, Addison-Wesley 1994 11.8 Silberschatz & Galvin 1994
Indexed Allocation − mapping (continued)
- Combined scheme: UNIX (4K bytes per block)
0
1
2
.
.
.
11
12 single
13 . indirect
14 . ..
. . block
double
.
indirect . ..
. .
block
triple . .
indirect . .. .
. . .
block
b
directly accessed 48K bytes
b
single indirection 222 bytes
b
double indirection 232 bytes
Operating System Concepts, Addison-Wesley 1994 11.9 Silberschatz & Galvin 1994
Free-Space Management
0 1 2 n-1
--
0 ⇒ block[i ] free
I
bit[i ] = K
L
1 ⇒ block[i ] occupied
Operating System Concepts, Addison-Wesley 1994 11.10 Silberschatz & Galvin 1994
g Need to protect:
- Pointer to free list
- Bit map
Must be kept on disk.
b
g Grouping
g Counting
Operating System Concepts, Addison-Wesley 1994 11.11 Silberschatz & Galvin 1994
Directory Implementation
- simple to program
- time-consuming to execute
- fixed size
Operating System Concepts, Addison-Wesley 1994 11.12 Silberschatz & Galvin 1994
Efficiency and Performance
g Performance
Operating System Concepts, Addison-Wesley 1994 11.13 Silberschatz & Galvin 1994
Recovery
Operating System Concepts, Addison-Wesley 1994 11.14 Silberschatz & Galvin 1994
CHAPTER 12: SECONDARY-STORAGE STRUCTURE
g Disk Structure
g Disk Scheduling
g Disk Management
g Swap-Space Management
g Disk Reliability
g Stable-Storage Implementation
B0
B1
..
.
Bn-1
Operating System Concepts, Addison-Wesley 1994 12.1 Silberschatz & Galvin 1994
Disk Scheduling
- Seek
- Latency
- Transfer
Head pointer 53
Operating System Concepts, Addison-Wesley 1994 12.2 Silberschatz & Galvin 1994
g FCFS
14 37 53 65 67 98 122 124 183
g SSTF
14 37 53 65 67 98 122 124 183
Operating System Concepts, Addison-Wesley 1994 12.3 Silberschatz & Galvin 1994
g SCAN
14 37 53 65 67 98 122 124 183
g C-SCAN
0 14 37 53 65 67 98 122 124 183 199
Operating System Concepts, Addison-Wesley 1994 12.4 Silberschatz & Galvin 1994
g LOOK
14 37 53 65 67 98 122 124 183
g C-LOOK
14 37 53 65 67 98 122 124 183
Operating System Concepts, Addison-Wesley 1994 12.5 Silberschatz & Galvin 1994
Disk Management
g Disk formatting
- physical
- logical
Operating System Concepts, Addison-Wesley 1994 12.6 Silberschatz & Galvin 1994
Swap-Space Management
g Swap-space use
g Swap-space location
- normal file system
- separate disk partition
g Swap-space management
- 4.3BSD allocates swap space when process
starts (holds text segment and data segment).
- Kernel uses swap maps to track swap-space
use.
Operating System Concepts, Addison-Wesley 1994 12.7 Silberschatz & Galvin 1994
Disk Reliability
g Disk striping
g RAID
Operating System Concepts, Addison-Wesley 1994 12.8 Silberschatz & Galvin 1994
Stable-Storage Implementation
Operating System Concepts, Addison-Wesley 1994 12.9 Silberschatz & Galvin 1994
CHAPTER 13: PROTECTION
g Goals of Protection
g Domain of Protection
g Access Matrix
g Capability-Based Systems
g Language-Based Protection
Operating System Concepts, Addison-Wesley 1994 13.1 Silberschatz & Galvin 1994
Domain Structure
D1 D2 D3
Operating System Concepts, Addison-Wesley 1994 13.2 Silberschatz & Galvin 1994
Domain Implementation
g System consists of 2 domains:
- user
- supervisor
g UNIX
- Domain = user-id
- Domain switch accomplished via file system.
Each file has associated with it a domain bit
b
(setuid bit).
When file is executed and setuid = on, then
b
Operating System Concepts, Addison-Wesley 1994 13.3 Silberschatz & Galvin 1994
Access Matrix
g Rows − domains
object
F1 F2 F3 printer
domain
D1 read read
D2 print
D3 read execute
D4 read read
write write
Operating System Concepts, Addison-Wesley 1994 13.4 Silberschatz & Galvin 1994
Use of Access Matrix
Operating System Concepts, Addison-Wesley 1994 13.5 Silberschatz & Galvin 1994
g Access matrix design separates mechanism from
policy.
Operating System Concepts, Addison-Wesley 1994 13.6 Silberschatz & Galvin 1994
Implementation of Access Matrix
Operating System Concepts, Addison-Wesley 1994 13.7 Silberschatz & Galvin 1994
Revocation of Access Rights
- simple
- immediate
- Reacquisition
- Back-pointers
- Indirection
- Keys
Operating System Concepts, Addison-Wesley 1994 13.8 Silberschatz & Galvin 1994
Capability-Based Systems
g Hydra
Operating System Concepts, Addison-Wesley 1994 13.9 Silberschatz & Galvin 1994
Language-Based Protection
Operating System Concepts, Addison-Wesley 1994 13.10 Silberschatz & Galvin 1994
CHAPTER 14: SECURITY
g Authentication
g Program Threats
g System Threats
g Threat Monitoring
g Encryption
- unauthorized access.
Operating System Concepts, Addison-Wesley 1994 14.1 Silberschatz & Galvin 1994
Authentication
Operating System Concepts, Addison-Wesley 1994 14.2 Silberschatz & Galvin 1994
Program Threats
g Trojan Horse
- Code segment that misuses its environment.
- Exploits mechanisms for allowing programs
written by users to be executed by other users.
g Trap Door
- Specific user identifier or password that cir-
cumvents normal security procedures.
- Could be included in a compiler.
Operating System Concepts, Addison-Wesley 1994 14.3 Silberschatz & Galvin 1994
System Threats
g Internet worm
- Exploited UNIX networking features (remote
access) and bugs in finger and sendmail pro-
grams.
- Grappling hook program uploaded main worm
program.
Operating System Concepts, Addison-Wesley 1994 14.4 Silberschatz & Galvin 1994
Threat Monitoring
Operating System Concepts, Addison-Wesley 1994 14.5 Silberschatz & Galvin 1994
Encryption
Operating System Concepts, Addison-Wesley 1994 14.6 Silberschatz & Galvin 1994
g Public-key encryption based on each user having
two keys:
- public key − published key used to encrypt
data.
- private key − key known only to individual
user used to decrypt data.
Operating System Concepts, Addison-Wesley 1994 14.7 Silberschatz & Galvin 1994
CHAPTER 15: NETWORK STRUCTURES
g Background
g Motivation
g Topology
g Network Types
g Communication
g Design Strategies
g Nodes
- Central processing unit
- Main memory
- Locally-attached disks
g Network
node 2
node 1
disk disk
processors
processors
disk disk
Network
node 3 node N
disk disk
processors processors
disk disk
...
Operating System Concepts, Addison-Wesley 1994 15.1 Silberschatz & Galvin 1994
Background − node types
banking systems
b
office-information systems
b
private databases
b
g Personal Computers
- example applications:
office information systems
b
Operating System Concepts, Addison-Wesley 1994 15.2 Silberschatz & Galvin 1994
Motivation
g Resource sharing
- sharing and printing files at remote sites
- processing information in a distributed data-
base
- using remote specialized hardware devices
Operating System Concepts, Addison-Wesley 1994 15.3 Silberschatz & Galvin 1994
Topology
Operating System Concepts, Addison-Wesley 1994 15.4 Silberschatz & Galvin 1994
Topology (continued)
A
A B
B C
F C
E E F D
D
A A
B
B E
F C
C D F D
E
Operating System Concepts, Addison-Wesley 1994 15.5 Silberschatz & Galvin 1994
Topology (continued)
A B
F C
E D
ring network
A C E
bus
B D
Operating System Concepts, Addison-Wesley 1994 15.6 Silberschatz & Galvin 1994
Network Types
Operating System Concepts, Addison-Wesley 1994 15.7 Silberschatz & Galvin 1994
Communication
Operating System Concepts, Addison-Wesley 1994 15.8 Silberschatz & Galvin 1994
Naming and Name Resolution
Operating System Concepts, Addison-Wesley 1994 15.9 Silberschatz & Galvin 1994
Routing Strategies
Operating System Concepts, Addison-Wesley 1994 15.10 Silberschatz & Galvin 1994
Routing Strategies (continued)
Operating System Concepts, Addison-Wesley 1994 15.11 Silberschatz & Galvin 1994
Connection Strategies
Operating System Concepts, Addison-Wesley 1994 15.12 Silberschatz & Galvin 1994
Contention
Operating System Concepts, Addison-Wesley 1994 15.13 Silberschatz & Galvin 1994
Contention (continued)
Operating System Concepts, Addison-Wesley 1994 15.14 Silberschatz & Galvin 1994
Design Strategies
Operating System Concepts, Addison-Wesley 1994 15.15 Silberschatz & Galvin 1994
g Transport layer − responsible for low-level net-
work access and for message transfer between
clients, including partitioning messages into pack-
ets, maintaining packet order, controlling flow,
and generating physical addresses.
Operating System Concepts, Addison-Wesley 1994 15.16 Silberschatz & Galvin 1994
Operating System Concepts, Addison-Wesley 1994 Silberschatz & Galvin 1994