MULTIPROCESSORS 8.2 MULTICOMPUTERS 8.3 DISTRIBUTED SYSTEMS 8.4 RESEARCH ON MULTIPLE PROCESSOR SYSTEMS 8.5 SUMMARY
Trang 15 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
Trang 3Two address One address space Two address spaces
Memory
I/O ports 0xFFFF…
0
Fig 5-2 (a) Separate I/O and memory space (b) Memory-mapped I/O (c) Hybrid.
Trang 4CPU Memory I/O
Bus All addresses (memory
and I/O) go here
CPU reads and writes of memory
go over this high-bandwidth bus
This memory port is
to allow I/O devices access to memory
Fig 5-3 (a) A single-bus architecture (b) A dual-bus memory architecture.
Trang 5DMA 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.
Trang 6Interruptcontroller
3 CPU acks interrupt
2 Controller issues interrupt
1 Device is finished
Disk
Keyboard
PrinterClock
Bus
12 6
9 3 8 5 7
1 11 2 10
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.
Trang 7Printed page
(a)
ABCD EFGH
ABCD EFGH
Printed page
(b)
A Next
(c)
AB Next
Fig 5-6 Steps in printing a string.
Trang 8copy3from3user(buffer, p, count); /*p is the kernel bufer*/
for (i = 0; i < count; i++) { /*loop on every character*/
while (*printer3status3reg != READY) ;/*loop until ready*/
*printer3data3register = p[i]; /*output one character*/
}
return3to3user( );
Fig 5-7 Writing a string to the printer using programmed I/O.
Trang 9copy3from3user(buffer, p, count); if (count == 0) {
enable3interrupts( ); unblock3user( );
while (*printer3status3reg != READY) ; } else {
*printer3data3register = p[0]; *printer3data3register = p[i];
i = i + 1;
}acknowledge3interrupt( );
return3from3interrupt( );
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.
Trang 10copy3from3user(buffer, p, count); acknowledge3interrupt( );
set3up3DMA3controller( ); unblock3user( );
scheduler( ); return3from3interrupt( );
Fig 5-9 Printing a string using DMA (a) Code executed when the print system call is made (b) Interrupt service procedure.
Trang 11User-level I/O software Device-independent operating system software
Device drivers Interrupt handlers Hardware
Fig 5-10 Layers of the I/O software system.
Trang 12Rest of the operating system
Printerdriver
Camcorderdriver
CD-ROMdriver
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.
Trang 14Operating system Operating system
Disk driver Printer driver Keyboard driver Disk driver Printer driver Keyboard driver
Fig 5-13 (a) Without a standard driver interface (b) With a dard driver interface.
Trang 15Fig 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.
Trang 164
3User process
Network
Networkcontroller
Trang 17request
Layer
I/Oreply I/O functionsMake 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-independentsoftwareDevice drivers
Interrupt handlers
Hardware
Fig 5-16 Layers of the I/O system and the main functions of each layer.
Trang 18Fig 5-17 Disk parameters for the original IBM PC 360-KB
floppy disk and a Western Digital WD 18300 hard disk.
Trang 190 1 2
3
5 6
1415
2 3 4 5 6 7
9 1 11 12 13 14 15 16 17 18
5
7
89 10 11
12 13 14 15 16
1 7
1 2 21 22
Fig 5-18 (a) Physical geometry of a disk with two zones.
(b) A possible virtual geometry for this disk.
Trang 20P16-19 Strip 16 Strip 17 Strip 18
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
RAID level 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
Strip 11 Strip 7 P0-3
Fig 5-19 RAID levels 0 through 5 Backup and parity drives are shown shaded.
Trang 21Spiral groove
PitLand
2K block ofuser data
Fig 5-20 Recording structure of a compact disc or CD-ROM.
Trang 22Frames 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.
Trang 23Printed label
Protective lacquerReflective gold layer
layer
SubstrateDirection
Infraredlaserdiode
Dark spot in thedye layer burned
by laser whenwriting1.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.
Trang 24Polycarbonate substrate 1
Polycarbonate substrate 2
Semireflective layer
Semireflective layer
Aluminum reflector
Aluminum reflector
Trang 25Preamble Data ECC
Fig 5-24 A disk sector.
Trang 260 1 2 3 4 5 6 7
9 10
11
12 13
1 41 51 61 71 81 92 0 21 22
24 25 26
2930 31
0 1 2 3 4
6 7 8 9 10 11 12 13 14
15 16
17
1 8 1
345678911 121314116
181 2
2122
23 24 2
5
23 24
252627229 3
01234567 8910
11
1
1 3
1
11819
22
222324226 2
293310123456 7
89
10
111151617
19 20 21 2 232
262 282930 31 0 123456 7
9
1
11213
14
rotation
Fig 5-25 An illustration of cylinder skew.
Trang 275
(b)
07
52
41
36
(c)
05
14
36
27
Fig 5-26 (a) No interleaving (b) Single interleaving (c) Double interleaving.
Trang 28Initial position
Pending requests
Trang 29Initial position
Trang 303 4 5 6 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
Trang 311
Old
2 Disk
ECC error
Fig 5-30 Analysis of the influence of crashes on stable writes.
Trang 32Crystal oscillator
Counter is decremented at each pulse
Holding register is used to load the counter
Fig 5-31 A programmable clock.
Trang 33Fig 5-32 Three ways to maintain the time of day.
Trang 34Current time Next signal Clock
Trang 35CPU Memory
RS-232interface
Trang 36(a) (b)
Terminal
data structure
Terminal data structure
Terminal Terminal
Central buffer pool
area for terminal 0
area for terminal 1
Trang 39CPU Memory
Graphics
controller Video
RAM
Analog video signal Parallel port
Bus
Fig 5-38 With memory-mapped displays, the driver writes directly into the display’s video RAM.
Trang 4080 characters (a)
Fig 5-39 (a) A video RAM image for a simple monochrome
display in character mode (b) The corresponding screen The × s are attribute bytes.
Trang 41Fig 5-40 A sample window located at (200, 100) on an XGA display.
Trang 42#include <windows.h>
int WINAPI WinMain(HINSTANCE h, HINSTANCE, hprev, char*szCmd, int iCmdShow){
WNDCLASS wndclass; /*class object for this window*/
MSG msg; /*incoming messages are stored here*/
HWND hwnd; /*handle (pointer) to the window object*/
/*Initialize wndclass*/
wndclass.lpfnWndProc = WndProc; /*tells which procedure to call*/
wndclass.lpszClassName = "Program name"; /*Text for title bar*/
wndclass.hIcon = LoadIcon(NULL, IDI3APPLICATION);/*load program icon*/wndclass.hCursor = LoadCursor(NULL, IDC3ARROW); /*load mouse cursor*/RegisterClass(&wndclass); /*tell Windows about wndclass*/
hwnd = CreateWindow ( ) /*allocate storage for the window*/
ShowWindow(hwnd, iCmdShow); /*display the window on the screen*/UpdateWindow(hwnd); /*tell the window to paint itself*/
while (GetMessage(&msg, NULL, 0, 0)) { /*get message from queue*/
TranslateMessage(&msg); /*translate the message*/
DispatchMessage(&msg); /*send msg to the appropriate procedure*/
case WM3CREATE: ; return ; /*create window*/
case WM3PAINT: ; return ; /*repaint contents of window*/case WM3DESTROY: ; return ; /*destroy window*/
Trang 430 0
Fig 5-42 An example rectangle drawn using Rectangle Each box
represents one pixel.
Trang 442 4 6 8
Window 1
Window 2
0 2 4 6 8
0 2 4 6 8 0
2 4 6 8
Trang 46Remote host Window
manager
Application program Motif
Intrinsics Xlib
X client UNIX Hardware
X server UNIX Hardware
X terminal
Window User
Trang 47#include <X11/Xlib.h>
#include <X11/Xutil.h>
main(int argc, char*argv[])
{
int running = 1;
disp = XOpenDisplay("display3name"); /*connect to the X server*/
win = XCreateSimpleWindow(disp, ); /*allocate memory for new window*/XSetStandardProperties(disp, ); /*announces window to window mgr*/
gc = XCreateGC(disp, win, 0, 0); /*create graphic context*/
XSelectInput(disp, win, ButtonPressMask | KeyPressMask | ExposureMask);XMapRaised(disp, win); /*display window; send Expose event*/
while (running) {
XNextEvent(disp, &event); /*get next event*/
switch (event.type) {
case Expose: ; break; /*repaint window*/
case ButtonPress: ; break; /*process mouse click*/
case Keypress: ; break; /*process keyboard input*/
}
}
XFreeGC(disp, gc); /*release graphic context*/
XDestroyWindow(disp, win); /*deallocate window’s memory space*/
XCloseDisplay(disp); /*tear down network connection*/
}
Fig 5-46 A skeleton of an X Window application program.
Trang 48Computer center
Dedicatednetworkconnection
Switch
Disks
Thin clientServer(s)
Fig 5-47 The architecture of the SLIM terminal system.