Tải bản đầy đủ (.pdf) (52 trang)

A computer system consists of hardware, system programs, and application programs figs 5

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (513.01 KB, 52 trang )

5
INPUT/OUTPUT
5.1 PRINCIPLES OF I/O HARDWARE
5.2 PRINCIPLES OF I/O SOFTWARE
5.3 I/O SOFTWARE LAYERS
5.4 DISKS
5.5 CLOCKS
5.6 CHARACTER-ORIENTED TERMINALS
5.7 GRAPHICAL USER INTERFACES
5.8 NETWORK TERMINALS
5.9 POWER MANAGEMENT
5.10 RESEARCH ON INPUT/OUTPUT
5.11 SUMMARY
Device Data rate
Keyboard 10 bytes/sec
Mouse 100 bytes/sec
56K modem 7 KB/sec
Telephone channel 8 KB/sec
Dual ISDN lines 16 KB/sec
Laser printer 100 KB/sec
Scanner 400 KB/sec
Classic Ethernet 1.25 MB/sec
USB (Universal Serial Bus) 1.5 MB/sec
Digital camcorder 4 MB/sec
IDE disk 5 MB/sec
40x CD-ROM 6 MB/sec
Fast Ethernet 12.5 MB/sec
ISA bus 16.7 MB/sec
EIDE (ATA-2) disk 16.7 MB/sec
FireWire (IEEE 1394) 50 MB/sec
XGA Monitor 60 MB/sec


SONET OC-12 network 78 MB/sec
SCSI Ultra 2 disk 80 MB/sec
Gigabit Ethernet 125 MB/sec
Ultrium tape 320 MB/sec
PCI bus 528 MB/sec
Sun Gigaplane XB backplane 20 GB/sec
Fig. 5-1. Some typical device, network, and bus data rates.
Two address One address space Two address spaces
Memory
I/O ports
0xFFFF…
0
(a) (b) (c)
Fig. 5-2. (a) Separate I/O and memory space. (b) Memory-mapped
I/O. (c) Hybrid.
CPU Memory I/O
Bus
All addresses (memory
and I/O) go here
CPU Memory I/O
CPU reads and writes of memory
go over this high-bandwidth bus
This memory port is
to allow I/O devices
access to memory
(a) (b)
Fig. 5-3. (a) A single-bus architecture. (b) A dual-bus memory
architecture.
CPU
DMA

controller
Disk
controller
Main
memory
Buffer
1. CPU
programs
the DMA
controller
Interrupt when
done
2. DMA requests
transfer to memory
3. Data transferred
Bus
4. Ack
Address
Count
Control
Drive
Fig. 5-4. Operation of a DMA transfer.
CPU
Interrupt
controller
3. CPU acks
interrupt
2. Controller
issues
interrupt

1. Device is finished
Disk
Keyboard
Printer
Clock
Bus
12
6
93
48
57
111
210
Fig. 5-5. How an interrupt happens. The connections between the
devices and the interrupt controller actually use interrupt lines on
the bus rather than dedicated wires.
String to
be printed
User
space
Kernel
space
ABCD
EFGH
Printed
page
(a)
ABCD
EFGH
ABCD

EFGH
Printed
page
(b)
A
Next
(c)
AB
Next
Fig. 5-6. Steps in printing a string.
copy from user(buffer, p, count); /
*
p is the kernel bufer
*
/
for (i = 0; i < count; i++) { /
*
loop on every character
*
/
while (
*
printer status reg != READY) ;/
*
loop until ready
*
/
*
printer data register = p[i]; /
*

output one character
*
/
}
return to user( );
Fig. 5-7. Writing a string to the printer using programmed I/O.
copy from user(buffer, p, count); if (count == 0) {
enable interrupts( ); unblock user( );
while (
*
printer status reg != READY) ; } else {
*
printer data register = p[0];
*
printer data register = p[i];
scheduler( ); count = count − 1;
i=i+1;
}
acknowledge interrupt( );
return from interrupt( );
(a) (b)
Fig. 5-8. Writing a string to the printer using interrupt-driven I/O.
(a) Code executed when the print system call is made. (b) Inter-
rupt service procedure.
copy from user(buffer, p, count); acknowledge interrupt( );
set up DMA controller( ); unblock user( );
scheduler( ); return from interrupt( );
(a) (b)
Fig. 5-9. Printing a string using DMA. (a) Code executed when
the print system call is made. (b) Interrupt service procedure.

User-level I/O software
Device-independent operating system software
Device drivers
Interrupt handlers
Hardware
Fig. 5-10. Layers of the I/O software system.
User
space
Kernel
space
User process
User
program
Rest of the operating system
Printer
driver
Camcorder
driver
CD-ROM
driver
Printer controllerHardware
Devices
Camcorder controller CD-ROM controller
Fig. 5-11. Logical positioning of device drivers. In reality all
communication between drivers and device controllers goes over
the bus.
Uniform interfacing for device drivers
Buffering
Error reporting
Allocating and releasing dedicated devices

Providing a device-independent block size
Fig. 5-12. Functions of the device-independent I/O software.
Operating system Operating system
Disk driver Printer driver Keyboard driver Disk driver Printer driver Keyboard driver
(a) (b)
Fig. 5-13. (a) Without a standard driver interface. (b) With a stan-
dard driver interface.
User process
User
space
Kernel
space
22
113
Modem Modem Modem Modem
(a) (b) (c) (d)
Fig. 5-14. (a) Unbuffered input. (b) Buffering in user space.
(c) Buffering in the kernel followed by copying to user space. (d)
Double buffering in the kernel.
2
1
5
4
3
User process
Network
Network
controller
User
space

Kernel
space
Fig. 5-15. Networking may involve many copies of a packet.
I/O
request
Layer
I/O
reply
I/O functions
Make I/O call; format I/O; spooling
Naming, protection, blocking, buffering, allocation
Set up device registers; check status
Wake up driver when I/O completed
Perform I/O operation
User processes
Device-independent
software
Device drivers
Interrupt handlers
Hardware
Fig. 5-16. Layers of the I/O system and the main functions of each
layer.
Parameter IBM 360-KB floppy disk WD 18300 hard disk
Number of cylinders 40 10601
Tracks per cylinder 2 12
Sectors per track 9 281 (avg)
Sectors per disk 720 35742000
Bytes per sector 512 512
Disk capacity 360 KB 18.3 GB
Seek time (adjacent cylinders) 6 msec 0.8 msec

Seek time (average case) 77 msec 6.9 msec
Rotation time 200 msec 8.33 msec
Motor stop/start time 250 msec 20 sec
Time to transfer 1 sector 22 msec 17 µsec
Fig. 5-17. Disk parameters for the original IBM PC 360-KB
floppy disk and a Western Digital WD 18300 hard disk.
0
1
2
3
4
5
6
7
8
9
1
0
1
1
1
2
1
3
1
4
1
5
0
1

2
3
4
5
6
7
8
9
1
0
1
1
1
2
1
3
1
4
1
5
1
6
1
7
1
8
1
9
2
0

2
1
2
2
2
3
2
4
2
5
2
6
2
7
2
8
2
9
3
0
3
1
0
1
2
3
4
5
6
7

8
9
1
0
1
1
1
2
1
3
1
4
1
5
1
6
1
7
1
8
1
9
2
0
2
1
2
2
2
3

2
4
Fig. 5-18. (a) Physical geometry of a disk with two zones.
(b) A possible virtual geometry for this disk.
P16-19 Strip 16 Strip 17 Strip 18
Strip 12 P12-15 Strip 13 Strip 14
(a)
(b)
(c)
(d)
(e)
(f)
RAID level 0
Strip 8
Strip 4
Strip 0
Strip 9
Strip 5
Strip 1
Strip 10
Strip 6
Strip 2
RAID level 2
Strip 11
Strip 7
Strip 3
Strip 8
Strip 4
Strip 0
Strip 9

Strip 5
Strip 1
Strip 10
Strip 6
Strip 2
Strip 11
Strip 7
Strip 3
Strip 8
Strip 4
Strip 0
Strip 9
Strip 5
Strip 1
Strip 10
Strip 6
Strip 2
Strip 11
Strip 7
Strip 3
Bit 1 Bit 2 Bit 3 Bit 4 Bit 5 Bit 6
RAID
level 1
Bit 7
Bit 1 Bit 2 Bit 3 Bit 4
Strip 8
Strip 4
Strip 0
Strip 9
Strip 5

Strip 1
Strip 10
Strip 6
Strip 2
Strip 11
Strip 7
Strip 3
Strip 8
Strip 4
Strip 0
Strip 9
Strip 5
Strip 1
P8-11
Strip 6
Strip 2
Strip 10
P4-7
Strip 3
Strip 19
Strip 15
RAID level 3
RAID level 4
RAID level 5
Parity
P8-11
P4-7
P0-3
Strip 11
Strip 7

P0-3
Fig. 5-19. RAID levels 0 through 5. Backup and parity drives are
shown shaded.
Spiral groove
Pit
Land
2K block of
user data
Fig. 5-20. Recording structure of a compact disc or CD-ROM.
Preamble
Bytes 16
Data
2048 288
ECC
Mode 1
sector
(2352 bytes)
Frames of 588 bits,
each containing
24 data bytes
Symbols of
14 bits each
42 Symbols make 1 frame
98 Frames make 1 sector


Fig. 5-21. Logical data layout on a CD-ROM.
Printed label
Protective lacquer
Reflective gold layer

layer
Substrate
Direction
of motion
Lens
Photodetector Prism
Infrared
laser
diode
Dark spot in the
dye layer burned
by laser when
writing
1.2 mm
Dye
Polycarbonate
Fig. 5-22. Cross section of a CD-R disk and laser (not to scale).
A silver CD-ROM has a similar structure, except without the dye
layer and with a pitted aluminum layer instead of a gold layer.
Polycarbonate substrate 1
Polycarbonate substrate 2
Semireflective
layer
Semireflective
layer
Aluminum
reflector
Aluminum
reflector
0.6 mm

Single-sided
disk
0.6 mm
Single-sided
disk
Adhesive layer
Fig. 5-23. A double-sided, dual layer DVD disk.
Preamble Data ECC
Fig. 5-24. A disk sector.

×