io managment
Embed Size (px)
TRANSCRIPT
-
8/6/2019 IO Managment
1/19
I/O Management
-
8/6/2019 IO Managment
2/19
2
Differences in I/O Devices
Data transfer rate
Complexity ofcontrol
Unit oftransfer data may be transferred as
a stream ofbytes (e.g. terminal), stream-oriented
in larger blocks (e.g. disk), block-oriented
Data representation Error conditions
-
8/6/2019 IO Managment
3/19
3
-
8/6/2019 IO Managment
4/19
Objectives and implication
Chap 11 4
Blocking - process suspended until I/O completed
Easy to use and understand
Insufficient for some needs
Nonblocking - I/O call returns as much as available
User interface, data copy (buffered I/O)
Implemented via multi-threading
Returns quickly with count of bytes read or written
Asynchronous - process runs while I/O executes
Difficult to use
I/O subsystem signals process when I/O completed
-
8/6/2019 IO Managment
5/19
5
Performing I/O
Programmed I/O
Process is busy-waiting for the operation tocomplete
Interrupt-driven I/O
I/O command is issued
Processor continues executing instructions
I/O module sends an interrupt when done
-
8/6/2019 IO Managment
6/19
6
Performing I/O
Direct Memory Access (DMA)
DMA module controls exchange ofdatabetween main memory and the I/O device
Processorinterrupted only after entire block
has been transferred
-
8/6/2019 IO Managment
7/19
7
DMA Configurations
-
8/6/2019 IO Managment
8/19
8
DMA Configurations
-
8/6/2019 IO Managment
9/19
9
Techniques forPerforming I/O
Programmed I/O Interrupt-driven I/OI/O-to-memorytransfer through
processor
DMADirect I/O-to-
memory transfer
No Interrupts Use of Interrupts
-
8/6/2019 IO Managment
10/19
10
Operating System Design Issues
Efficiency
Most I/O devices extremely slow comparedto main memory
Use ofmultiprogramming allows for some
processes to be waiting on I/O while another
process executes I/O cannot keep up with processor speed
Swapping is used to bring in additional
Ready processes which is an I/O operation
-
8/6/2019 IO Managment
11/19
11
Operating System Design Issues
Generality
Desirable to handle all I/O devices in auniform manner
Hide most ofthe details ofdevice I/O in
lower-level routines so that processes and
upper levels see devices in general terms suchas read, write, open, close, lock, unlock
-
8/6/2019 IO Managment
12/19
Buffer Buffering - store data in memory while transferring
between devices
To cope with device speed mismatch
To cope with device transfer size mismatch
To maintain copy semantics
Chap 11 12
-
8/6/2019 IO Managment
13/19
13
I/O Buffering
Reasons for buffering
Processes must wait for I/O to complete before
proceeding
Certain pages must remain in main memory during
I/O
Chap
Addressing space of a process
...fgets(F,s1)fgets(F,s2)...
s1
z
I/O device
Chap 11Input / Output
s2
-
8/6/2019 IO Managment
14/19
14
How I/O Buffer works, 1
Addressing space of a process
...fgets(F,s1)fgets(F,s2)...
s1
z
I/O device
Chap 11
Input / Output
s2
To avoid these overheads and
inefficiencies, it is sometimes convenient
to perform input transfers in advance of
requests being made and to perform
output transfers sometime after the
request is made. This technique is
known as buffering.
Cha
I/O buffer
OS reads data from I/O
device to I/O buffer. User
process reads from I/O buffer.
(similar for data write)
I/O buffer is not swapped out.
-
8/6/2019 IO Managment
15/19
15
How I/O Buffer works, 2Chap 11
Addressing space of a process
...fgets(F,s1)fgets(F,s2)...
s1
I/O device
Chap 11
Input / Output
s2
When the process requests the first line, it is
blocked. A few lines will be read, in advance, from
the I/O device to the I/O buffer. Later, when the
process requests the second line, the OS can
satisfy the request from the I/O buffer without
blocking.
Chap 11
Input / Output
Input/Output
I/O buffer
-
8/6/2019 IO Managment
16/19
16
I/O Buffering
-
8/6/2019 IO Managment
17/19
17
Double Buffer
Use two system buffers instead ofone
A process can transfer data to orfrom one buffer
while the operating system empties orfills the
other buffer
-
8/6/2019 IO Managment
18/19
-
8/6/2019 IO Managment
19/19
Chap 11 19
Spooling
hold output for a device If device can
serve only one request at a time
i.e., Printing