CS623 – Session 9
Download
Report
Transcript CS623 – Session 9
CS623: Lecture 4
2/17/2004
© Joel Wein 2003, modified by T. Suel
Review of I/O - Key Issues
Current performance battleground:
–
–
–
–
Processor speeds increasing, SMPs coming
Internal memory getting faster, multi-level caches
I/O to disk lags behind
But not capacity: data sets growing with disks
File Systems:
–
–
–
–
Performance
Reliability
Security
Distributed File Systems
Organization of the I/O Function
Programmed I/O:
–
–
Interrupt-Driven I/O:
–
I/O-to-memory transfer through processor.
Processor issues an I/O command, on behalf of
process, to an I/O module. Process busy-waits
for operation to be completed before proceeding.
Processor issues I/O command on behalf of
process, continues to process, is interrupted by
I/O module when done
“synchronous vs. asynchronous I/O”
Organization of the I/O Function
Direct Memory Access:
–
–
–
Direct I/O to Memory transfer
DMA module controls exchange of data
between main memory and I/O module.
Processor interrupted only after entire block
has been transferred.
Evolution of I/O Function
1.
2.
3.
4.
5.
6.
Processor directly controls a peripheral device.
Controller or I/O module added. Proc uses
programmed I/O w/o interrupts. Proc becomes
somewhat divorced from details of external device
interfaces
Add interrupts. Processor does not need to wait for
I/O to happen
I/O module is given direct control of memory via
DMA. Can now move a block of data to or from
memory without involving the processor, except at
the beginning and end of each transfer.
I/O module is enhanced to become a separate proc
I/O module has local memory and is own computer
OS Design Issues
Design Objectives
–
Generality
–
–
–
Efficiency
handle devices in a uniform fashion.
Hierarchical, modular approach
Hide most of details of device I/O in lower-level
routines
Logical Structure of I/O Function
Logical Structure of I/O Function
Logical I/O: deal with device as logical
resource and not concerned with details of
controlling the device
Device I/O: Requested operations and data
are converted into appropriate sequences
of I/O instructions, channel commands and
controller orders.
Scheduling and Control: Actual queueing
and scheduling of I/O operations.
See Figure 11.5
Additional Layers
Directory Management
–
File system:
–
Symbolic file names converted to identifiers that
reference file directly or indirectly through file
descriptor or index table.
Logical structure of files, operations that can be
specified by users, such as open, close, read,
write. Access rights managed here too.
Physical Organization
I/O Buffering
Suppose we are reading blocks of data from
tape one at a time:
–
–
–
Program has to wait for I/O, may be swapped out
Approach to I/O interferes with OS swapping
decisions. Target locations must remain in main
memory. Impossible to completely swap the
process out.
If swap out could get a single-process deadlock.
Process issues I/O command, suspended awaiting result,
swapped out waiting.
Process blocked waiting on I/O, I/O blocked waiting for it
to be swapped in.
must lock certain areas of memory involved
in I/O
try to ameliorate by doing input transfers in
advance of requests made and to perform
output transfers sometime after a request is
made
Single Buffering
When user process issues I/O request, OS assigns a
buffer in system portion of main memory to the
operation.
–
–
–
Advantages:
–
–
Input transfers made to system buffer
When transfer complete, moved to user space,
Immediately request another block – anticipated input.
Speedup
Can swap process out because I/O to system memory, not
user space
Double Buffer: A process transfers data to one buffer
while the OS empties or fills the other
Circular Buffer
Double buffering may be inadequate if process
performs rapid bursts of I/O. Use multiple buffers.
NOTE: No amount of buffering will allow an I/O
device to keep pace with a process indefinitely
when average demand of process is greater than
I/O device can service
–
–
Even with multiple buffers, all of the buffers will
eventually fill up and the process will have to wait after
processing each chunk of data.
In a multiprogramming environment, when there is a
variety of I/O activity, etc., it can help
I/O systems function using disk
hardware
Drive Geometry
–
–
–
–
Disks are designed as circular platters
stacked one on top of another
Tracks are defined in each disk as
circular structures at some predefined
radius
Sectors are one slice of a track
Cylinders are one set of tracks across all
the disks
Disk Scheduling
Seek time:
–
–
Rotational Delay
–
–
Startup time, traversal time, settling time
Average seek time “today:” 5 to 10 ms.
5400 to 10000 rpm
10000 rpm = one revolution per 6 ms; average
rotational delay 3ms.
Transfer time to or from disk:
bytes/(Bytes per Track)*Rotation Speed
(RPS)
Example 1
Average seek time: 10 ms
Rotational Speed: 10,000 RPM
Format Characteristics:
–
–
512 Bytes/Sector
320 Sectors/Track
Read a file of 1,310,720 (1.3MB) – two
cases:
a)
it’s fully sequential
–
8 tracks, 8x320=2560 sectors.
b) it’s 100% fragmented (Random access)
Fully sequential
2560 Sectors
Average seek: 10ms
Rotational delay: 3 ms
Read 320 sectors: 6 ms.
So, time to read 1st track = 19 ms.
Suppose rest of tracks have no seek time.
19 + 7*9 = .082 seconds.
Random
Average seek 10 ms
Rot delay 3 ms.
Read 1 sector 0.01875 ms
2560 x 13.01875ms = 33.328 sec.
Order in which sectors read from disk
makes a difference
Important to keep files “together” on disk
Disk Scheduling Policies:
Queue/Requestor-Based
Random
–
FIFO
–
–
–
Process items from queue in seq. order; fair.
Good if a few processes do access to clustered file sectors
If many processes competing for disk, approaches random
Priority
–
Select items from queue in random order (bad)
Does not optimize disk utilization but meets other objectives
within the OS
LIFO
–
–
–
Always take most recent request
Great for a sequential file
Starvation possible
Disk Scheduling Policies:
Advanced
SSTF– choose I/O request with least seek
time. Better than FIFO
(all these algos except for FIFO can have starvation)
SCAN:
–
–
–
–
Arm moves in one direction, satisfying all
outstanding requests.
When hits last request, turns around.
LOOK policy: Stop early if no more requests
Also called elevator
More policies:
C-SCAN: Restricts scanning to one direction
only
N-step-SCAN, FSCAN
–
–
–
SSTF, SCAN,C-SCAN can all have “arm stickiness”,
monopolizing device by repeated requests to
close-by tracks
segment disk-request queue in segments of size N:
one segment at a time processed completely.
FSCAN: All new requests in 2nd queue during scan
File Management - Terms
Field: Basic element of data; could be fixed or
variable-length.
Record: collection of related fields that can be
treated as a unit by some application
File: collection of similar records
Database: collection of related data.
–
Relationships are made explicit in database.
Operations:
–
–
–
Retrieve_all/One/Next/Previous
Insert_One/Delete_One/Update_One
Retrieve_Few
File System Architecture
Device Drivers: communicate directly with
peripherals
Basic file system/physical I/O
–
–
Blocks of data that are exchanged with disk and
tape systems.
Deals with placements of those blocks on
secondary storage device and on buffering of
these blocks. No notion of content or structure
of files involved.
File System Architecture (cont.)
Basic I/O Supervisor:
–
–
File I/O initiation and termination
Scheduling disk and tape accesses to optimize
performance.
Logical I/O: Enable users and applications
to access records. Deals with file records,
not general blocks of data.
File Organization and Access
file organization: logical structuring of records
as determined by the way they are accessed
Criteria:
–
–
–
–
–
Rapid access
Ease of update
Economy of storage
Simple maintenance
Reliability
can be at tension:
–
Economy of storage v. rapid access