Académique Documents
Professionnel Documents
Culture Documents
Course text: "Computer Systems Architecture - a networking approach" Edition 2 Prentice Hall, 2006
CSA Ch 01
CSA Computers Fetch-execute cycle Hardware CPU Arithmetic Logic Unit Control Unit RISC features ARM processor Pentium Itanium Input-output Parallel communication Serial communication Networking Local Area Networks Ethernet USB Wide Area Networks Other Networks Point to point Visual output Memor y Memor y hierarchy Cache and main memory Disk ling Parallel processing Software Operating systems Unix MS Windows Tools Compilers and assemblers Subroutines and stacks WIMPs Users viewpoints Hardware engineer HLL programmer Systems administrator Systems programmer
CSA ch 01 - p 1
CSA ch 01 - p 2
Computer Architecture?
h/w
s/w
User code
Software
Operating Systems Procedures
Hardware
CSA ch 01 - p 3
108 Intel PII NEC 64Mb DRAM 7 10 Siemens 16Mb DRAM 1 Mb DRAM 106 Motorola 68000 256kbb DRAM 105 Intel 8086 Number of 4 64kb DRAM 10 transistors 3 1103 DRAM 10 Intel 4004 102 10 1 1970 1975 1980
Design year
3m
1985
1990
1995
2000
10
0.1
CSA ch 01 - p 4
TIC
Control Computer
Monitoring terminal
Windows le browser
CSA ch 01 - p 5
% cat .cshrc umask 077 limit core 0 setenv TERM vt100 setenv PRINTER lw set prompt = "hostname > " set history = 25 biff y mesg n alias tt99 setenv DISPLAY TT99:0 set path = ( . /usr/ucb /usr/bin/X11 /bin /usr/bin /usr/local set path = ($path /etc /usr/etc /usr/lang /usr/local $home/bin)
CSA ch 01 - p 6
Dialup modem
Domestic PC
ISP
Ofce Network
The Internet
CSA ch 01 - p 7
Hub
Ether Switch
ATM Switch
DB server
100Mbps Ethernet
Ether Switch ATM Switch
Internet Gateway
Sun
University LAN
8 bytes Preamble
6 bytes
Destination Address
6 bytes
Source Address
Patterson & Hennessy, "Computer Organization & Design: The Hardware/Software Inter Morgan Kaufmann
CSA ch 01 - p 8
CSA Ch 02
CSA Computers Fetch-execute cycle Hardware CPU Arithmetic Logic Unit Control Unit RISC features ARM processor Pentium Itanium Input-output Parallel communication Serial communication Networking Local Area Networks Ethernet USB Wide Area Networks Other Networks Point to point Visual output Memor y Memor y hierarchy Cache and main memory Disk ling Parallel processing Software Operating systems Unix MS Windows Tools Compilers and assemblers Subroutines and stacks WIMPs Users viewpoints Hardware engineer HLL programmer Systems administrator Systems programmer
CSA ch 02 - p 9
instructions
Program Memory
CSA ch 02 - p 10
from HLL:
i = j + k;
to assembler mnemonics: mov EAX,[12011234] add EAX,[12011238] mov [1201123C],EAX to machine binary: 0010 0000 0011 1001 0001 0010 0000 0001 0001 0010 0011 0100 1101 0000 1011 1001 0001 0010 0000 0001 0001 0010 0011 1000 0010 0011 1100 0000 0001 0010 0000 0001 0001 0010 0011 1100
Semantic Gap
1. Data Transfer and Manipulation 2. Input / Output 3. Transfer of Program Control 4. Machine Control
CSA ch 02 - p 11
Edit
HLL source le
Compile
Executable le
Link
Errors
Load RUN
Macros
Compile
CSA ch 02 - p 12
Edit
CSA ch 02 - p 13
32
16
weighting
1 1 1 1 0 1 0 1 1 1 0 0 1
4096 + 2048 + 1024 + 512 + 128 + 32 + 16 + 8 + 1 = 7865
weighting
1 1 1 1 1 1 0 1 -------2 ) 2 3 9 7 1 1 9 8 5 9 9 2 9 9 1 4 9 7 4 3 7 1 8 9 4 2 1 0
CSA ch 02 - p 14
\ b i t s 765 | 000 001 010 011 100 101 110 111 \ | bi ts\ dec | 0 16 32 48 64 80 96 112 4321 \ hex | 0 10 20 30 40 50 60 70 --------------|--------------------------------------------0000 0 0 | NUL DLE SP 0 @ P p 0001 1 1 | SOH DC1 ! 1 A Q a q 0010 2 2 | STX DC2 " 2 B R b r 0011 3 3 | ETX DC3 # 3 C S c s 0100 4 4 | EOT DC4 $ 4 D T d t 0101 5 5 | ENQ NAK % 5 E U e u 0110 6 6 | ACK SYN & 6 F V f v 0111 7 7 | BEL ETB 7 G W g w 1000 8 8 | BS CAN ( 8 H X h x 1001 9 9 | T AB EM ) 9 I Y i y 1010 10 A | LF SUB * : J Z j z 1011 11 B | VT ESC + ; K [ k { 1100 12 C | FF FS , < L \ l | 1101 13 D | CR GS = M ] m } 1110 14 E | SO HO E . M > N n 1111 15 F | SI NL / ? O _ o DEL NUL SOH STX ETX EOT ENQ ACK BEL BS HT LF VT FF CR SO SI SP Null DLE Start of Heading DC1 Start of Text DC2 End of Text DC3 End of transmission DC4 Enquiry NAK Acknowledge SYN Bell ETB Back Space CAN Horizontal Tab EM Line Feed SUB Ver tical Tab ESC Form Feed FS Carriage Return GS Shift Out RS Shift In US Space DEL Data Link Escape Device Control 1 Device Control 2 Device Control 3 Device Control 4 Negative Acknowledge Synchronization character End of Transmitted Block Cancel End of Medium Substitute Escape File Separator Group Separator Record Separator Unit Separator Delete
http://www.unicode.org
CSA ch 02 - p 15
Data types
Operating Systems
1. Command line interpreter (CLI), shell script or desktop selections 2. Function calls from within user programs (API)
CSA ch 02 - p 16
rob[66] stty -icanon min 1 time 0 ; menu_prog Are you ready to proceed? [ Y / N ] :
CSA ch 02 - p 17
sh - the original Bourne shell, still popular with administrators for scripts csh - the C shell, more C-like syntax, and is better for interactive sessions tcsh - Tenex shell, perhaps the most used interactive shell, emacs keying ksh - Korn shell, normal issue with Hewlett Packard workstations bash - bourne-again-shell, a free-ware rework of several shells
CSA ch 02 - p 18
Screen Server
File Server
Xterm
atari@pong [50] xterm & atari@pong [51] rlogin milly -l rwilliam Last login: Tue Jul 1 09:22:21 sister rwilliam@milly >
CSA ch 02 - p 19
CSA Ch 03
CSA Computers Fetch-execute cycle Hardware CPU Arithmetic Logic Unit Control Unit RISC features ARM processor Pentium Itanium Input-output Parallel communication Serial communication Networking Local Area Networks Ethernet USB Wide Area Networks Other Networks Point to point Visual output Memor y Memor y hierarchy Cache and main memory Disk ling Parallel processing Software Operating systems Unix MS Windows Tools Compilers and assemblers Subroutines and stacks WIMPs Users viewpoints Hardware engineer HLL programmer Systems administrator Systems programmer
CSA ch 03 - p 20
Computer subsystems
I/O Units
Mouse socket Printer Connector Keyboard socket
CPU
Main Memory
USB sockets
MODEM socket
LAN socket
Sound
I/O
ATX Power Connector Hard Disk IDE Connectors Floppy disk Connector PCI Slots
ChipSet
VGA
AGP Slot
ChipSet
Socket 462
Crystal
Fig 3.2 PC ATX Motherboard, showing the locations of the CPU, memor y and I/O card sockets
Motherboard from a PC
CSA ch 03 - p 21
System Clock
Main Memory
I/O Subsystem
Bus
CPU
ALU
Control Unit
CSA ch 03 - p 22
ns
s 1 1 000 000
light 300 m/s tv line scan 60 s interrupt 2-20 s engine spark 10 s
1 1 000 human reaction 300 ms tv frame 20 ms hard disk access 10 ms car engine (3000 rpm) 20 ms
ms
Comparative speeds
CSA ch 03 - p 23
CPU
AX IP IR
System Clock
System Bus
MAR
10111000 00000000 00000001
CPU
IR
Instruction Address
Instruction Code
Address bus
Data bus
MAR
10111000 00000000 00000001
MAR
10111000 00000000 00000001
Main Memory
Main Memory
CSA ch 03 - p 24
CPU
AX IP IR AX
CPU
IR IP ++
Data Address
MAR
10111000 00000000 00000001
MAR
10111000 00000000 00000001
Main Memory
Main Memory
CSA ch 03 - p 25
Data bus - typically 32 bits wide, but will be increased to 64 bits, Address bus - 32 bits wide, but will require more very soon, Control bus - about 15 lines for starting and stopping activities.
A
System Clock Address R/W Addr1
Addr2
Addr3
Read
Read
Write
Data
Instr Fetch 10 ns
Result
CSA ch 03 - p 26
Addr2
Addr3
A
valid Fetch
valid
valid
Read
Write
Data
Instr
Data
Result
DTA
ok
ok 10 ns
ok time-base
Read instruction
Decode instruction
Read operand
Execute op
Write result
CSA ch 03 - p 27
1011011
Robert
ideal pulse
real pulse
CSA ch 03 - p 28
IP
Execution unit
Prefetching instructions
fetch 1 execute 1 fetch 2 execute 2 fetch 3 execute 3 fetch 4 execute 4
Winning margin
fetch 1
fetch 2
fetch 3
fetch 4
fetch 5
fetch 6
fetch 7
fetch 8 execute 5
fetch 9 execute 6
execute 1
execute 2
execute 3
execute 4
Time
Top
16 MByte
memor y length
Bottom
memor y width
CSA ch 03 - p 29
16 bit addresses can access 216, 20 bit addresses can access 220, 24 bit addresses can access 224, 32 bit addresses can access 232, 64 bit addresses can access 264,
65536, 64K locations 1048576, 1M locations 16777216, 16M locations 4294967296, 4G locations 4398046511104, 4E locations
dec 0 1 2 3 4 5 6 7 8 9 10 11 12 13 bin 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1 hex 0 1 2 3 4 5 6 7 8 9 A B C D
CSA ch 03 - p 30
0102 0304 0506 0708 090A FBFC FDFE FF00 0001 0002 0003 0004 0005 00FE 00FF 0100 0101 FFFC FFFD FFFE FFFF 0000 0001 0000 0002 0000 0003 0000 0004 0000 0005 0000 00FE 0000 00FF 0000 0100 0000 0FFF 0000 1000 0000 1001 FFFF FFFF 0000 0A00 0000 0000 0020 0000 0000 0000 0000 000F E0C0
b4[0]
Intel Pentium
Compare these
CSA ch 03 - p 31
Data Bus
R/W
Address bus
Address Decoder
Chip Select
Data Bus
R/W
Address bus
Address Decoder
Chip Select
CSA ch 03 - p 32
CSA Ch 04
CSA Computers Fetch-execute cycle Hardware CPU Arithmetic Logic Unit Control Unit RISC features ARM processor Pentium Itanium Input-output Parallel communication Serial communication Networking Local Area Networks Ethernet USB Wide Area Networks Other Networks Point to point Visual output Memor y Memor y hierarchy Cache and main memory Disk ling Parallel processing Software Operating systems Unix MS Windows Tools Compilers and assemblers Subroutines and stacks WIMPs Users viewpoints Hardware engineer HLL programmer Systems administrator Systems programmer
CSA ch 04 - p 33
7 0v
Inputs A B A OR B 00 0 01 1 10 1 11 1
Inputs A B A XOR B 00 0 01 1 10 1 11 0
Input A NOT A 0 1 1 0
OR
XOR
NOT
Detect: 111
Detect: 101
Detect: 010
Data Out
DX d0 d1
Out 0 d
Out a b c d
Control Y lines Z
O = (A AND Z ) OR (B AND Y ) OR (C AND X ) OR (D AND W )
CSA ch 04 - p 35
A2
b Data c Output
A3
A4
a b c d A B C D
Output
CSA ch 04 - p 36
inputs 1234 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111
O 0 0 1 0 0 1 0 0 0 0 1 0 1 1 0 0 i
1 2 3 4
O1
O1 = (i 3 i 2 i 1) + (i 4 i 3 i 2) + (i 4 i 3 i 2 i 1)
CSA ch 04 - p 37
i1
i2
i3
O1 O2 O3 O4 O5 O6 O7 O
8
CSA ch 04 - p 38
Level Crossing Inputs XY 00 01 10 11 Lights RAG 100 110 001 010 Inputs XYZ
N W E W S E
Cross Roads Lights RAG rag W-E N-S 100 100 110 100 001 100 010 100 100 100 100 110 100 001 100 010
Y R A G
Z R A G r a
N-S W-E
R=X A =Y G = X AND Y
CSA ch 04 - p 39
Outputs Y
01234567 11111111 11111111 01111111 10111111 11011111 11101111 11110111 11111011 11111101 11111110 A B C 3 to 8 line decoder Y0 Y1 Y2 Y3 Y4 Y5 Y6 Y7
G1 G2 G3
Y0 Y1 Y2 Y3 Y4
A B C
Y5 Y6 Y7
3 to 8 line decoder
CSA ch 04 - p 40
Inputs WXYZ 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001
LEDs abcdefg 1111110 0110000 1101101 1111001 0110011 1011011 0011111 1110000 1111111 1111011
a f b
a = (W AND X AND Y AND Z ) OR (W AND X AND Y AND Z ) OR (W AND X AND Y AND Z ) b = (W AND X AND Y AND Z ) OR (W AND X AND Y AND Z ) c = W AND X AND Y AND Z d = (W AND X AND Y AND Z ) OR (W AND X AND Y AND Z ) OR (W AND X AND Y AND Z ) e = (W AND X AND Y AND Z ) OR (W AND X AND Y AND Z ) OR (W AND X AND Y AND Z ) OR (W AND X AND Y AND Z ) f = (W AND X AND Y AND Z ) OR (W AND X AND Y AND Z ) OR (W AND X AND Y AND Z ) OR (W AND X AND Y AND Z ) g = (W AND X AND Y AND Z ) OR (W AND X AND Y AND Z ) OR (W AND X AND Y AND Z ) Z Y X W
CSA ch 04 - p 41
DRAIN
HEAT
RINSE DRAIN
WASH
1 rev per
CSA ch 04 - p 42
Control Lines 0 1 0 1 0
0.55 mHz
1 0 1 000 READY 001 010 011 100 101 110 111 FILL HEAT WASH DRAIN RINSE DRAIN SPIN
0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 1 1 0 0 1 0 0 0 0 0 1 0 0 1 0 1
On
IR
Control Store 111 00101 110 00001 101 10010 100 00001 011 00010 Program Counter 3 bit code from micro-switches 010 01000 001 10000 000 00000
Valve Heat Open On F S Pump On Motor
Control Lines
Control 111 110 101 100 011 010 001 Store 00101 00001 10010 00001 00010 01000 10000 00000
JMP
ag
addr select 000 00 000 000 000 000 000 000 000 00 00 00 00 00 00 00
Clock Reset
Counter
000
decoder
JMP addr
JMP load temperature water level high water level low
CSA ch 04 - p 44
Pre-Decode
System Clock
reset
CSA ch 04 - p 45
Condn Flags
Microaddr Reg
reset
Micro IR
CSA ch 04 - p 46
CSA Ch 05
CSA Computers Fetch-execute cycle Hardware CPU Arithmetic Logic Unit Control Unit RISC features ARM processor Pentium Itanium Input-output Parallel communication Serial communication Networking Local Area Networks Ethernet USB Wide Area Networks Other Networks Point to point Visual output Memor y Memor y hierarchy Cache and main memory Disk ling Parallel processing Software Operating systems Unix MS Windows Tools Compilers and assemblers Subroutines and stacks WIMPs Users viewpoints Hardware engineer HLL programmer Systems administrator Systems programmer
CSA ch 05 - p 47
(X OR Y ) (X AND Y )
De Morgans equivalences
X XY 00 01 10 11 ADD CS 00 01 01 10 X Y Carr y Y Carr y Sum
Sum
CSA ch 05 - p 48
Y Carr y
Sum
Y Carr y
Sum
CS 00 01 01 10 01 10 10 11
X Y Z
Sum
CSA ch 05 - p 49
A
3 2 1 0 3 2
B
1 0
Cin Add0
Add1
Add2
C=A+B
Cout
Add3 S3 S2 S1 S0
CSA ch 05 - p 50
0111 0110 0101 0100 0011 0010 0001 0000 1111 1110 1101 1100 1011 1010 1001 1000
31 0
+7 +6 +5 +4 +3 +2 +1 0 -1 -2 -3 -4 -5 -6 -7 -8
31
positive
negative
0
To form a twos compliment negative: Take the positive number, invert all the bits, add 1.
B 1 - subtract
31 0
0 - add
IR
control lines CU
CSA ch 05 - p 51
Input, x x7 . . . . . x0 Diagonal closed switch pattern controlled by the CU No shift in this position x7 . . . . . . . x0 Output Input, x x7 . . . . . x0 Input, x x7 . . . . . . x0 Input, x x7 . . . . . x0
Output, x <<= 1
x6 . . . . . x0 0
Output, x <<= 2
x5 . . . x0 0 0
Output, x >>= 3
0 0 0 x7 . . x3
Input, x x7 . . . . . x0
Input, x x7 . . . . . x0
CSA ch 05 - p 52
10101101 00111001x -------------------10101101 00000000 00000000 10101101 10101101 10101101 00000000 00000000 -----------------------------------1001101000001
/* function to multiply two 16 bit positive integers returning a 32 bit result, using only integer addition and shift operators */ int multiply(int a, int c) { int i; c = c << 16; for (i=0; i<16; i++) { if (a & 1) { a += c }; a = a >>1; } return a;
CSA ch 05 - p 53
Test LS bit A
1
00101101 00111001 00010110 10011100 00101101
+
00101101
shift right
shift right
shift right
00110010 10100111
if (A & 1)
A += C 1
00101101
A = A >>1
+ 1
00101101
shift right
01010000 00101001
+ 1
00101101
shift right
shift right
Result
00010100 00001010 00101101 Test LS bit 00010100 00001010 00101101 00001010 00000101 00101101
shift right
CSA ch 05 - p 54
D7 D6 D5 D4 D3 D2 D1 D0
Data Registers
Register select
ALU
CPU Flags
CSA ch 05 - p 55
Output Values, F
S3 - S0
M=0 Arithmetic Cin = 1 F =A+1 F = (A OR B) + 1 F = (A OR A) + 1 F =0 F = A + (B AND A) + 1 F = (A OR B) + (B AND A) + 1 F =AB F = (B + A) F = A + (A AND B) + 1 F =A+B +1 F = (B OR A) + (A AND B) + 1 F = (A AND B) F = (A << 1) + 1 F = (A OR B) + A + 1 F = (B OR A) + A + 1 F =A
0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111
F =A F = A OR B F = B OR A F = 1 F = A + (B AND A) F = (A OR B) + (B AND A) F =AB 1 F = B AND A 1 F = A + (B AND B) F =A+B F = (B OR A) + (A AND B) F = (A AND B) 1 F = A << 1 F = (A OR B) + A F = A + (B OR A) + A F =A1
Data in
A0 A1 A2 A3 B0 B1 B2 B3 Cin S3 S2 S1 S0 M
Data out
F0 F1 F2 F3 Cout
74xx181
A=B
Control
CSA ch 05 - p 56
float net_cost, tot_cost, price; float vat = 0.175; int items; net_cost = price * items; tot_cost = net_cost + net_cost * vat;
CSA ch 05 - p 57
Exponent Mantissa
10011010010.1001
unnormalized
1.00110100101001 x 21010
normalized format
-3.3125 0.065625
-11.0101 0.00011
S 0 1 0
CSA ch 05 - p 58
/* floatit.c - to write a real number into a file for viewing */ #include <stdio.h> int main( ) { FILE *fp; float f = 231.125; if (fp = fopen ("float_data", "w")) { fwrite(&f, 4, 1, fp); }; return 0; }
rob@olveston [78] cc oatit.c -o oatit rob@olveston [79] oatit rob@olveston [80] od -x oat_data 0000000 0000004 rob@olveston [129] od -f oat_data 0000000 2.3112500e+02 0000004 rob@olveston [130] 4367 2000
CSA ch 05 - p 59
The hex value 43 67 20 00 is the 32 bit oating-point number : 0 100 0011 0110 0111 0010 0000 0000 0000 || sign bit 8 bit exponent in 127 offset format The range and precision of the various oating-point formats are as follows: | 23 bits of the 24bit mantissa
CSA ch 05 - p 60
CSA Ch 06
CSA Computers Fetch-execute cycle Hardware CPU Arithmetic Logic Unit Control Unit RISC features ARM processor Pentium Itanium Input-output Parallel communication Serial communication Networking Local Area Networks Ethernet USB Wide Area Networks Other Networks Point to point Visual output Memor y Memor y hierarchy Cache and main memory Disk ling Parallel processing Software Operating systems Unix MS Windows Tools Compilers and assemblers Subroutines and stacks WIMPs Users viewpoints Hardware engineer HLL programmer Systems administrator Systems programmer
CSA ch 06 - p 61
_ Q
S S R Q _ Q R S-R Latch
_ Q Q
CSA ch 06 - p 62
5v
0V Cat ap swipe switch 10 kOhm
5v
200 Ohm
LED
OUT IN
MT46V128M8TG-6T
M5L27512K-2
A15 A12 A7 A6 A5 A4 A3 A2 A1 A0 D0 D1 D2 Gnd D7 0 D6 3v D5 0 D4 3v 0 DQ Clk Cke A11 A9 A8 A7 A6 A5 A4 0
Micron, MT46V128M8TG-6T 128 Mbyte Dynamic RAM 167 MHz operation, 6 ns access
CSA ch 06 - p 63
Clock, f
FlipFlop
f/2
FlipFlop
f/4
FlipFlop
f/8
FlipFlop
CSA ch 06 - p 64
Row decoder
Address
31
Address
15 015 0
Row number
RAS cycle
Column number
CAS cycle
Row Access RAS Column Access CAS Row Addr Data 60 ns access time
C0 D0
C1 D1
C2 D2
C3 D3
CSA ch 06 - p 65
CSA ch 06 - p 66
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
Vss DQO DQ1 D02 DQ3 Vcc DQ4 DQ5 DQ6 DQ7 DQ8 Vss DQ9 DQ10 DQ11 D012 DQ13 VCC DQ14 DQ15 NC NC Vss NC NC Vcc WE DQM0 DQM1 CSO NC Vss AO A2 A4 A6 A8 A10/AP BA1 Vcc Vcc CLKO
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
Vss NC CS2 DQM2 DQM3 NC Vcc NC NC NC NC Vss DQ16 DQ17 DQ18 DQ19 Vcc DQ20 NC NC NC Vss DQ21 DQ22 D023 Vss DQ24 DQ25 DQ26 DQ27 Vcc DQ28 DQ29 DQ30 DQ31 Vss CLK2 NC NC SDA SCL Vcc
85 Vss 86 DQ32 87 DQ33 88 DQ34 89 DQ35 90 Vcc 91 DQ36 92 DQ37 93 DQ38 94 DQ39 95 DQ40 96 Vss 97 DQ41 98 DQ42 99 DQ43 100 DQ44 101 DQ45 102 Vcc 103 DQ46 104 DQ47 105 NC 106 NC 107 VSS 108 NC 109 NC 110 VCC 111CAS 112 DQM4 113 DQM5 114 NC 115RAS 116 VSS 117 Al 118 A3 119 A5 120 A7 121 A9 122 BAO 123 All 124 VCC 125 CLK1 126 NC
127 Vss 128 CKEO 129 NC 130 DQM6 131 DQM7 132 NC 133 Vcc 134 NC 135 NC 136 NC 137 NC 138 Vss 139 DQ48 140 DQ49 141 DQ50 142 DQ51 143 Vcc 144 DQ52 145 NC 146 NC 147 NC 148 Vss 149 DQ53 150 D054 151 DQ55 152 Vss 153 DQ56 154 DQ57 155 DQ58 156 D059 157 Vcc 158 DQ60 159 DQ61 160 DQ62 161 DQ63 162 Vss 163 CLK3 164 NC 165 SAO 166 SA1 167 SA2 168 Vcc
CSA ch 06 - p 67
CPU A0-31
A0-31 4 GB SRAM
Device
Size
Pins
Address range
20 24 24 24 24
0000 0000 xxxx ++++ ++++ ++++ ++++ ++++ 0000 0001 ++++ ++++ ++++ ++++ ++++ ++++ 0000 0010 ++++ ++++ ++++ ++++ ++++ ++++ 0000 0011 ++++ ++++ ++++ ++++ ++++ ++++ 0000 0100 ++++ ++++ ++++ ++++ ++++ ++++
0000 0000 - 000F FFFF 0100 0000 - 01FF FFFF 0200 0000 - 02FF FFFF 0300 0000 - 03FF FFFF 0400 0000 - 04FF FFFF
address line used directly for internal selection line ignored, indicates partial (degenerate) addressimg must be 0 for chip selection must be 1 for chip selection
RAM4 16MB
c/s
RAM3 16MB
c/s
RAM2 16MB
c/s
RAM1 16MB
c/s
PROM1 1MB
c/s
CSA ch 06 - p 68
RAM4 16MB RAM3 16MB RAM2 16MB RAM1 16MB PROM1 1MB
0000 0100 1111 1111 1111 1111 1111 1111 0000 0100 0000 0000 0000 0000 0000 0000 0000 0011 1111 1111 1111 1111 1111 1111 0000 0011 0000 0000 0000 0000 0000 0000 0000 0010 1111 1111 1111 1111 1111 1111 0000 0010 0000 0000 0000 0000 0000 0000 0000 0001 1111 1111 1111 1111 1111 1111 0000 0001 0000 0000 0000 0000 0000 0000 0000 0000 0000 1111 1111 1111 1111 1111 0000 0000 0000 0000 0000 0000 0000 0000 Binar y
04 FF FF FF 04 00 00 00 03 FF FF FF 03 00 00 00 02 FF FF FF 02 00 00 00 01 FF FF FF 01 00 00 00 00 0F FF FF 00 00 00 00 Hexadecimal
CSA ch 06 - p 69
I/O Dev3
RAM2
80 0000 80 002F
RAM1
ROM Motherboard
10 0000 2F FFFF
00 0000 01 FFFF
MEMORY MAP
CSA ch 06 - p 70
I/O Dev1
I/O Dev2
I/O Dev3
RAM2
RAM1
ROM
00 0000 01 FFFF
MEMORY MAP
CSA ch 06 - p 71
CSA Ch 07
CSA Computers Fetch-execute cycle Hardware CPU Arithmetic Logic Unit Control Unit RISC features ARM processor Pentium Itanium Input-output Parallel communication Serial communication Networking Local Area Networks Ethernet USB Wide Area Networks Other Networks Point to point Visual output Memor y Memor y hierarchy Cache and main memory Disk ling Parallel processing Software Operating systems Unix MS Windows Tools Compilers and assemblers Subroutines and stacks WIMPs Users viewpoints Hardware engineer HLL programmer Systems administrator Systems programmer
CSA ch 07 - p 72
FG13054 USA HF
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z AA BB CC DD EE FF GG HH II JJ KK
CSA ch 07 - p 73
Bus Interface Level I D cache TLB 8kBytes MMU Addr Trans Level I Code cache TLB 8kbytes MMU Addr Trans BTB BPL
Control Unit
Microcode ROM
CSA ch 07 - p 74
Name
P24T P54C P55C P54CTB Tillomook P6 Klamath Deschutes Covington Mendocino Dixon Katmai Willamette Tanner Cascades Merced McKinley Foster Madison
Processor
486 Pentium OverDrive, 63 or 83MHz, Socket 3 Clossic Pentium 75-200MHz, Socket 517, 3.3v Pentium NWX 166-266MHz, Socket 7, 2.8v Pentium MMX OverDrive 125+, Socket 517, 3.3v Mobile Pentium MMX 0.25 m, 166-266MHz, 1.8v Pentium Pro, Socket 8 Original Pentium II, 0.35 m, Slot-I Pentium 11, 0.25 m, Slot 1, 256 Kbyte LII cache Celeron PII, Slot-I, with no L2 cache Celeron, PII with 28 Kbyte L2 cache on die Mobile Pentium IIPE, 256 Kbyte on-die L2 cache Pentium III, PII with SSE instructions Pentium III, on-die L2 Pentium 111 Xeon PIll, 0.18 m, on-die L2 P7, First IA-64 processor, on-die 12, 0.18 m 1 GHz, Improved Merced, IA-64, 0.18 m, copper interconnects Improved PIII, IA-32 Improved McKinley, IA-64, 0.13 m
CSA ch 07 - p 75
31
15
AH BH CH DH SI DI BP IP SP
AL BL CL DL
EAX EBX ECX EDX ESI EDI EBP EIP ESP EFlags Base Address Limit CSDCR SSDCR DSDCR ESDCR FSDCR GSDCR
0
Flags CS SS DS ES FS GS
15 0 31
Access
63
52 51 019
20 19
TSS base address LDT base address IDT base address GDT base address
CR1 Page Fault Service Routine CR2 Page Dir Base Reg CR3
31 12 0
CSA ch 07 - p 76
; load constant value 4660 into 32 bit accumulator ; add 1 to accumulator value ; compare the ASCII Q with the LS byte value in EAX ; store accumulator value to memory variable "maxval" ; divide accumulator by value in 16 bit D register
EBX: Base registers hold addresses pointing to data structures, such as arrays in memory. LEA EBX,marks ; initialize EBX with address of the variable "marks" MOV AL,[EBX] ; get byte value into AL using EBX as a memory pointer ADD EAX,EBX ; add 32 bits from EBX into accumulator MOV EAX,table[BX] ; take 32 bit value from the "table" array using the value in BX as the array index ECX: The Count register has a special role as a counter in loops or bit shifting operations. MOV ECX,100 ..... for1: ..... LOOP for1 ; initialize ECX as the FOR loop index ;symbolic address label ; decrement ECX, test for zero, JMP back if non-zero
EDX: The Data register can be involved during input/output data transfers or when executing integer multiplication and division. Otherwise it is generally available for holding variables. IN AL,DX MUL DX ; input byte value from port, with 16 bit port address in DX ; multiply A by value in D
ESI: Source Index register is a pointer for string or array operations within the Data Segment. LEA ESI,dtable ; initialize SI with memory address of variable "dtable" MOV AX,[EBX+ESI] ; get word using Base address and Index register EDI: Destination Index register is a pointer for string or array operations within the Data Segment. MOV [EDI],[ESI]
CSA Rob Williams Pearson Education (c) 2006
EBP: The Stack Base Pointer register is used as the stack frame pointer to support HLL procedure operations. It is taken as an offset within the Stack Segment. ENTER 16
; saves EBP on stack, copies ESP into EBP, and subtracts 16 from ESP
EIP: The Instruction Pointer (Program Counter) holds the offset address of the next instruction within the current Code Segment. JMP errors ; forces a new address into EIP
ESP: The Stack Pointer holds the offset address of the next item available on the stack within the current Stack Segment. CALL subdo PUSH EAX ; call a subroutine (subdo), storing return address on stack ; save 32bit value in accumulator on stack
EFLAG: Flag Register contains CPU status ags, implicated in all conditional instructions. JGE back1 LOOP backagin ; tests sign ag for conditional jump ; tests zero ag for loop exit condition
CS - GS: These 16 bit Segment Selector registers were originally introduced to expand the addressing range of the i8086 processor while maintaining a 16 bit IP. The Segment Register is added to the EIP register to form a 32 bit address. CSDCR - GSDCR: 64 bit Code Segment Descriptor Cache Register holds the current Code Segment Descriptor, which includes: Base address, size Limit and Access permissions. The Segment Descriptor is obtained from either the Global or Local Descriptor Tables. TR: The Task Register holds the 16 bit segment selector, the 32 bit base address, the 16 bit size limit and the descriptor attributes for the current task. It references a TSS descriptor in the Global Descriptor Table (GDT). When a task switch occurs, the Task Register is automatically reloaded. IDTR: The 48bit Interrupt Descriptor Table Register holds the base address and size limit of the current Interrupt Vector Table (IVT). GDTR: The Global Descriptor Table Register holds the segment descriptors which point to universally available segments and to the tables holding the Local Descriptors. LDTR: Each task can use a Local Descriptor Table in addition to the Global CSA Rob Williams CSA ch 07 - p 78
Pearson Education (c) 2006
Descriptor Table. This register indicates which entry in the Local Segment Descriptor Table to use. CR3: This Control Register points to the directory table for the Paging Unit. CR2: This Control Register points to the routine which handles page faults which occur when the CPU attempts to access an item at an address which is located on a non-resident memory page. The service routine will instigate the disk operation to bring the page back into main memory from disk.
CSA ch 07 - p 79
15
Flags B D H SP PC
A C E L
INC/DEC increment or decrement ADD SUB CMP TEST JZ LOOP ENTER LEAVE JMP INT CSA Rob Williams Pearson Education (c) 2006 arithmetic integer addition arithmetic subtraction for 2s complement integers compare 2 values, a subtract with no result, only setting ags bit testing conditional jump implements a FOR loop by decrementing the CX register sets up a subroutine (procedure) stack frame cleans up a stack frame on exit from a subroutine a dreaded jump instruction software interrupt to get into an operating system routine
CSA ch 07 - p 80
1. the action or operation of the instruction, 2. the "victims" or operands involved, 3. where the result is to go.
0 - 3 bytes
1 - 2 bytes
0 - 1 bytes
0 - 1 bytes
0, 1, 2 or 8 bytes
Prex
Opcode D W
S I B
EAX ECX EDX EBX ESP 2EH 3EH 36H 26H 64H 65H 66H B8H F0H F3H CSEG DSEG SSEG ESEG FSEG GSEG 32bit mode 16bit mode Lock REP W=0 W=1 0 REG is source 1 REG is destination 000 001 010 011 100 101 110 111 AL CL DL BL AH CH DH BH AX CX DX BX SP BP SI DI R/M 000 001 010 011 100 101 110 111 MOD=00 (BX+SI) (BX+DI) (BP+SI) (BP+DI) (SI) (DI) direct (BX) MOD=01 [ESI] [EDI] 00 01 10 11 Memor y Memory+d8 Mem+d32/d16 Register [EAX] 00 [ECX] 08 [EDX] 10 [EBX] 18 20 [EBP] 28 30 38 01 09 11 19 21 29 31 39 02 0A 12 1A 22 2A 32 3A 03 0B 13 1B 23 2B 33 3B 04 0C 14 1C 24 2C 34 3C 05 0D 15 1D 25 2D 35 3D
ESI EDI 06 0E 16 1E 26 2E 36 3E 07 0F 17 1F 27 2F 37 3F
MOD=10
(BX+SI+d8) (BX+SI+d16) (BX+DI+d8) (BX+DI+d16) (BP+SI+d8) (BP+SI+d16) (BP+DI+d8) (BP+DI+d16) (SI+d8) (DI+d8) (BP+d8) (BX+d8) (SI+d16) (DI+d16) (BP+d16) (BX+d16)
CSA ch 07 - p 81
03 C3 ADD AX,BX _____________________________________ 0 0 0 0 0 0 1 1 1 1 0 0 0 0 1 1 ------------ | | --- ----- ----ADD op | W rd | o AX BX Des t | | | Reg -Reg | | mode | | des t i na t i on sou r ce
66 B8 00 00 00 00 00 00 12 00 MOV EAX,12H ____________________________________________________________________________ 0 1 1 0 0 1 1 0 1 0 1 1 1 0 0 0 0000 0000 0000 0000 0000 0000 0001 0010 --------------- ------- | ------------------------------------------32b i t p r ex M V op W r d AX O o im ed i a t e da t a m
ID VIP VI AC VM R
N IOP O
identication ag for CPUID availability vir tual interrupt pending vir tual interrupt active alignment check vir tual 8086 mode active resume task after breakpoint interrupt nested task i/o privilege level arithmetic overow error direction of accessing string arrays external interrupt enable trap, single step debugging, generates an INT #1 after each instruction sign, MS bit value zero, result being zero auxiliar y carr y, used by BCD arithmetic on 4 LS bits parity, operand status carr y, indicates an arithmetic carry or borrow result
CSA ch 07 - p 82
CMP AL,q
. . . . . . . . .
JZ end
Data Register Direct
JZ tests the Z ag
CSA ch 07 - p 83
Control Instructions
Branch Detector
Decoder logic
Data
Integer ALU
Fetch
CSA ch 07 - p 84
LI
CSA ch 07 - p 85
Debugger tool-bar
Output Window Editor Window with source code breakpoint mark and IP index mark CPU Registers Memor y Window with hex dump of memory
CSA ch 07 - p 86
/* demo of assembler within a C prog*/ #include <stdio.h> #include <stdlib.h> int main (void) { char format[] = "Hello World\n" __asm { mov ecx,10 Lj: push ecx lea eax,format push eax call printf add esp,4 pop ecx loop Lj } return 0; }
//declare variables in C
;switch to inline assembler ;initialize loop counter ;loop count index saved on stack ;address of string, stack parameter ;use library code subroutine ;clean 4 byte parameter off stack ;restore loop counter ready for test ;dec ECX, jmp back IF NZ ;back to C
HELP go to next error run the program build executable code compile only set breakpoint single step (over funtions) single step into functions toggled windows backwards/forwards
CSA ch 07 - p 87
1. CPU registers 2. Program memor y with labels and disassembled mnemonics 3. Data memory with ASCII decode table 4. Output screen for your program under test 5. Stack, but only for the return addresses.
Debug
Restar t debugger Stop Disassembly Display Stack Display Memory Display Registers Display Variables Watch Quick Watch
debugger Break execution Show instruction Step into Step over Step out of Run to cursor
CSA ch 07 - p 88
open the Start Menu on the Taskbar. You can the nopen applications on the desktop, this switches between desktop, Taskbar and Start menu If you already have the Start menu, [Tab] switches between Applications. Alt [F4] terminate current application This can also terminate Windows if you are on the desktop! Alt [Tab] switch to next window Shift Alt [Tab]switch to preceding window [ESC] this sometimes cancels the previous action [F1] display the On-line Help for applicatioons Shift [F1] context sensitive help [F2] If an icon is highlighted you can change its name [F3] get Find
[ESC] [Tab]
CSA ch 07 - p 89
CSA Ch 8
CSA Computers Fetch-execute cycle Hardware CPU Arithmetic Logic Unit Control Unit RISC features ARM processor Pentium Itanium Input-output Parallel communication Serial communication Networking Local Area Networks Ethernet USB Wide Area Networks Other Networks Point to point Visual output Memor y Memor y hierarchy Cache and main memory Disk ling Parallel processing Software Operating systems Unix MS Windows Tools Compilers and assemblers Subroutines and stacks WIMPs Users viewpoints Hardware engineer HLL programmer Systems administrator Systems programmer
CSA ch 8 - p 90
8. CSA - Subroutines
. . . average(&maths); . . . . . .
Main Program
1 2
return 1 return 2
average( ) {
. . .
average(&english);
Subroutine
average(&english);
. . . average(&maths); . . . . . .
1 2
return 1 return 2
average( ) {
. . .
3
return 3 return 4
average(&taxes);
. . . average(&ages); . . . . . .
DLL Subroutine
Program A
Program B
call
average( ) {
Stack area
. . . . . .
ret addr
call
return
ret
EIP
}
Subroutine
CSA ch 8 - p 91
ESP EIP
EAX
CPU
System Bus
CSA ch 8 - p 92
#include <stdio.h> #define NCLASS 10 int maths_scores[NCLASS]; int tech_scores[NCLASS]; oat average(int x, int * y) { int i; oat av; for (i=0; i<x; i++) { av += *y++ ; } return av /= x; } void main( void) { int i; ..... printf("Average of maths = %3.1f\n", average( NCLASS, maths_scores)); ..... printf("Average of technology = %3.1f\n", average( NCLASS, tech_scores)); ...... }
PUSH EAX ;push 32bit word in A onto stack CALL printf ;do something POP EBX ;pop the 32bit word from stack
Stack operation
CSA ch 8 - p 93
;scrub a longword off the stack ;open up 256 bytes of space on stack
1. to save the return address during PROCEDURE calls 2. to pass parameters into PROCEDURES 3. to allocate Local Variable storage space (stack frame) 4. as temporary scratch-pad storage for register values
CSA ch 8 - p 94
CSA ch 8 - p 95
Stack growing
73 10 40 00 0A 00 00 00 30 5A 41 00
stack area
Stack Growing
CSA ch 8 - p 96
EBP stack frame 1 params 1 ESP ret add 1 EBP ESP params 1 ret add 1 EBP 1 loc vars params 1 ret add 1 EBP 1 loc vars params 2 EBP ESP ret add 2 EBP 2 loc vars ESP stack frame 2 EBP params 1 ret add 1 EBP 1 loc vars ESP params 1
FFFF FFFF
Stack grows
0000 0000 Main program sets up calls parameters and return address subr tn 1 installs local variables calls subr tn 2 returns subr tn 1 Main program returns
02 00 00 00 80 31 41 00 80 FF 12 00
space for av - current Head of Stack space for i Stack Growing old EBP value
CSA ch 8 - p 97
#include <stdio.h> char* getname(void) { char nstring[25]; printf("Please type your name: "); gets( nstring); putchar(\n); return nstring; //SERIOUS ERROR IN THIS PROGRAM } int main(void) { char* myname; myname = getname(); printf("%s\n", myname); return 0; }
mov eax,10;
. . . add EAX,3); . . . . . .
return
. . .
IRET
Main Program
Late binding
CSA Rob Williams Pearson Education (c) 2006
CSA ch 8 - p 98
CSA Ch 09
CSA Computers Fetch-execute cycle Hardware CPU Arithmetic Logic Unit Control Unit RISC features ARM processor Pentium Itanium Input-output Parallel communication Serial communication Networking Local Area Networks Ethernet USB Wide Area Networks Other Networks Point to point Visual output Memor y Memor y hierarchy Cache and main memory Disk ling Parallel processing Software Operating systems Unix MS Windows Tools Compilers and assemblers Subroutines and stacks WIMPs Users viewpoints Hardware engineer HLL programmer Systems administrator Systems programmer
CSA ch 09 - p 99
I/O subsystem
1. Dedicated and Periodic polling 2. Interrupt driven 3. Direct Memory Access (DMA)
CSA ch 09 - p 100
CSA ch 09 - p 101
GROUP A PORT C UPPER (4) 8-BIT INTERNAL DATA BUS GROUP B CONTROL GROUP B PORT C LOWER (4)
RD WR A1 A0 RESET
I/O PB7PB0
CS
FIGURE 1. 82C55A BLOCK DIAGRAM. DATA BUS BUFFER, READ/WRITE, GROUP A & B CONTROL LOGIC FUNCTIONS
(RESET) Reset. A high on this input initializes the control register to 9Bh and all ports (A, B, C) are set to the input mode. Bus hold devices internal to the 82C55A will hold the I/O port inputs to a logic 1 state with a maximum hold current of 400A. Group A and Group B Controls The functional conguration of each port is programmed by the systems software. In essence, the CPU outputs a control word to the 82C55A. The control word contains information such as mode, bit set, bit reset, etc., that initializes the functional conguration of the 82C55A. Each of the Control blocks (Group A and Group B) accepts commands from the Read/Write Control logic, receives control words from the internal data bus and issues the proper commands to its associated ports. Control Group A - Port A and Port C upper (C7 - C4) Control Group B - Port B and Port C lower (C3 - C0) The control word register can be both written and read as shown in the Basic Operation table. Figure 4 shows the control word format for both Read and Write operations. When the control word is read, bit D7 will always be a logic 1, as this implies control word mode information.
A1 0 0 1 1
A0 0 1 0 1
RD 0 0 0 0
WR 1 1 1 1
CS 0 0 0 0
Data Sheet (page 3) for a Harris 82C55A Parallel Por t I/O Chip
CSA ch 09 - p 102
Mode 0 - basic byte-wide input and output ports Mode 1 - bytes passed by strobed (asynchronous) handshake Mode 2 - tri-state bus action
D7 D6 D5 D4 D3 D2 D1 D0
Control Register
C0 - C3: 1 - input, 0 - output B0 - B7: 1 - input, 0 - output Mode: 0 - basic, 1 - strobed C4 - C7: 1 - input, 0 - output A0 - A7: 1 - input, 0 - output Mode: 00 - basic, 01 - strobed, 10 - bus 1 - set port modes
// Win-98. Initializes 8255 at 0x1f3: Port A IN; B OUT; C OUT outp((short)0x1F3, 0x90); // init 8255 cmnd reg
Initialization using C
CSA ch 09 - p 103
System Bus A21A23 A0-A19 D0-D7 A0-A1 status reg command reg data regs I/O Subsystem
PROM Memory
0
C/S RAM
I/O C/S
Memor y decoder
Size
1MB 2MB 2MB 2MB 4B
Address Pins
20 21 21 21 2
Address bus
000x ++++ ++++ ++++ ++++ ++++ 001+ ++++ ++++ ++++ ++++ ++++ 010+ ++++ ++++ ++++ ++++ ++++ 011+ ++++ ++++ ++++ ++++ ++++ 111x xxxx xxxx xxxx xxxx xx++ aliases
Address range
00 0000 - 0F FFFF 20 0000 - 3F FFFF 40 0000 - 5F FFFF 60 0000 - 7F FFFF E0 0000 - E0 0003 E0 0004 - E0 0007 E0 0008 - E0 000B E0 000C - E0 000F
. . .
CSA ch 09 - p 104
LOOP:
;read status port Polling Loop ;test device status ;if no data go back again ;get Rx data & clear RXRDY flag ;test for end marker ;jmp out if finished ;save character in data buffer ;back for more input ;character string input complete
RxRDY
DATIN: IN AX,RXDATA OR AL,AL JZ COMPLETE MOV [DI],AL INC DI JMP LOOP COMPLETE: ....
do { while (!(*(BYTE*)RXSTATUS & RXRDY)) { } ;/* wait for data */ } while (*pch++ = *(BYTE*)RXDATA) ; /* check for a NULL */
CSA ch 09 - p 105
System buses operate at 500 Mbyte/sec Blocks of characters can be moved at100 Mbyte/sec Ethernet transfers data at 10 Mbytes/sec Telephone call needs 8 Kbyte/sec Serial lines frequently run at 1 Kbyte/sec Epson printers operate at 100 byte/sec Keyboards send at 4 byte/sec
CSA ch 09 - p 106
/* io.h
/* address, offsets and setting for M68681 DUART */ #define DUART 0XFFFF80 /*base address*/ #define ACR 9 /*aux control reg */ #define CRA 5 /*command reg A */ #define MRA 1 /*mode reg A */ #define CSRA 3 /*clock select A */ #define SRA 3 /*status reg A */ #define RBA 7 /*rx reg A*/ #define TBA 7 /*tx reg A */ #define RXRDY 1 /*bit mask for rx ready bit */ #define TXRDY 4 /*bit mask for tx ready bit */ /*Settings for the Motorola M68230 Parallel Interface Timer These only deal with mode 0.0, and for ports B and C No details about the timer. */ /* PI/T offsets and adresses, PIT registers are all on odd addresses */ #define PIT 0Xffff40 /*address of PI/T */ #define BCR 0Xf /*offset for port B cntrl Reg*/ #define BDDR 7 /*offset for B data direction*/ #define BDR 0X13 /*offset port B data reg */ #define CDR 0X19 /*offset port C data reg */ /* Parallel port settings masks and modes */ #define MODE0 0X20 /* mode 0.0, 2X buff i/p, single buff o/p */ #define MODE01X 0X80 /* mode 0.1X, unlatch i/p, 1X buff o/p */ #define OUT 0XFF /* all bits output: 0 - i/p, 1 - o/p*/ #define STROBE_MINUS 0X28 /* strobe printer -ve */ #define STROBE_PLUS 0x20 /* strobe printer +ve */ #define PRINT_ST 1 /* paper out pin 00000001 */ #define PAPER_ST 2 /* paper out pin 00000010 */ #define SELECT_ST 4 /* selected pin 00000100 */
CSA ch 09 - p 107
for(i=0; i != 1000;i++) ;/* init delay*/ /* set up 68230 PIT for print out on port B */ void pinit() { char *p; p = ( char *) PIT; /* set to base address of PI/T */ *(p + BCR ) = MODE0; /* mode 0.0 */ *(p + BDDR ) = OUT; } /* get char from serial port A char get() { register char *p; returns character */
p = (char *)DUART; while ( !( *(p+SRA) & RXRDY )) { }; return *(p+RBA); } /* put character c to serial port A */ void put( char c) { register char *p; p = (char *)DUART; while ( !( *(p+SRA) & TXRDY )) { }; *(p+TBA) = c; }
/* block here */
/* block here */
/* put string to serial port A using put routine */ void puts(char* p) { while( *p ) put(*p++); put(\n); }
Continues
CSA ch 09 - p 108
/*put character to parallel port */ int print(int c) { register char * p ; p = ( char *) PIT; while ( *(p + CDR) & PRINT_ST ) { if ( !( *(p + CDR) & PAPER_ST) ) return (PAPER_OUT) ; if ( !( *(p + CDR) & SELECT_ST) ) return ( DE_SELECT); } *(p + BDR) = c; /*send data */ *(p + BCR) = STROBE_MINUS;/* strobe positive */ *(p + BCR) = STROBE_PLUS;/* strobe negative */ return OK ;
CSA ch 09 - p 109
Telephonic Interruptions
CPU
Interrupt Request
System Bus
Main Memory
I/O A
I/O B
I/O C
PIC CPU
Interrupt Request
System Bus
Main Memory
I/O A
I/O B
I/O C
CSA ch 09 - p 110
Int Function Number 77 Hard Disk2 76 Hard Disk1 75 8087 74 PS/2 Mouse 73 Soundcard 72 Network 71 Redirected 70 RTC ........... 18 17 16 15 14 13 12 11 10 0F 0E 0D 0C 0B 0A 09 08 07 06 05 04 03 02 01 00 BIOS/TOD BIOS/softboot BIOS/print BIOS/KBD BIOS/comms BIOS/disk BIOS/msize BIOS/check BIOS/Video LPT1: FDC SoundCard COM1: COM2: ---KBD: System Timer
Source IRQ15 IRQ14 IRQ13 IRQ12 IRQ11 IRQ10 IRQ2 IRQ8 INT INT INT INT INT INT INT INT INT IRQ7 IRQ6 IRQ5 IRQ4 IRQ3 IRQ2 IRQ1 IRQ0 PIC 1
IRQ0 IRQ1 IRQ3 IRQ4 IRQ5 IRQ6 IRQ7 IRQ8 IRQ9 IRQ10 IRQ11 IRQ12 IRQ13 IRQ14 IRQ15
to CPU interrupt
PIC 2
Screen dump to printer Numeric Overow Breakpoint NMI, Power fail Single Step Trace Integer Divide Error
CSA ch 09 - p 111
CSA ch 09 - p 112
IVT Memor y
1. I/O data transfer request 2. Software TRAP (SVC) 3. Machine Failure 4. Real-time Tick 5. Run-time Software Error 6. System Reset or Watchdog
CSA ch 09 - p 113
mouse activity
CSA ch 09 - p 114
ISR
msecs++ ? msecs=0 secs++ ? secs = 0 mins++ ? mins = 0 hrs++ ? hrs = 0
Display Routines
Display secs
Hours
Mins
Secs
CSA ch 09 - p 115
msecs=0 secs++ ? N
secs = 0 mins++ ? N
CSA ch 09 - p 116
Transmit Data Buffer putc( ) Tx Dev Driver Receive Data Buffer Rx Dev Driver Rx ISR Tx Interrupt request Tx ISR UART Tx data
User Application
getc( )
System Bus data I/O Subsystem Main Memory source destination count DMA Controller
CSA ch 09 - p 117
1 1 1 1 1 1 2 3 2 3 2 3
2 2 2
3 3 3
time
CSA ch 09 - p 118
please enter a single letter: A A please enter a single letter: please enter a single letter: B B please enter a single letter: please enter a single letter:
? ?
A CR B CR
please enter a single letter: A 41 please enter a single letter: 0a please enter a single letter: B 42 please enter a single letter: 0a please enter a single letter:
#include <stdio.h> int main(void) { int answer; do { printf("please enter a single letter: "); answer = getchar(); getchar( ); putchar(\n); printf("%c\n",answer); } while (answer != E); return 0; }
scanf("%c%*c", &answer);
CSA Rob Williams Pearson Education (c) 2006
CSA ch 09 - p 119
CSA Ch 10
CSA Computers Fetch-execute cycle Hardware CPU Arithmetic Logic Unit Control Unit RISC features ARM processor Pentium Itanium Input-output Parallel communication Serial communication Networking Local Area Networks Ethernet USB Wide Area Networks Other Networks Point to point Visual output Memor y Memor y hierarchy Cache and main memory Disk ling Parallel processing Software Operating systems Unix MS Windows Tools Compilers and assemblers Subroutines and stacks WIMPs Users viewpoints Hardware engineer HLL programmer Systems administrator Systems programmer
CSA ch 10 - p 120
data - compression and coding schemes, quantity timing - synchronization of rx with tx: frequency and phase signaling- error handling, ow control, and routing
100s
50s
Tx
Rx
CSA ch 10 - p 121
Tx Clock write data bit to line Data Rx Clock sample data now
Parity Bits - simple to apply, not ver y secure Block Checksums- simple to apply, not ver y helpful Polynomial Division- more complex, better security
CSA ch 10 - p 122
XOR 00000000 00000001 00000010 00000011 00000100 00000101 00000110 00000111 00001000 00001001 00001010 00001011 00001100 etc 0 1 1 0 1 0 0 1 1 0 0 1 0
Data to be sent
Transmit
New Parity value computed and compared 0110_0111 1 no error detected 0111_1110 0 error detected 0110_0101 0 no error detected !
0110_0111
0111_0110
0111_0110 1
0111_0100
0111_0100 0
CSA ch 10 - p 123
p1
p1 = d 1 XOR d 3 XOR d 4 p2 = d 2 XOR d 3 XOR d 4 p3 = d 1 XOR d 2 XOR d 4
d3 d4 p3
p2 d2
d1
7
d4
6
d3
5
d2
4
p3
3
P d1
2
p2
1
p1
2p d
d = 2p (p + 1)
4d-3p
CSA ch 10 - p 124
1 1 0 0 1 1 0
1 0 1 0 1 0 1
= [101]
CSA ch 10 - p 125
2 bytes Type
2 bytes Length
6 bytes Address
2 bytes Checksum
.......
S2 24 012200 0968584F4878004C4EB900010928584F206EFFFC524810BC0004602248790001 7D S2 24 012220 21CA4EB900010968584F487800484EB900010928584F206EFFFC524842104E5E 84 S2 08 012240 4E750000 D1 S8 04 000000 FB
08 + 01 + 22 + 40 + 4E + 75 + 00 + 00 = 12E forget the 1 as overow, leaving 2E ( 0010 1110 ) invert the bits 1101 0001 ( D1 ) THE CHECKSUM !
CSA ch 10 - p 126
1 1 1 1 0 _______________ 1 0 1 |1 1 0 0 1 1 0 1 0 1 ----1 1 0 1 0 1 ----1 1 1 1 0 1 ----1 0 1 1 0 1 ----0 0 0 -> indicates 1 0 = Remainder no errors to send
Sender
Receiver
CSA ch 10 - p 127
Echo back Hardware Control lines, RTS/CTS Software Control Codes, S/Q Frame-based Handshake Codes, ACK/NAK
Rx and Tx data
CTS RTS
RTS CTS
control
hardware handshake
software handshake
Serial links dedicated route, no addressing needed LAN broadcast transmission, receiver does the identication WAN selective routing can be dynamically changed
Star t lsb
CSA ch 10 - p 128
DCE ( 9 pin D-type) IBM COM1 Modem Por t -- 2 Rx Data 3 Tx Data 4 DTR 5 Ear th 7 RTS 8 CTS Ready to Send Clear to Send Data Terminal Ready
5 9 6 1
Socket Numbering
CSA ch 10 - p 129
/* Transmitter.c */ #include <stdio.h> int main(void) { FILE *dp; int c; if ((dp = fopen("COM2", "w"))==NULL) { printf("fail to open COM port\n"); return 1; } while ((c=getch()) != EOF) { fputc( c, dp); fflush(dp); } return 0; =============================================== /* Receiver.c */ #include <stdio.h> int main(void) { FILE *dp; int c; if ((dp = fopen("COM2", "r"))==NULL) { printf("fail to open COM port\n"); return 1; } while ((c= fgetc(dp)) != EOF) { putch( c); } return 0;
CSA ch 10 - p 130
Pentium CPU
PIC
IRQ 4
16550 UART
CSA ch 10 - p 131
/* Filetrans.c */ #include <stdio.h> #include <conio.h> #define CNTRLZ 0x1A int main(void) { FILE * fp FILE * dp; int c; if ((fp=fopen("C:\TEMP\text.dat", "rt"))==NULL) { printf("fail to open data file\n"); return 1; } if ((dp = fopen("COM2", "wt")) == NULL) { printf("fail to open COM port\n"); return 1; } while ((c = fgetc(fp )) != EOF) { fputc( c, dp); } fputc(CNTRLZ, dp); fflush(dp);} fclose(fp);
/* Filereceive.c */ #include <stdio.h> #include <conio.h> #define CNTRLZ 0x1A int main(void) { FILE *fp; FILE *dp; int c; if ((fp=fopen("C:\TEMP\text.dat", "w"))==NULL) { printf("fail to open data file\n"); return 1; } if ((dp = fopen("COM2", "r")) == NULL) { printf("fail to open COM port\n"); return 1; } while ((c= fgetc(dp)) != CNTRLZ) { fputc( c, fp); } fflush(fp); fclose(fp); return 0; }
CSA ch 10 - p 132
#include <stdio.h> #include <conio.h> #include <windows.h> #include <winbase.h> HANDLE hCom; char inpacket[16], outpacket[16]; BOOL fSuccess; //////////////////////////////////////////////////// // Initializes PC COM2 port to non-blocking mode // void initcomm(void) { COMMTIMEOUTS noblock; DCB dcb; hCom=CreateFile("COM2", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL ); if (hCom == INVALID_HANDLE_VALUE) { dwError = GetLastError(); printf("INVALID_HANDLE_VALUE()"); } fSuccess = GetCommTimeouts(hCom, &noblock); noblock.ReadTotalTimeoutConstant = 1; noblock.ReadTotalTimeoutMultiplier = MAXDWORD; noblock.ReadIntervalTimeout = MAXDWORD; fSuccess = SetCommTimeouts(hCom, &noblock); fSuccess = GetCommState(hCom, &dcb); if(!fSuccess) printf("GetCommState Error!"); dcb.BaudRate = 9600; dcb.ByteSize = 7; dcb.fParity = TRUE; dcb.Parity = EVENPARITY; dcb.StopBits = TWOSTOPBITS; dcb.fRtsControl = RTS_CONTROL_HANDSHAKE; dcb.fOutxCtsFlow = TRUE; fSuccess = SetCommState(hCom, &dcb); if(!fSuccess) printf("SetCommState Error!"); else printf("Comm port set OK!0); } Continues
CSA ch 10 - p 133
////////////////////////////////////////////////// // Reads COM2, single character // IF !char on COM2 return 0, ELSE return ASCII char // char readcomm() { char item; int ni; fSuccess = ReadFile( hCom, &item, 1, &ni, NULL ); if (ni >0 ) return item; else return 0; } ////////////////////////////////////////////////// // tests and reads keyboard // IF !char on kbd return 0, ELSE return ASCII char // char readkbd() { if (kbhit() ) return _getch(); else return 0; }
CSA ch 10 - p 134
Y roller
Mouse UART
X Y
1200kHz Crystal
Mouse Buttons
X & Y wheels
LED drive
Voltage regulator
Power on reset
Desk top
CSA ch 10 - p 135
hardware issues plugs & sockets dont t: 25/9 pin, sockets/pins Tx and Rx pins confused - crossed vs uncrossed lead different plug congurations incorrect wiring of h/w ow controls (CTS/RTS) reversed internal IDC ribbon cables incorrectly assembled IDC ribbon cables incorrectly installed interface card (IRQ, dma, port no.) serial por t hardware not initialized incompatible transmission formats ASCII vs EBCDIC or Unicode line speed setting: 1200, 2400, 9600 bps error checks: odd/even/none parity ASCII char length: 7 vs 8 bits number of stop bits user dened packet lengths CR-LF line terminator differences in les tab vs multiple SP differences Word Processor control characters (Word) EOF problems ow control failure CTS input uncontrolled by receiver RTS/CTS talking to XON/XOFF intermediate buffers on end-to-end ow control unread echo characters on serial lines RAM buffer threshold problems software problems sending/receiving data through wrong channel incorrect device driver installed uninstalled device driver
CSA ch 10 - p 136
used by the root hub to pass on conguration instructions and data to the devices, especially used during the initialization period. timed data transfers for devices with real-time data streams. simple non-time sensitive USB is not an interrupt system, it depends on timed polling from the hub to pick up data, such as keyboard input. downstream Hub 1
upstream
Hub 3
host Hub 2
Hub 4
Hub 6
USB interface
CU
ALU
SP downstream ports
DP Periphs
CSA ch 10 - p 137
External modem
ON / OFF Carrier
. . . . ... ... ... . . . . . .... ... ... ... ..... .... ... ... ... ...... .. ... .. .. .... ... .. .. . .. .. . . . . . . . . . . . .. .. .. . . . . . . . . . .. FSK . . . .. .. ... ... ... ... ... .. .. .. .. .. .. .. .. ... ... .. .. .. .. .. .. .. .. ... .. .. .. .. .. .. .. .. .. .. . . . . . . . . .. . .. . . . .. . .. . . . .. . . . . . . . . . . .. .. . . . . . . . .. . . . . . .. .. .. .. .. .. .. .. .. . .. . .. . . . .. .. . . . . . . . . .. .. . . . . Frequency . . . . . . . . . . . . . . . . .. . . . . . .. . . . . . . .. . . . .. .. . . .. .. .. . .. . .. . . . . . . . . . .. . .. . . . . . . . .. . . . . . . . . . .. .. .. .. .. .. . . . . . . . . .. .. . . . . . . . . .. . . . . . Shift Keying . . .. . .. . .. . . . .. . .. . .. . ... .. . .. . . . . . .. .. .... .... .... .... .. . .. .. ... ... .. ... ..... .. .. ... ... ..... .. .. .. .. ... . .... ... .. ... . . . .. .. . .
CSA ch 10 - p 138
Command
ATA ATDnnn-nnnn ATL ATPDnnn-nnnn ATW ATH0 ATM0 ATM1 ATM2 ATO0 ATO1 ATY0 ATY1
Function
Answer incoming call Tone dials the phone number nnn-nnnn Redials last number dialed Pulse dial nnn-nnnn Wait for dial tone Hang up Speaker off Speaker is on until a carrier is detected Speaker is always on Puts modem in data mode Takes modem out of data mode Disable disconnection on pause Enable disconnection on pause
1 Data
. .. ..... ...... ..... ..... ..... ...... . .. ....... ....... .. .. ...... ..... .. ... ... . . . . .. .. .. .. ... .... ... .. .. ... .... ... .. ... .. ... .. ... . . . . . . . . ... . .. .. ... .. .. .. . .. .. .. .. .. .. .. .. .. .. .. . . . . .. . . . .. ... . .. . .. ... . .. ... . . . .. .. .. .. .. .. .. .. ... .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..... . . . .... ..... . ..... ... ... .... ..... ... ... .......... ............ ........... .......... ........... ... .. ... .. .. .. ..... ... ..... .. .... ... ... ... ... .. .. .. .. .. . ... ... ... ... ..... ... ... .. .. .. .... ... .... ... ...... .... .... ... .. ..... ...... ...... ...... ..... ..... .. 01 10 11 00
1B1B
2B1Q
............ ............ .. ..... .. ..... ..... ........ .. .. ... ... .... . ...... .... ... .. .. .. .... ... .... ... . . . .. .... 3B1O . .... ... ... ... .. .. .. ..... ...... ..... ... ... ... .. .. . ............. . . ..... ... ... .... .... .... .... ....... ....... 000 011 011 010
CSA ch 10 - p 139
/2
r 0
- Phase
r - Amplitude - /2
Phase shift modem with a single carrier frequency signalling 0 or 1 with 0 or phase shift
Quad Phase, Single Amplitude /4, -/4, 3/4, -3/4 4 level QAM, 2B1Q
Oct Phase, Dual Amplitude 0, /4, /2, -/4, -/2, 3/4, -3/4, 8 level QAM, 3B1O
CSA ch 10 - p 140
CSA Ch 11
CSA Computers Fetch-execute cycle Hardware CPU Arithmetic Logic Unit Control Unit RISC features ARM processor Pentium Itanium Input-output Parallel communication Serial communication Networking Local Area Networks Ethernet USB Wide Area Networks Other Networks Point to point Visual output Memor y Memor y hierarchy Cache and main memory Disk ling Parallel processing Software Operating systems Unix MS Windows Tools Compilers and assemblers Subroutines and stacks WIMPs Users viewpoints Hardware engineer HLL programmer Systems administrator Systems programmer
CSA ch 11 - p 141
ACK
1 14
CSA ch 11 - p 142
Bus free
Arbit
Device select
Transfer
1. tting a large memory buffer inside the printer 2. run a background print spooler 3. use a full multi-tasking system
CSA ch 11 - p 143
Pin 2 4 6 8 10 12 14 16 18 32 36 38 40 42 44 46 48 50
data bit 0 data bit 1 data bit 2 data bit 3 data bit 4 data bit 5 data bit 6 data bit 7 PARITY ATN BSY ACK RST MSG SEL C /D REQ I /O
Master Slave
7 Byte 0 Byte 1 Byte 2 Byte 3 Byte 4 Byte 5 Vendor Group LUN Command (MSB) 0
50
CSA ch 11 - p 144
00 01 03 04 05 07 08 0A 0B 0F 10 11 12 25 26 2A 2E 2F
Group 1 Test unit ready Rezero unit Request sense Format unit Read block limits Reassign blocks Read Write Seek Read reverse Write le mark Space Inquiry Group2 Read capacity Extend addr rd Extend addr wr Write 7 verify Verify
13 14 15 16 17 18 19 1A 1B 1C 1D 1E
Verify Recover buffer Mode select Reser ved unit Release unit Copy Erase Mode sense Start / stop Receive diagnostic Send diagnostic Lock media
30 31 32 33 39 3A
Search data high Search data equal Search data low Set limits Compare Copy & verify
CSA ch 11 - p 145
i8253
i8255
i8255
B
I /OCHCK SD7 SD6 SD5 SD4 SD3 SD2 SD1 SD0 IOCHRDY AEN SA19 SA18 SA17 SA16 SA15 SA14 SA13 SA12 SA11 SA10 SA9 SA8 SA7 SA6 SA5 SA4 SA3 SA2 SA1 SA0 GND
D C
GND MEMCS16 IOCS16 IRQ10 IRQ11 IRQ12 IRQ15 IRQ14 DAK 0 DRQ0 DAK 5 DRQ5 DAK 6 DRQ6 DAK 7 DRQ7 +5v MASTER GND GND GND SBHE LA23 LA22 LA21 LA20 LA19 LA18 LA17 MEMR MEMW SD08 SD09 SD10 SD11 SD12 SD13 SD14 SD15 KEY
D CA B
EISA
The PCI bus can operate in two modes: Multiplexed Mode A single 32 bit bus is shared by address and data information. This increases the effective bus width, but reduces the data rate. Burst Mode This is the same trick that EDO DRAM employs. After an address has been sent, several data items will follow in quick succession. The bridge is capable of assembling "packets" of data and bursting it through to the PCI bus when ready.
Pentium CPU System bus, 66MHz, 64bits PCI Nor th Bridge PCI Bus, 33MHz, 32bits Disk Controller ISA South Bridge ISA bus, 8.33MHz, 16bits
Graphics
CPU
System Bus
Posting buffer
PCI Bus
CSA ch 11 - p 147
12V TCK GND TDO +5v +5V INTB INTD PRSTN 1 res PRSTN 2 GND GND res GND CLK GND REQ 5v I/O AD31 AD29 GND AD27 AD25 +3.3v C/BE 3 AD23 GND AD21 AD19 +3.3v AD17 C/BE 2 GND IRDY +3.3V DEVSEL GND LOCK PERR +3.3v SERR +3.3v C/BE 1 AD14 GND AD12 ADIO GND AD8 A07 +3.3v AD5 AD3 GND AD1 +5v I/O ACK 64 +5V +5v
TRST +12v TMS TDI +5v INTA INTC +5v res +5v I/O res GND GNO res RST +5v I/O GNT GND res AD30 +3.3V AD28 AD26 GND AD24 IDSEL +3.3v AD22 AD20 GND AD18 AD16 +3.3v FRAME GND TRDY GND STOP +3.3v SDONE SBO GND PAR AD15 +3.3v AD13 AD11 GND AD9 C/BE 0 +3.3V AD6 AD4 GND AD2 ADO +5v I/O REQ64 +5v +5v
PCI Socket
Card 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Serial Number 00000001 00000010 00000011 00000100 00000101 00000110 00000111 00001000 00001001 00001010 00001011 00001100 00001101 00001011 00001111
ABCDEFGH
Manufacturer Adaptec Compaq Creative Cyrix Epson HP Intel Matsushita Mitsubishi Motorola NCR Toshiba Tseng Labs
MID 9004 1032 10F6 1078 1008 103C 8086 10F7 1067 1057 1000 102F 100C
PID 36868 4146 4342 4216 4104 4156 32902 4343 4199 4183 4096 4143 4108
CSA ch 11 - p 149
GND D3 D4 D5 D6 D7 CD EN 1 A10 OUT EN A11 A9 A8 A13 A14 WE /PRG READY /BUSY +5v V 1 pp A16 A15 A12 A7 A6 A5 A4 A3 A2 A1 A0 D0 D1 D2 IOIS16 GND
PCMCIA Interface
GND CD DET 1 D11 D12 D13 D14 D15 CD EN 2 REFRESH IOR IOW A17 A18 A19 A20 A21 +5v V 2 pp A22 A23 A24 A25 RFU RESET WAIT INPACK REG SEL SPKR STSCHG D8 D9 D10 CD DET 2 GND
CSA ch 11 - p 150
CSA Ch 12
CSA Computers Fetch-execute cycle Hardware CPU Arithmetic Logic Unit Control Unit RISC features ARM processor Pentium Itanium Input-output Parallel communication Serial communication Networking Local Area Networks Ethernet USB Wide Area Networks Other Networks Point to point Visual output Memor y Memor y hierarchy Cache and main memory Disk ling Parallel processing Software Operating systems Unix MS Windows Tools Compilers and assemblers Subroutines and stacks WIMPs Users viewpoints Hardware engineer HLL programmer Systems administrator Systems programmer
CSA ch 12 - p 151
A0-A31
4 Gbyte Memor y
words - 2 / 4 bytes lines - 32 bytes lines - 32 bytes pages - 4 Kbytes blocks - 4 Kbytes les - Mbytes
16 Kbytes
LI Cache Memory - 1 ns
Primary Cache Controller
256 Kbytes
512 Mbytes
Main Memory - 10 ns
Memory Management Unit
16 Mbyte
Disk Cache - 10 ns
Device Controller
80 Gbytes
Disk Storage - 10 ms
Administrative staff
20 Tbytes
CSA ch 12 - p 152
Facility DRAM SRAM SCSI Hard Disk CD-ROM CD-RW Jazz Zip DAT Floppy
Size 64 MB 32 MB 256 KB/10ns PCI card 10GB 10GB 650 MB 650 MB WORM RW 1 GB 1 GB 100 MB 100 MB 4 GB 4 GB 1.4 MB 1.4 MB
device SDRAM 168 pin DIMM EDO 72 pin SIMM SRAM chip IDE SCSI 32x IDE 2x IDE disk disk drive disk drive disk SCSI drive tape drive disk
Unit cost, 40 50 2 180 110 250 60 200 0.75 2.50 200 65 60 15 350 2.5 15 0.5
Memor y costs
Memor y location
CPU time
CSA ch 12 - p 153
Column index 0 1 2 3 4 5 6 7 8 9 10 . . . . 0 1 2 3 4 5 6 7 8 9 10 . . .
Row index
row 0
row 1
row 2
row 3
row 4
CSA ch 12 - p 154
#include <stdio.h> #include <sys/times.h> #include <limits.h> #define MAX 1000 clock_t times(struct tms* b); main () { int i, j; int big[MAX][MAX]; int sum, start, middle, end; struct tms tbuff; times( &tbuff); start = tbuff.tms_utime; for(i=0; i<MAX; i++) { for(j=0; j<MAX; j++) { sum += big[i][j]; /* <------------ i, j here */ }; }; times( &tbuff); middle = tbuff.tms_utime; for(i=0; i<MAX; i++) { for(j=0; j<MAX; j++) { sum += big[j][i]; /* <------------ j, i here */ }; }; times( &tbuff); end = tbuff.tms_utime; printf("First run time is %d \n",(middle - start)*1000/CLK_TCK); printf("Second run time is %d \n",(end - middle)*1000/CLK_TCK); }
rob [80] cc cache.c -o cache rob [81] cache First run time is 150 Second run time is 310 rob [82]
CSA ch 12 - p 155
CSA ch 12 - p 156
! 19
.L119: .L116: ! 20
.L123: .L120: ! 21
sum += big[i][j];
! 22
};
sethi%hi(-4000016),%l0 or%l0,%lo(-4000016),%l0 ld[%fp+%l0],%l4 sethi%hi(-4000012),%l0 or%l0,%lo(-4000012),%l0 add%fp,%l0,%l3 ld[%fp-8],%l0 sll%l0,12,%l2 sll%l0,5,%l1 sub%l2,%l1,%l2 sll%l0,6,%l1 sub%l2,%l1,%l1 add%l3,%l1,%l2 ld[%fp-12],%l0 sll%l0,2,%l1 add%l2,%l1,%l0 ld[%l0+0],%l1 add%l4,%l1,%l1 sethi%hi(-4000016),%l0 or%l0,%lo(-4000016),%l0 st%l1,[%fp+%l0] ld[%fp-12],%l0 add%l0,1,%l0 st%l0,[%fp-12] ld[%fp-12],%l0 cmp%l0,1000 bl.L120 nop ! block 4
.L124: .L122: ! 23
};
.L125: .L118:
CSA ch 12 - p 157
CPU
I/O Subsystem
1. Folded address space, also known as Direct Mapping 2. Associative (content addressable) memory 3. Hashed mapping
CSA ch 12 - p 158
TAG Memor y 111 110 101 100 011 010 001 000 4 0 11
Cache Memory
Main Memory 11111 111 11 11111 111 10 11111 111 01 11111 111 00 11111 110 11 11111 110 10 11111 110 01 11111 110 00 10100 101 11 10100 101 10 10100 101 01 10100 101 00 10100 100 11 10100 100 10 10100 100 01 10100 100 00 00000 111 00 00000 001 11 00000 001 10 00000 001 01 00000 001 00 00000 000 11 00000 000 10 00000 000 01 00000 000 00 Address
10
01
00
CSA ch 12 - p 159
Status
TAG Memor y
Cache Memory
Main Memory 11111 111 11 11111 111 10 11111 111 01 11111 111 00 11111 110 11 11111 110 10 11111 110 01 11111 110 00 10100 111 11 10100 110 10 10100 101 01 10100 100 00 10100 011 11 10100 010 10 10100 001 01 10100 000 00 00000 111 00 00000 001 11 00000 001 10 00000 001 01 00000 001 00 00000 000 11 00000 000 10 00000 000 01 00000 000 00 Address
11
10
01
00
Associative Cache
A31-A24 TAG 01
CSA ch 12 - p 160
1. on start-up of a new program 2. when the cache is too small to hold the active execution set 3. cache line conict in a direct mapped cache.
CSA ch 12 - p 161
Main Memor y
of pages
Disk
31
Memor y
Vir tual memory logical page into physical frame address translation
CSA ch 12 - p 162
CPU
vir tual address
MMU
physical address
System Bus
I/O Subsystem
I/O Subsystem
Stack Segment
Data Segment Stack Segment DS Base Code Segment Logical Addressing Programmers View page CS Base Vir tual Addressing O/S View
0000 0000
frame
000 0000
CSA ch 12 - p 163
100km/hr
Read/write head
CSA ch 12 - p 164
A computer system having 2 Mbytes of RAM has hard disks with the following characteristics: Rotational speed: 3600 rpm Track capacity: 16384 bytes Heads/cylinder : 10 Head movement time, track to track:20 ms Average seek time: 50 ms How long does it take to dump memory onto disk? Assume the disk is empty. 3600rpm = 60 rps rotational period = 1/60 secs = 1000/60 msec = 16.66 msec = 17 msec latency = 8.5 msec data rate = 16 Kbytes / 17 msec = 1 Mbyte/sec ow time for 2 Mbyte = 2000 msec = 2 sec 2 Mbyte needs 128 tracks or 12.8 cylinders ie 13 head movements tot time = head movement (seeks) + rotnl delays (latencies) + data ow time = 1 x 50 + 12 X 20 + 13 X 8.5 + 2000 = 2314 msec
90650U2 6.5 2 1
90845U 8.45 3 2
91020U3 10.21 3 2
91360U4 13.61 4 2
92040U6 20.42 6 3
92040U8 27.23 8 4
CSA ch 12 - p 165
SCAN
FCFS
SSTF Time
34 29
FCFS
SSTF
SCAN
CSA ch 12 - p 166
lacquer coating (30m) metalic layer rotating (1000r pm) Polycarbonate disk (1.2mm)
beam splitter
light detector
focusing
Paper Label 1.6 m Lacquer Reective coating Upper dielectric Recording layer Lower dielectric
1.2 mm
Track grooves
Polycarbonate Disk
CSA ch 12 - p 167
Discrete Cosine Transform (DCT) base functions as used with MPEG image compression
CSA ch 12 - p 168
CSA Ch 13
CSA Computers Fetch-execute cycle Hardware CPU Arithmetic Logic Unit Control Unit RISC features ARM processor Pentium Itanium Input-output Parallel communication Serial communication Networking Local Area Networks Ethernet USB Wide Area Networks Other Networks Point to point Visual output Memor y Memor y hierarchy Cache and main memory Disk ling Parallel processing Software Operating systems Unix MS Windows Tools Compilers and assemblers Subroutines and stacks WIMPs Users viewpoints Hardware engineer HLL programmer Systems administrator Systems programmer
CSA ch 13 - p 169
.. .. .. . .. .. .. .. .. .. . .. .. .. .. .. .. . .. .. .. .. .. .. .. .. .. . .. .. .. . .. .. .. . .. . . . . . . . ... ... ....... .... ... .... .... ... ....... .... ... .... .... .... ....... .... .... .... .... .... ... .... ... ...... ... .... ...... .... ... .... .. . .. .... .. .. .. . .. .. .... .. .. .. . .. .. .... .. .. .. .. .. . .. .. .. .... . .. .. .... .. .. .. . . . .. . . . . . .. . . . . . .. . . . . . . . . .. . . .. . . . .... . ... . . . . . ... ... . . . ... . . . . . ... ... . . . . . . . . . . ... . . ... ... . . . . . ... . . . . . . . . . . . . . ... ... .... .. .. .. .. .... .. .. .. .. .. .... .. .. .. .. .. .. .. .... .. .. .. .... .. .. .. .. .. .. .... .. .. ... .. .... .. .. ... .. .. .... ... ... ... ... .. .. .. .... .. ... .. ..... ... .. ... .. .. .. .. . . . . .. . . . . . .. . . . . . . . .. . . . . . . . . . . . . . . . . . . . . .. .. . . .. .. .. .. .. .. .. . . .. .. ..
CSA ch 13 - p 170
rob@milly [80] total 6702 drwx--x--x 76 drwx--x--x 3 -rwx-----1 -rwx-----1 -rwx-----1 -rwx-----1 -rwx-----1 -rwx-----1 -rwx-----1 -rwx-----1 rob@milly [81]
ls -alt rob rob rob rob rob rob rob rob rob rob csstaff csstaff csstaff csstaff csstaff csstaff csstaff csstaff csstaff csstaff 7168 3072 42544 42545 9503 9525 5144 17851 17890 21180 Aug Aug Aug Aug Aug Aug Aug Aug Aug Aug 7 7 6 5 5 5 3 3 3 2 17:57 15:55 14:57 14:55 14:35 14:31 14:31 14:31 14:30 17:28 .. . #testparam.c# sort.c jeffsm.c jeffsm.c a.out ch_9c.txt ch_9c.asc ntime.c
CSA ch 13 - p 171
Chapt 7
cat
eqn
pic
troff
lpr
Printer
A Unix process pipeline to format and print text used by systems administrators
1 rob csstaff 0 Oct 14 18:39 pipe1 1 rob csstaff 0 Oct 14 18:39 pipe2 1 rob csstaff 0 Oct 14 18:39 pipe3
rob@milly [82] cat letter.tmp >! pipe1 & rob@milly [82] cat pipe1 >! pipe2 & rob@milly [82] cat pipe2 >! pipe3 &
CSA ch 13 - p 172
#!/bin/sh # # Script converts sar data into graphs - PJN 20/10/1998 # # Extend the PATH to include gnuplot PATH=${PATH}:/usr/local/bin ; export PATH # Procedure to remove non-data lines from log file. remclutter() { grep : |grep -v free |grep -v % |grep -v / |grep -v restarts } # Procedure to pad numbers with zeroes to 2 digits. padnum() { NUM=$1 while [ `/bin/echo "${NUM}\c" | wc -c` -lt 2 ]; do NUM="0${NUM}" done echo $NUM } # Procedure to convert time of day timestamps to decimal days. parsetimes() { DAY=0 OLDHOUR=23 while read TIME DATA; do if [ "$DATA" = "" ]; then DATA="0 0 0 0 0 0 0 0 0 0 0 0" fi HOUR=`echo $TIME | cut -f1 -d:` MIN=`echo $TIME | cut -f2 -d:` if [ $HOUR -lt $OLDHOUR -a "$MIN" = "00" ]; then DAY=`expr $DAY + 1` fi PTIME=`expr \( \( \( $HOUR \* 60 \) + $MIN \) \* 100 \)/1440` PTIME=${DAY}.`padnum $PTIME` echo "$PTIME $DATA" OLDHOUR=$HOUR done } # Procedure to get data from a named column. getcol() { tr -s | cut -f1,${1} -d\ | tr }
Continues
CSA ch 13 - p 173
# Determine the i/p and o/p files (for last weeks data). WEEK=`date +%W` WEEK=`expr $WEEK - 1` if [ $WEEK -eq -1 ]; then WEEK=52 fi WEEK=`padnum $WEEK` DATAFILE=/var/adm/sa/sa$WEEK OUTFILE=/tmp/$$.graphs # Process virtual memory data from sar log. echo "VM usage" sar -f $DATAFILE -r > /tmp/$$.sar cat /tmp/$$.sar | remclutter | parsetimes > /tmp/$$.sar-f rm /tmp/$$.sar cat /tmp/$$.sar-f | getcol 2 > /tmp/$$.freemem cat /tmp/$$.sar-f | getcol 3 > /tmp/$$.freeswap (cat << EOF set term postscript set time set xtic 0,0.5 set title "`hostname` virtual memory usage" f(x) = (x * 512 ) / 1048576 g(x) = (x * `pagesize` ) / 1048576 plot [0:7] []\ "/tmp/$$.freemem" thru g(x) title "Free RAM MB" with lines,\ "/tmp/$$.freeswap" thru f(x) title "Free Swap MB" with lines EOF ) | gnuplot > $OUTFILE rm /tmp/$$.freemem /tmp/$$.freeswap /tmp/$$.sar-f lp -d ps $OUTFILE sleep 60; rm $OUTFILE exit
CSA ch 13 - p 174
#include <stdio.h> int bsort(char* pc[ ], int n ) { int gap, i, j; char* pctemp; for (gap = n/2; gap > 0; gap /= 2) for (i = gap; i < n; i++) for(j = i-gap; j>= 0; j -= gap) { if (strcmp(pc[j], pc[j+gap]) <= 0) break; pctemp = pc[j]; pc[j] = pc[j+gap]; pc[j+gap] = pctemp; } } void main(void) { int i; char* names[ ] = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday","Sunday"}; i = bsort(names, 7); for(i=0; i<7; i++) { printf("%s0, names[i] ); }; }
CSA ch 13 - p 175
SEQ
void doitall(void) { doA( ); doB( ); doC( ); }
do A
do B
do C
IT
do D
* 10
SEL
X>0
do F
do E
CSA ch 13 - p 176
SEQ
do A do B do C
L1: CALL doA CALL doB CALL doC --------------------------JZ L2 .... CALL doD JMP L1
IT
? n do D
SEL
y do E
n do F
CSA ch 13 - p 177
Microcode Interpreter
Co-processor Units
Electronic Devices
CSA ch 13 - p 178
1. instruction mnemonics into binary codes 2. user dened symbols into constant numbers 3. numbers from base to base, normally decimal to binary 4. symbolic position labels into physical addresses
Value $FF
CSA ch 13 - p 179
Source le
Preprocessor Error repor t Source le Lexical analysis Error repor t Token list
Symbol table
Intermediate code
Code Gen
Machine code
Stages of Compilation
Code Optim
CSA ch 13 - p 180
CSA Ch 14
CSA Computers Fetch-execute cycle Hardware CPU Arithmetic Logic Unit Control Unit RISC features ARM processor Pentium Itanium Input-output Parallel communication Serial communication Networking Local Area Networks Ethernet USB Wide Area Networks Other Networks Point to point Visual output Memor y Memor y hierarchy Cache and main memory Disk ling Parallel processing Software Operating systems Unix MS Windows Tools Compilers and assemblers Subroutines and stacks WIMPs Users viewpoints Hardware engineer HLL programmer Systems administrator Systems programmer
CSA ch 14 - p 181
DEC
Mainframe computer
Mini computer
Personal computer
CSA ch 14 - p 182
CSMA/CD Token Bus Token Ring MAN Wireless LAN 100 Mbps LAN
70 Terminator
////////
\\\\\\\\
70 Terminator
10Mbps Ethernet
Workstations
Switching Hub
Switching Hub
workstations
CSA ch 14 - p 183
1 2 3 6 4 5 7 8
UltraChip
SMC
CSA ch 14 - p 184
Application TCP/IP Device Driver Network Controller Serial Network interface Software
Hardware
CSA ch 14 - p 185
20MHz Clock
Data
1 XOR
+0.7v
-0.7v
CSA ch 14 - p 186
10Base5
10Base2
10BaseT
100BaseT
100BaseF
10Mbps, 500m segment length, minimum tap separation 2.5m, maximum of 4 repeaters, 50 coax cable vampire tap (Media Access Unit) 10 Mbps, 200m (165m) segment length, minimum tap separation 0.5m, maximum of 4 repeaters, 70 coax cable BNC T-piece bayonet connection 10 Mbps, 100m segment length, end-to-end, simplex 100 AWG24 twisted pairs cable RJ45 telecom jack 100 Mbps, 205m segment length, end-to-end, simplex 100 AWG24 twisted pairs cable 100 Mbps 2000m segment length end-to-end, simplex optic bres
Thick Ethernet
Thin Ethernet
Switched Ethernet
Fibre Ethernet
CSA ch 14 - p 187
T packet =
S2
Received Collision
Collision warning
S1
Transmitted
Star t End
Time, sec
CSA ch 14 - p 188
Binar y 0000_0000 0000_0001 0000_0010 0000_0011 0000_0100 0000_0101 0000_0110 0000_0111 0000_1000 0000_1001 0000_1010 0000_1011 0000_1100 0000_1101 0000_1110 0000_1111 .... 1111_1111
Trinar y +-00+-T 0+-+-+T +-0+-0T -0++-0T -0+0+-T 0+--0+T +-0-0+T -0+-0+T -+00+-T 0-++-0T -+0+-0T +0-+-0T +0-0+-T 0-+-0+T -+0-0+T +0--0+T ... +0-+00T
8B6T Coding
CSA ch 14 - p 189
15
Sync Preamble (56 bits) SFD Destination Address (48 bits) Source Address (48 bits) Length of Data Field Data 0-1500 Padding 0-46 CRC error detection
CSA ch 14 - p 190
1000 127255255255 128000 191255255255 192000 223255255255 224000 239255255255 240000 247255255255 127000
Local 0 1 1 1 1 1 1 1 loopback
CSA ch 14 - p 191
rob@olveston [20]cat /etc/hosts # Internet host table # 127.0.0.1 localhost 164.11.10.206 olveston 164.11.8.16 egg ns0 164.11.253.2 sister ns1 164.11.8.99 ada ns2 164.11.10.5 riff ns3 rob@olveston [21]
loghost
Appln header
user data
TCP
TCP header
Appln data
IP
IP header
TCP header
Appln data
Ether driver
Ether header
IP header
TCP header
Appln data
Ether trailer
Ethernet
CSA ch 14 - p 192
rob@olveston [20]df / (/dev/dsk/c0t0d0s0 ): /usr /proc /dev/fd /var /tmp /cache /local /usr/misc /tutorials /home/staff/cs /var/mail /projects/staff /projects/rob /WWW/Documents /WWW/Servlets rob@olveston [21] (/dev/dsk/c0t0d0s3 ): (/proc (fd ): ):
751760 blocks 292766 blocks 0 blocks 0 blocks 264238 blocks 165454 blocks
216981 files 177111 files 915 files 0 files 97421 files 100191 files 48381 files 1264846 files 273054 files
(/dev/dsk/c0t0d0s4 ): (/dev/dsk/c0t0d0s5 ):
(milly:/tutorials ): 282752 blocks 93369 files (sister:/home/staff/csm/csstaff): 4942096 blocks 513071 (mailhub:/var/spool/mail): 3582944 blocks (ada:/projects/staff): 1408240 blocks (ada:/projects/rob ): 218704 blocks 974994 files 729518 files 95166 files
(www:/var/htdocs ): 2032720 blocks 582750 files (www:/opt/local/JSDK/servlets): 3539408 blocks 344000 files
remote hosts
CSA ch 14 - p 193
LAN 1
CSA ch 14 - p 194
Linux
Windows-XP
CSA ch 14 - p 195
Ser ver
socket( ) create a socket
Client
CSA ch 14 - p 196
SOCKET socket(int af, int typesock, int protocol) int bind(SOCKET mysock, const struct sockaddr "psock, int nlength) int listen(SOCKET mysock, int qmax) int connect(SOCKET yoursock, const struct sockaddr *sname, int nlength) SOCKET accept(SOCKET mysock, struct sockaddr *psock, int *addrlen) int send(SOCKET yoursock, const char *pdbuff, int dblen, int flags) int recv(SOCKET mysock, char *pdbuff, int dblen) int closesocket(SOCKET mysock)
CSA ch 14 - p 197
Ser ver
socket( ) create a socket
Client
socket( ) create a socket
CSA ch 14 - p 198
CSA Ch 15
CSA Computers Fetch-execute cycle Hardware CPU Arithmetic Logic Unit Control Unit RISC features ARM processor Pentium Itanium Input-output Parallel communication Serial communication Networking Local Area Networks Ethernet USB Wide Area Networks Other Networks Point to point Visual output Memor y Memor y hierarchy Cache and main memory Disk ling Parallel processing Software Operating systems Unix MS Windows Tools Compilers and assemblers Subroutines and stacks WIMPs Users viewpoints Hardware engineer HLL programmer Systems administrator Systems programmer
CSA ch 15 - p 199
LAN
5 1 6 WAN WAN
LAN
LAN
CSA ch 15 - p 200
biff
517
talk
512
telnet ftp
23 20/21
smtp
25
http
80
UDP
TCP
por t
02
06
IP 0800
ARP 0806
Ether Driver
Network Interface
CSA ch 15 - p 201
> cat /etc/services tcpmux 1/tcp echo 7/tcp echo 7/udp discard 9/tcp discard 9/udp systat 11/tcp ftp-data 20/tcp ftp 21/tcp telnet 23/tcp smtp 25/tcp time 37/udp name 42/udp whois 43/tcp gopher 70/tcp finger 79/tcp www 80/tcp www 80/udp hostnames 101/tcp sunrpc 111/udp sunrpc 111/tcp
mail timserver nameserver nicname # usually to sri-nic #Internet Gopher http hostname rpcbind rpcbind # World Wide Web # usually to sri-nic
CSA ch 15 - p 202
15
0 15 7 0
15
Sync Preamble SFD Destination Address (48 bits) Source Address (48 bits) Length of Data Field
Source port Destination Por t Transmitted Sequence number Acknowledged Sequence number
Header length
TOS
TTL max hops Protocol Header checksum IP Source address (32 bits) IP Destination address (32 bits)
Flags
Payload Type
User Payload
IP Header Structure
Ethernet header
IP header
Ethernet Packet
Data packet
single data packet sent immediately ACK ACKed multiple data packets sent all ACKed
Router
Network 1
Network 5
Bridge
Network 1
Network 1
Repeater
Network 2
CSA ch 15 - p 204
rob@olveston [20] cat /etc/hosts # Internet host table # 127.0.0.1 localhost 164.11.253.47 olveston loghost 164.11.8.16 egg ns0 164.11.253.2 sister ns1 164.11.8.99 ada ns2 164.11.10.5 riff ns3 rob@olveston [21] rob@olveston [21] netstat -rn Routing Table: Destination Gateway Flags Ref Use Interf ----------------------------------------------------127.0.0.1 127.0.0.1 UH 0 503 lo0 164.11.253.0 164.11.253.47 U 3 228 hme0 224.0.0.0 164.11.253.47 U 3 0 hme0 default 164.11.253.1 UG 0 14297 rob@olveston [22]
CSA ch 15 - p 205
IP number 164.11.253.47
CSA ch 15 - p 206
rob@milly [10] ypcat hosts | more 164.11.13.5 gecko 164.11.9.89 TT89 164.11.235.52 saar 164.11.243.225 valdoonican 164.11.10.56 StaffPC56 164.11.11.73 blackwell 164.11.253.47 olveston 164.11.8.203 dialin63 164.11.8.200 dialin60 164.11.13.15 wallaby 164.11.235.87 shannon 164.11.253.158 new_pb2 164.11.243.249 naqqara 164.11.194.4 linux04 164.11.10.45 drjones 164.11.11.71 wesley 164.11.235.122 siphon --more--
org
net
com
edu
gov
mil
fr
de
uk
us
gov
ac
co
uwe
csm
rob@milly [33] cat /etc/resolv.conf domain csm.uwe.ac.uk search csm.uwe.ac.uk uwe.ac.uk nameserver 164.11.8.16 nameserver 164.11.253.2 nameserver 164.11.253.11 nameserver 164.11.8.99 rob@milly [34] /usr/sbin/nslookup Default Server: egg.csm.uwe.ac.uk Address: 164.11.8.16 > smilodon.cs.wisc.edu Server: egg.csm.uwe.ac.uk Address: 164.11.8.16 Non-authoritative answer: Name: smilodon.cs.wisc.edu Address: 128.105.11.80 > D rob@milly [35]
CSA ch 15 - p 208
CSA ch 15 - p 209
CSA ch 15 - p 210
http proxy [URL] - The proxy command allows a proxy HTTP server to be dened which will be used in subsequent client commands. Providing a URL argument sets the proxy server. Setting the proxy to an empty string turns the proxy feature off. http head url - The head command retrieves the HTTP header for the document located at URL. http get url le - The get command retrieves the document located at URL. The body of the document is written to le. The command returns the HTTP header as described for the http head command above. http post url lename_1 lename_2 - The post command posts the document in lename_1 to the location URL. The body of the returned document is written to lename_2. The command returns the HTTP header as described for the http head command above. http put URL le - The put command copies the le into the URL. The command returns the HTTP header as described for the http head command above. http delete URL - The delete command deletes the document at the URL. The command returns HTTP status information. The %X variables are substituted before a script is evaluated: %A - The network address of the client. %P - The URL path requested by the requestor. %S - The search path contained in the URL path.
CSA ch 15 - p 211
rob@olveston [50] telnet www.altavista.com 80 Trying 204.152.190.69... Connected to altavista.com. Escape character is ]. GET / - - <img src="/av2/gifs/dart.gif" width=8 height=9 hspace=5 vspace=5 align=top><a <img src="/av2/gifs/dart.gif" width=8 height=9 hspace=5 vspace=5 align=top><a </font></td></tr></table> <br> <table width="100%" cellpadding=0 cellspacing=0 border=0><tr> <td align=center><font size=-2 face="arial,helvetica" color="#003399"> <a href="/av/content/about.htm">About AltaVista</a> | <a href="/av/content/help.htm">Help</a> | <a href="/av/content/questions.htm">Feedback</a> | <a href="http://www.doubleclick.net/advertisers/altavista/">Advertising Info</a> | <a href="/cgi-bin/query?pg=addurl">Add a Page</a><br> <a href="/av/content/disclaimer.htm">Disclaimer</a> | <a href="/av/content/privacy.htm">Privacy</a> | <a href="http://image.altavista.com/AV_CopyrightPolicy.htm">Copyright</a> | <a href="/av/content/av_network.html">International</a> | <a href="/cgi-bin/query?pg=tmpl&v=pref.html">Set your Preferences</a> </font></td></tr></table> </body></html> Connection closed by foreign host.
rob@localhost> telnet www.cems.uwe.ac.uk 80 Trying 164.11.8.19... Connected to www.cems.uwe.ac.uk (164.11.8.19). Escape character is ]. GET /rwilliam/http_spook Hello, and welcome to the target file in this telnet/http file GET exercise. Connection closed by foreign host. rob@localhost>
CSA ch 15 - p 212
DNS server
Index ser vers each with 80 dual Pentium cards with 2 GB DRAM & 80 GB IDE disks in cooled racking
CSA ch 15 - p 213
Repositor y of web pages (compressed by zlib) Lexicon Indexer wordID converter Word index store inverted le Index sor ter
Document index store URL resolver Links Searchers hits PageRank Filter and sor ter
Quer y allocate
results list
CSA ch 15 - p 214
Application layer
Application program
Presentation layer
Session layer
Transpor t layer
Network layer
Vir tual circuit routing control packet sequencing Flow control error/lost block detection
Link layer
Physical layer
Communication sub-net layers
CSA ch 15 - p 215
CSA Ch 16
CSA Computers Fetch-execute cycle Hardware CPU Arithmetic Logic Unit Control Unit RISC features ARM processor Pentium Itanium Input-output Parallel communication Serial communication Networking Local Area Networks Ethernet USB Wide Area Networks Other Networks Point to point Visual output Memor y Memor y hierarchy Cache and main memory Disk ling Parallel processing Software Operating systems Unix MS Windows Tools Compilers and assemblers Subroutines and stacks WIMPs Users viewpoints Hardware engineer HLL programmer Systems administrator Systems programmer
CSA ch 16 - p 216
IXC
Trunk lines
LXC
CSA ch 16 - p 217
128 112
Output value
96 80 64 48 32 16
V V /16 /8 V /4 V /2 V V /1
V out =
Multiplexor 28 29 30 31
1 slot
10110110
CSA ch 16 - p 218
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9
Control Computer
Signal Channel
time frame 2
5 8 2 0 8 4
frame 3
5 8 2 0 8 4
frame 4
5 8 2 0 8 4
frame 5
5 8 2 0 8 4
TDM Bus
0 1 2 3 4 5 6 7 8 9
TDM Controller
0 1 2 3 4 5 6 7 8 9
CSA ch 16 - p 219
300 Hz
30 KHz LF
30 GHz
VLF
twisted pair
Frequency Modu a ed
Phase Modu a ed
1 0 0 1 1 1 1 0 0 0 1 1 1 1 0 0 0 1 1 1 1 1 1 0 0 0 0
CSA ch 16 - p 220
Radio mast
Base station
Switch
Switch
Switch
0.1 - 0.3 GHz 0.3 - 1.0 GHz 1.0 - 2.0 GHz 2.4 - 2.5 GHz 3.4 - 3.5 GHz
VHF UHF
Terrestrial television & radio Television, GSM mobile (0.9 GHz), packet radio, pagers Navigation aids, GSM mobile (1.8 GHz) Shor t range radio control (Bluetooth) Neighbourhood antennae
CSA ch 16 - p 221
7 6 1 5 4 7 6 1 5 4 6 1 5 4 3 3 7 2 5 4 2 5 4 6 1 3 6 1 3 7 2 3 7 2 5 4 6 1 3 7 2 2
4 2 1 3 4 2 3
CSA ch 16 - p 222
Sound switch ADC Speech Encoder Listener Noise Speech Encoder Extra polation Speech Processing
Class 1 CRC Convl Coding Re-ordering Interleaving Ciphering Burst assem GMSK_mod
DAC
PA MXR Filter
DAC
ADC
Voice Codec
Sig Proc
Radio Modem
TDMA timer
Analog Baseband
PLL
SIM card
CSA ch 16 - p 223
0 1 2 3 4 5 6 7 8 9 10111213141516171819202122232425 120 ms TCh Multiframe 0 1 2 3 4 5 6 7 4.616 ms TDM frame T 3 Voice 57 C 1 TS 26 C 1 Voice 57 T Gd 577 s time slot 3 8.25bits
Voice data
Packets Transfer
Circuit Closed
Message Complete
Switch: 1
Path Closed
CSA ch 16 - p 224
Header 5 bytes
Payload 48 bytes
111
0 1
111
0 1
0 4 155 Mbps 1 5
0 1
0 1
0 1
4 5
0 1
0 1
0 1
2 6
6 7
0 1
0 1
0 1
3 7
CSA ch 16 - p 225
ATM switch
LAN
ATM switch ATM 155 Mbps Trunk Line ATM switch Ser ver ATM switch
ATM WAN linking together diverse LANs to form par t of the Internet
A/C
address
func
CRC
CSA ch 16 - p 226
P
12 : 01
Enter car number rst Tariff 1hr 40p Sun free Sat free
Coins
U
ISDN i/f card Domestic Control maximum 8 devices
B chan-1
B chan-2
B chan-1
B chan-2
CSA ch 16 - p 227
1 Data
CSA ch 16 - p 228
Local Exchange Ofce PTT Local Exchage Voice Splitter ATM Switch DSL Modem Data Subscriber line 2.5 Km
Subscriber premises
Guard bands .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
04
Voice band
25
160 240
Amplitude
Frequency (kHz)
780
CSA ch 16 - p 229
15 Km Satellite receiver Kerb side Node Kerb side Node Optic Fibre Video Voice & data Kerb side Node
500 m
Headend
575 600
750
Digital Outward
Digital Inward
Telephones
CSA ch 16 - p 230
CSA Ch 17
CSA Computers Fetch-execute cycle Hardware CPU Arithmetic Logic Unit Control Unit RISC features ARM processor Pentium Itanium Input-output Parallel communication Serial communication Networking Local Area Networks Ethernet USB Wide Area Networks Other Networks Point to point Visual output Memor y Memor y hierarchy Cache and main memory Disk ling Parallel processing Software Operating systems Unix MS Windows Tools Compilers and assemblers Subroutines and stacks WIMPs Users viewpoints Hardware engineer HLL programmer Systems administrator Systems programmer
CSA ch 17 - p 231
On-line
Batch Processing
Real-time
aw k ep gr
Secondar y Bootstrap
CSA ch 17 - p 233
Tool awk cat diff echo nd grep lpr ls more ps sed sor t spell tr troff uniq users wc who
Function text processing language opens and concatenates les le comparison repeats argument to stdout le search utility string (reg expr) search print demon directory listing text viewer process listing stream editor string sor ter spell checker transpose strings text formatter repeated line detector network users list le sizer local user list
Example cat le | awk $0 ! /$/ {print} cat header ch_01 | groff -petfH > /tmp/tmp.ps diff ch_01.a ch_01.b echo $PATH nd -name "*rob*" -print grep "rob" /etc/passwd lpr -Pnts -#25 /Sheets/unix_intro ls -al more book.txt ps -af sed s/r-williams/rob.williams/g <le1 >le2 cat le | sort +1 -2 spell letter.txt tr -cs A-Za-z \012 groff -petfH sor t | uniq -c | sort -n users > checkle wc -w assignment.txt who
Computer hardware
CSA ch 17 - p 234
PID - process id UID - owner Process State Semaphore ID Signal ID Memor y needs CODE SEG pointer STACK SEG pointer DATA SEG pointer Priority Accounting information File descriptors Current director y Task Queue pointers
CSA ch 17 - p 235
Task 1 Control Block Task stack area Task 2 Control Block Task stack area Task 4 Control Block Task stack area Task code Task code Task code
CSA ch 17 - p 236
CSA ch 17 - p 237
Ready
Executing
Dispatched
Freed
Waiting
Condition wait
Zombie
rob@olveston [100] rlogin milly Last login: Wed Mar 29 19:22:33 from rob@milly [41] rob@milly [41] ps -A | wc -l 450 rob@milly [42] rob@milly [42] logout Connection closed. rob@olveston [101] rob@olveston [101] ps -A | wc -l 55 rob@olveston [102]
CSA ch 17 - p 238
The effective user ID number of the process (the login name is printed under the -f option). The process ID of the process (this number is used when killing a process). The process ID of the parent process. The star ting time of the process, given in hours, minutes, and seconds. (A process begun more than 24 hours before the ps inquir y is displayed in days and months) The controlling terminal for the process ("?" is shown when there is no controlling terminal as for background or daemon processes) The cumulative execution time for the process. The command name. (the full command name and its arguments, up to a limit of 80 chars, are printed with the -f option). The state of the process, (use the -f option): O Process is running on a processor. S Sleeping: process is waiting for an event to complete. R Runnable: process is on run queue. Z Zombie state: process terminated and parent is not waiting. T Process is stopped, either by a job control signal or because it is being traced. Processor utilization for scheduling. Not printed when the -c option is used.
(f,l)
CSA ch 17 - p 239
rob@olveston [141] ps -Af UID PID PPID C STIME root 0 0 0 Mar 16 root 1 0 0 Mar 16 root 2 0 0 Mar 16 root 3 0 0 Mar 16 root 322 297 0 Mar 16 root 122 1 0 Mar 16 root 318 1 0 Mar 16 root 102 1 0 Mar 16 root 112 1 0 Mar 16 root 110 1 0 Mar 16 root 284 1 0 Mar 16 root 226 1 0 Mar 16 root 240 1 0 Mar 16 root 230 1 0 Mar 16 root 249 1 0 Mar 16 root 259 1 0 Mar 16 root 319 1 0 Mar 16 root 274 1 0 Mar 16 root 292 1 0 Mar 16 root 321 318 0 Mar 16 rwilliam 340 323 0 Mar 16 root 325 1 0 Mar 16 rwilliam 408 407 0 Mar 16 rwilliam 342 340 0 Mar 16 rwilliam 388 378 0 Mar 16 rwilliam 412 1 0 Mar 16 rwilliam 378 342 0 Mar 16 rwilliam 389 388 0 Mar 16 rwilliam 407 389 0 Mar 16 rwilliam 19576 407 0 10:07:01 rwilliam 415 412 0 Mar 16 rwilliam 19949 19577 0 14:04:16 rwilliam 469 407 0 Mar 16 rwilliam 1061 1050 0 Mar 16 rwilliam 553 407 0 Mar 16 rwilliam 11510 1 0 Mar 22 root 20818 19577 1 18:01:46 rwilliam 20304 19949 0 15:31:45 rwilliam 1050 407 0 Mar 16 rwilliam 12251 1 0 Mar 22 rwilliam 19577 19576 0 10:07:02
TTY TIME CMD ? 0:01 sched ? 0:02 /etc/init ? 0:00 pageout ? 3:39 fsflush ? 145:37 /usr/openwin/bin/Xsun :0 -noban ? 0:00 /usr/sbin/inetd -s ? 0:00 /usr/lib/saf/sac -t 300 ? 0:00 /usr/sbin/rpcbind ? 0:00 /usr/sbin/kerbd ? 0:00 /usr/lib/netsvc/yp/ypbind ? 0:02 /usr/sbin/vold ? 0:00 /usr/lib/autofs/automountd ? 0:01 /usr/sbin/cron ? 0:00 /usr/sbin/syslogd ? 0:01 /usr/sbin/nscd ? 0:01 /usr/lib/lpsched console 0:00 /usr/lib/saf/ttymon -g -h -p olves ? 0:00 /usr/lib/utmpd ? 0:00 /usr/lib/sendmail -q15m ? 0:00 /usr/lib/saf/ttymon ? 0:00 /bin/ksh /usr/dt/config/Xsession ? 0:00 /usr/openwin/bin/fbconsole -d :0 ? 0:00 olwmslave ? 0:00 /bin/ksh /usr/dt/bin/Xsession ? 0:00 /bin/ksh /usr/dt/config/Xsession ?? 0:00 /usr/openwin/bin/cmdtool -Wp 0 0 ? 0:00 /bin/tcsh -c unsetenv _ PWD; ? 0:00 /bin/ksh /home/staff/csm/csstaff/ ? 0:18 olwm -syncpid 406 ?? 0:02 /usr/openwin/bin/xterm pts/3 0:00 /bin/tcsh pts/5 0:05 ghostview /tmp/tmp.ps ? 10:35 /usr/local/bin/emacs ? 0:00 (dns helper) ? 0:21 /usr/openwin/bin/filemgr ? 4:08 /opt/simeon/bin/simeon.orig -u pts/5 0:00 ps -Af pts/5 0:06 gs -sDEVICE=x11 -dNOPAUSE -dQUIET ? 14:39 /usr/local/netscape/netscape ? 0:17 /usr/local/Acrobat4/Reader/sparcs pts/5 0:01 tcsh
CSA ch 17 - p 240
sched: init: pageout: fsush: Xsun: inetd: sac: rpcbind: kerbd: ypbind: vold: automountd: cron: syslogd: nscd: lpsched: ttymon: utmpd: sendmail: ttymon: ksh: fbconsole: olmslave: ksh: ksh: cmdtool: tcsh: ksh: olwm: xterm: tcsh: ghostview; emacs: dns: lemgr: simeon: ps: gs: netscape: acroread: tcsh:
the O/S scheduler, notice the PID value, an impor tant process, following boot startup process from boot time, gets all the other Unix processes started virtual memory page handler updates the super block and ushes data to disk X-window ser ver Internet server daemon, provides remote services such as ftp, telnet, rlogin, talk port ser vices access controller address mapper for remote procedure calls source of kerberos unique keys, used for network user authentication NIS distributed password system le system (volume) management for CDROMs and oppy disk drives daemon to handle remote le system mount/unmout requests schedules tasks to run at particular times system message handler and router name ser vice cache daemon printer service scheduler monitors terminal por ts for activity user accounting daemon Internet mail server monitors terminal por ts for activity Korn shell user interface console window Open Look X-window manager second korn shell user interface third Korn shell user interface command-tool window handler a tenex shell user interface four th Korn shell Open Look Window Manager X terminal window a tenex shell user interface PostScript screen viewer the best editor! domain naming service for Internet name to IP number conversions drag n drop le manager, useful for oppy disks mail client this produced the process listing! ghostscript translator Netscape Navigator Web browser Adobe Acrobat reader for viewing pdf documents another user interface shell
CSA ch 17 - p 241
Task 1
Task 2
Task 3
Task 4
Stdout 1
Stderr 2
CSA ch 17 - p 242
WRITER Task produce a new item for Consumer Task WAIT(sem_space) WAIT(sem_free) place item on buffer queue SIGNAL(sem_free) SIGNAL(sem_data) END_WRITER READER Task WAIT(sem_data) WAIT(sem_free) take item from buffer queue SIGNAL(sem_free) SIGNAL(sem_space) process the item END_READER
CSA ch 17 - p 243
rob [262] rob [263] gcc kbdcnt.c rob [264] a.out & [1] 9539 rob [265] start counting kbd kills kill -44 9539 rob [266] signal 44 again, 1th time kill -44 9539 rob [267] signal 44 again, 2th time kill -44 9539 rob [268] signal 44 again, 3th time kill -44 9539 rob [269] signal 44 again, 4th time
send signal 44
Kill
signal 44
kbdcnt
CSA ch 17 - p 244
#include <stdio.h> #include <signal.h> #include <errno.h> #define PSIG 43 #define CSIG 42 /* check the value of NSIG in */ /* /usr/include/sys/signal.h */ /* before choosing the signal values */
int ccount = 0; int pcount = 0; char str[] = "error message "; void psigfunc(int s) { pcount++; signal(CSIG, psigfunc); } void csigfunc(int s) { ccount++; signal(PSIG, csigfunc); } main() { int ke, tpid, ppid, cpid; ppid = getpid(); cpid = fork(); /* spawn child process */ if ( cpid == -1) { printf("failed to fork\n"); exit(1); Continues }
CSA ch 17 - p 245
if (cpid == 0 ) { /* Child process executes here */ signal(PSIG, csigfunc); printf("Child started\n"); while (1) { pause(); printf("Child hit! count = %d\n",ccount); sleep(rand()%10); if( (kill(ppid, CSIG)) ) perror(str); } } else { /* Parent process continues execution from here */ signal(CSIG, psigfunc); printf("Parent started\n"); while (1) { sleep(rand()%10); if( (kill(cpid, PSIG)) ) perror(str); pause(); printf("Parent hit! count = %d\n",pcount); } }
PSIG 43
Parent Child
CSIG 42
CSA ch 17 - p 246
rob@olveston [40] trial & rob@olveston [41] ps PID TTY TIME CMD 451 pts/4 0:00 tcsh 469 pts/4 0:02 trial rob@olveston [42]
fork
rob@olveston [43] ps PID TTY TIME 451 pts/4 0:00 469 pts/4 0:02 472 pts/4 0:02 rob@olveston [44]
CSA ch 17 - p 247
rob [52] grep "ofthe" ls | egrep "ch_.." ch_01: symbiosis established ofthe hardware and soft ch_11:as little as it is, the start ofthe applicatio rob [53] rob [53] mail cat mail_list < message rob [54] rob[54] echo "There are who | wc -l users logged in at date" There are 12 users logged in at Tue June 20 20:23:55 BST 2000 rob [55]
CSA ch 17 - p 248
rob@olveston [154] ls /dev arp icmp audio ie audioctl ip bdoff ipd be ipdcm conslog ipdptp console isdn cua kbd diskette kmem diskette0 kstat dsk ksyms dtremote le dump llc1 ecpp0 log es logindmux fb m640 fb0 md fbs mem fd mouse fd0 null fd0a openprom fd0b partn fd0c printers hme profile rob@olveston [155] ptmajor ptmx pts ptyp0 ptyp1 ptyp2 ptyp3 ptyp4 ptyp5 ptyp6 ptyp7 ptyp8 ptyp9 ptypa ptypb ptypc ptypd ptype ptypf ptyq0 ptyq1 ptyq2 ptyq3 ptyq4 ptyq5 ptyq6 ptyq7 ptyq8 ptyq9 ptyqa ptyqb ptyqc ptyqd ptyqe ptyqf ptyr0 ptyr1 ptyr2 ptyr3 ptyr4 ptyr5 ptyr6 ptyr7 ptyr8 ptyr9 ptyra ptyrb ptyrc ptyrd ptyre ptyrf qe rawip rdiskette rdiskette0 rdsk rfd0 rfd0a rfd0b rfd0c rmt sad sehdlc sehdlc0 sehdlc1 sound sp spcic stderr stdin stdout swap syscon systty tcp term ticlts ticots ticotsord tnfctl tnfmap tty ttya ttyb ttyp0 ttyp1 ttyp2 ttyp3 ttyp4 ttyp5 ttyp6 ttyp7 ttyp8 ttyp9 ttypa ttypb ttypc ttypd ttype ttypf ttyq0 ttyq1 ttyq2 ttyq3 ttyq4 ttyq5 ttyq6 ttyq7 ttyq8 ttyq9 ttyqa ttyqb ttyqc ttyqd ttyqe ttyqf ttyr0 ttyr1 ttyr2 ttyr3 ttyr4 ttyr5 ttyr6 ttyr7 ttyr8 ttyr9 ttyra ttyrb ttyrc ttyrd ttyre ttyrf udp volctl winlock wscons zero
CSA ch 17 - p 249
rob@olveston [101] more /etc/termcap . . . . . xterm|vs100|xterm terminal emulator (X Window System):\ :AL=\E[%dL:DC=\E[%dP:DL=\E[%dM:DO=\E[%dB:IC=\E[%d@:U :al=\E[L:am:\ :bs:cd=\E[J:ce=\E[K:cl=\E[H\E[2J:cm=\E[%i%d;%dH:co#8 :cs=\E[%i%d;%dr:ct=\E[3k:\ :dc=\E[P:dl=\E[M:\ :im=\E[4h:ei=\E[4l:mi:\ :ho=\E[H:\ :is=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l:\ :rs=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l\E<:\ :k1=\EOP:k2=\EOQ:k3=\EOR:k4=\EOS:kb=H:kd=\EOB:ke=\E :kl=\EOD:km:kn#4:kr=\EOC:ks=\E[?1h\E=:ku=\EOA:\ :li#65:md=\E[1m:me=\E[m:mr=\E[7m:ms:nd=\E[C:pt:\ :sc=\E7:rc=\E8:sf=\n:so=\E[7m:se=\E[m:sr=\EM:\ :te=\E[2J\E[?47l\E8:ti=\E7\E[?47h:\ :up=\E[A:us=\E[4m:ue=\E[m:xn:
CSA ch 17 - p 250
Arg str bool bool str str str str str str str str str str
Padding (P*) (o) (P*) (P) (P*) (NP) (NP) (P) (P*) (P*) (P)
Function add new blank line terminal has automatic margins terminal can backspace with H clear to end of display clear to end of line clear screen and home cursor cursor move to row m, column n change scroll region to lines m thro n clear all tab stops delete character delete line enter insert mode home cursor
decimal number starting at 0 same as %2d same as %3d ASCII equiv adds x then taken as % if value is >x; then add y. no transmission reverse order of rows/columns origin is at 1,1 not 0,0 gives a single % XOR row and column (??) BCD format reverse coding
CSA ch 17 - p 251
CSA Ch 18
CSA Computers Fetch-execute cycle Hardware CPU Arithmetic Logic Unit Control Unit RISC features ARM processor Pentium Itanium Input-output Parallel communication Serial communication Networking Local Area Networks Ethernet USB Wide Area Networks Other Networks Point to point Visual output Memor y Memor y hierarchy Cache and main memory Disk ling Parallel processing Software Operating systems Unix MS Windows Tools Compilers and assemblers Subroutines and stacks WIMPs Users viewpoints Hardware engineer HLL programmer Systems administrator Systems programmer
CSA ch 18 - p 252
User Mode
Kernel Mode
NT Kernel HAL Hardware Abstraction Layer Hardware
Windows-NT/XP structure
Applications Winr32 Subsys OS/2 Subsys Posix Subsys DOS Subsys
CSA ch 18 - p 253
CSA ch 18 - p 254
HKEY_CURRENT_CONFIG holds the current hardware conguration, where options exist HKEY_CLASSES_ROOT HKEY_USERS HKEY_CURRENT_USER holds document types, le associations, shell interface holds login users software preferences and desktop conguration holds copies of the preferences of the curent user.
CSA ch 18 - p 255
CSA ch 18 - p 256
CSA ch 18 - p 257
CSA Ch 19
CSA Computers Fetch-execute cycle Hardware CPU Arithmetic Logic Unit Control Unit RISC features ARM processor Pentium Itanium Input-output Parallel communication Serial communication Networking Local Area Networks Ethernet USB Wide Area Networks Other Networks Point to point Visual output Memor y Memor y hierarchy Cache and main memory Disk ling Parallel processing Software Operating systems Unix MS Windows Tools Compilers and assemblers Subroutines and stacks WIMPs Users viewpoints Hardware engineer HLL programmer Systems administrator Systems programmer
CSA ch 19 - p 258
CSA ch 19 - p 259
CSA ch 19 - p 260
Cylinder 0 0 5 3 1 6 7
Cylinder 1 5 7
Alternative layouts for blocks 1, 2, 3, 4, 5 & 7 to reduce access times (Head Movement Delays)
CSA ch 19 - p 261
Signature
AA55H Partition 1 Partition 2 Partition 3 Partition 4 Program to check Partition Table and transfer to Boot Par tition Sector Size star t bytes 00H 01H 04H 05H 08H OCH Content Head, Cylinder, Sector
H7 H6 H5 H4 H3 H2 H1 H0 C9 C8 S6 S5 S4 S3 S2 S1 S0 C7 C6 C5 C4 C3 C2 C1 C0
Partition Table
Code
1 Boot ag 3 Star t of partition 1 System Flag 3 End of Par tition 4 Star t of Sector 4 # sectors
Boot Flag - 00H Inactive (nonbootable), 80H Active (bootable) System Flag -01H FAT-12 04H FAT-16 05H Extended DOS partition 08H AIX 0AH OS/2 0BH FAT-32 DBH CP/M (!) 83H Linux
OS boot loader program # Hidden Sectors # Heads # Sectors / Track # sectors / FAT media byte (F8H) # logical Sectors # Root DIR entries # FATS # Boot Sectors # Sectors / Cluster # Bytes / sector OEM Name/ID jmp to loader 2 byte 2 byte 2 byte 2 byte 1 byte 2 byte 2 byte 1 byte 2 byte 1 byte 2 byte 8 byte 3 byte
CSA ch 19 - p 262
le name le type owner id permissions le size create date disk address disk block
rob@milly [20]/usr/sbin/mount / on /dev/dsk/c0t0d0s0 read/write/setuid on Mon Jul 19 08:12:44 2000 /usr on /dev/dsk/c0t0d0s3 read/write/setuid on Mon Jul 19 08:12:44 2000 /proc on /proc read/write/setuid on Mon Jul 19 08:12:44 2000 /dev/fd on fd read/write/setuid on Mon Jul 19 08:12:44 2000 /var on /dev/dsk/c0t0d0s4 read/write/setuid on Mon Jul 19 08:12:44 2000 /cache/cache1 on /dev/dsk/c0t0d0s7 setuid/read/write on Mon Jul 19 08:13:4 /cache/cache2 on /dev/dsk/c0t1d0s7 setuid/read/write on Mon Jul 19 08:13:4 /cache/cache3 on /dev/dsk/c0t2d0s7 setuid/read/write on Mon Jul 19 08:13:4 /cache/cache4 on /dev/dsk/c0t3d0s7 setuid/read/write on Mon Jul 19 08:13:4 /cache/cache5 on /dev/dsk/c0t10d0s7 setuid/read/write on Mon Jul 19 08:13: /opt on /dev/dsk/c0t0d0s6 setuid/read/write on Mon Jul 19 08:13:45 2000 /tmp on /dev/dsk/c0t0d0s5 setuid/read/write on Mon Jul 19 08:13:45 2000 /tftpboot on /dev/dsk/c0t1d0s0 setuid/read/write on Mon Jul 19 08:13:45 19 /home/student/csm/BSc/CRTS/2 on /dev/dsk/c0t1d0s3 nosuid/read/write/quota /home/student/csm/BSc/other on /dev/dsk/c0t1d0s4 nosuid/read/write/quota on /home/student/csm/BA/other on /dev/dsk/c0t1d0s5 nosuid/read/write/quota on /home/student/csm/PhD on /dev/dsk/c0t1d0s6 nosuid/read/write/quota on Mon /home/student/csm/BSc/CRTS/2p on /dev/dsk/c0t2d0s3 nosuid/read/write/quota . . .
CSA ch 19 - p 263
le name TEST
le ext DAT
le attr
reser v
10 9 8
FFFFH
10
4 bytes
7 6 5 4 3
6 10
2 1 0
FAT
CSA ch 19 - p 264
struct stat { dev_t long ino_t mode_t nlink_t uid_t gid_t dev_t long off_t long timestruc_t timestruc_t timestruc_t long long char long }; st_dev; st_pad1[3]; st_ino; st_mode; st_nlink; st_uid; st_gid; st_rdev; st_pad2[2]; st_size; st_pad3; st_atime; st_mtime; st_ctime; st_blksize; /* file size in bytes */ /* reserve for future off_t expansion */ /* last access time */ /* last write time (modification) */ /* last status change time */ /* device holding the relevant directory */ /* reserve for dev expansion, */ /* inode number */ /* number of active links to the file */ /* file owners ID */ /* designated group id */
Boot Block
Super Block
owner uid gid of owner le type rwx access modes time of last access time modied time of inode change le size
inode Blocks
Data Blocks
direct 1 direct 2 direct 3 direct 4 direct 5 direct 6 direct 7 direct 8 direct 9 direct 10 indirect double indirect triple indirect
CSA ch 19 - p 265
principal le inode dir inode 0 inodp 1 inodp 2 inodp 3 inodp 4 inodp 5 inodp 6 inodp 7 inodp 8 inodp 9 inodp 10 inodp 11 inodp 12 Iinode 13 DIinode 14 TIinode
Data Block Data Block Data Block index block 0 dp 1 dp 2 dp 3 dp 4 dp 5 dp 994 995 996 997 998 999 dp dp dp dp dp dp
CSA ch 19 - p 266
/ root directory name inodp bin name inodp etc name inodp usr name inodp dev name inodp lib name inodp tmp name inodp sbin name local inodp name home inodp name inodp pub
Cong dir inode 0 inodp 1 inodp 2 inodp 3 inodp 4 inodp 5 inodp 6 inodp 7 inodp 8 inodp 9 inodp 10 inodp 11 inodp 12 Iinode 13 DIinode 14 TIinode /stuff dir inode 0 inodp 1 inodp 2 inodp 3 inodp 4 inodp 5 inodp 6 inodp 7 inodp 8 inodp 9 inodp 10 inodp 11 inodp 12 Iinode 13 DIinode 14 TIinode rusers directory
name name name name name name name name name name inodp inodp inodp inodp inodp inodp inodp inodp inodp inodp
/etc dir inode 0 inodp 1 inodp 2 inodp 3 inodp 4 inodp 5 inodp 6 inodp 7 inodp 8 inodp 9 inodp 10 inodp 11 inodp 12 Iinode 13 DIinode 14 TIinode uucp director y
name name name name name name name name name name inodp inodp inodp inodp inodp inodp inodp inodp inodp inodp
CSA ch 19 - p 267
MTF Header 1 2 3 4 5 6 7 8 9 10 fp fp fp fp fp fp fp fp fp fp
Name
Cluster Pointers
Write/ delete
Execute/ attach
CSA ch 19 - p 268
strip 1 strip 2 strip 3 strip 4 strip 5 strip 6 strip 7 strip 8 strip 9 strip 10
RAID 0
1 2 3 4 5
Data Block
byte 1 byte 2 byte 3 byte 4 CRC
RAID 2/3
Data Block
strip 1 strip 2 strip 3 strip 4 chksum strip 5 strip 6 strip 7 strip 8 chksum
RAID 4
1 2 3 4 5
CSA ch 19 - p 269
rob@olveston [63] ls -al -rwx-----1 rob csstaff 280 -rwx-----1 rob csstaff 48 -rwx-----1 rob csstaff 229 -rwx-----1 rob csstaff 25007 -rwx-----1 rob csstaff 251 -rwx-----1 rob csstaff 243 rob@olveston [64] chmod 666 unzip rob@olveston [65] ls -al unzip -rw-rw-rw1 rob csstaff 25007 rob@olveston [66] chmod 000 unzipit rob@olveston [67] ./unzipit ./unziput: permission denied. rob@olveston [68] ls -al unzip ---------1 rob csstaff 25007 rob@olveston [69] chmod 100 unzipit rob@olveston [70] ./unzipit rob@olveston [71] rob@olveston [71] chmod 711 unzipit rob@olveston [72] ls -al unzipit -rwx--x--x 1 rob csstaff 25007 rob@olveston [73]
1999 unzipit
Apr
1999 unzipit
Apr
1999 unzipit
CSA ch 19 - p 270
CSA Ch 20
CSA Computers Fetch-execute cycle Hardware CPU Arithmetic Logic Unit Control Unit RISC features ARM processor Pentium Itanium Input-output Parallel communication Serial communication Networking Local Area Networks Ethernet USB Wide Area Networks Other Networks Point to point Visual output Memor y Memor y hierarchy Cache and main memory Disk ling Parallel processing Software Operating systems Unix MS Windows Tools Compilers and assemblers Subroutines and stacks WIMPs Users viewpoints Hardware engineer HLL programmer Systems administrator Systems programmer
CSA ch 20 - p 271
CSA ch 20 - p 272
Resolution 640 x 480 640 x 480 800 x 600 800 x 600 1024 x 768 1024 x 768 1152 x 864 1280 x 1024 1280 x 1024
Horizontal scan rate kHz 31.5 37.8 46.9 53.7 60.0 68.8 77.6 80.0 91.2
light polarizing lter back plane electrode liquid crystal polarizing lter
0 1
Control signals
CSA ch 20 - p 273
CSA ch 20 - p 274
.PS define Driver { [line right 0.3 down 0.1 line left 0.3 down 0.1; line up 0.2]}
Base: box wid 6 ht 2 invis line up 2 from Base.sw line up 2 from Base.sw+0.4,0 line right 0.4 from Base.w+0,0.4 line right 0.4 from Base.w-0,0.4 """""image""data" below circle rad 0.02 at Base.w+0.2,0 line up 0.5 from last circle; arrow right 2 "color#""" above Palet: box wid 1.2 ht 1 ibox wid 1.2 ht 0.2 with .n at Palet.n "RGB Palette" ibox wid 1.2 ht 0.2 with .n at last box.s "table" ibox wid 1.2 ht 0.2 with .n at last box.s "R G B" {move up 0.1; line left 1.2} {move down 0.1 line left 0.4; {line up 0.2}; line left 0.4 {line up 0.2}; line left 0.4} line down 0.7 from Palet.s-0.3,0 arrow right 1.2 "8 bits" below; [Driver] line right 0.2 from last [].e then up 0.25 then right 0.2 box wid 0.6 ht 0.3 invis with .n at last [].s "DACs" line down 0.1 from Palet.s+0.3,0 arrow right 0.6 "8 bits" below; [Driver] line right 0.2 from last [].e; line down 0.25; line right 0.2 line down 0.4 from Palet.s arrow right 0.9 "8 bits" below; [Driver] line right 0.4 from last [].e then up 0.07 then right 0.4 then righ line down 0.6 "CRT " rjust line left 0.5 up 0.2; line left 0.4; line up 0.07 box wid 0.8 ht 0.2 at Base.w+1.1,0.2 "image base" box wid 0.8 ht 0.2 with .n at last box.s-0,0.1 "Y X" {arrow <- right 0.2 from last box.e move down 0.1 for i=1 to 2 do { line right 0.1 then up 0.2 then right 0.1 then down 0.2 } line right 0.1 } line from last box.n to last box.s arrow -> left 0.2 from last box.w box wid 0.6 ht 0.4 invis with .n at last box.s "image pointer" "23" at Palet.nw+0,0.2;"0" at Palet.ne+0,0.2 box wid 0.5 ht 0.3 invis "Memory" with .nw at Base.sw .PE
CSA ch 20 - p 275
<?xml version="1.0" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg width="100%" height="100%" version="1.1" xmlns="http://www.w3.org/2000/svg"> <rect x="250" y="50" rx="20" ry="20" width="150" height="100" style="fill:white;stroke:black;stroke-width:5;opacity:0.5"/> <rect x="250" y="200" rx="20" ry="20" width="150" height="100" style="fill:white;stroke:black;stroke-width:5;opacity:0.5"/> <rect x="50" y="200" rx="20" ry="20" width="150" height="100" style="fill:white;stroke:black;stroke-width:5;opacity:0.5"/> <rect x="450" y="200" rx="20" ry="20" width="150" height="100" style="fill:white;stroke:black;stroke-width:5;opacity:0.5"/> <rect x="250" y="350" rx="20" ry="20" width="150" height="100" style="fill:white;stroke:black;stroke-width:5;opacity:0.5"/> <rect x="250" y="500" rx="20" ry="20" width="150" height="100" style="fill:white;stroke:black;stroke-width:5;opacity:0.5"/> <rect x="50" y="500" rx="20" ry="20" width="150" height="100" style="fill:white;stroke:black;stroke-width:5;opacity:0.5"/> <rect x="450" y="500" rx="20" ry="20" width="150" height="100" style="fill:white;stroke:black;stroke-width:5;opacity:0.5"/> <line <line <line <line <line <line <line x1="330" x1="330" x1="330" x1="330" x1="330" x1="330" x1="330" y1="150" y1="150" y1="150" y1="300" y1="450" y1="450" y1="450" x="280" x="290" x="100" x="460" x="410" x2="330" x2="125" x2="525" x2="330" x2="330" x2="525" x2="125" y2="200" y2="200" y2="200" y2="350" y2="500" y2="500" y2="500" stroke="#000000" stroke="#000000" stroke="#000000" stroke="#000000" stroke="#000000" stroke="#000000" stroke="#000000" stroke-width="2" stroke-width="2" stroke-width="2" stroke-width="2" stroke-width="2" stroke-width="2" stroke-width="2" /> /> /> /> /> /> />
<text id="S1" <text id="S2" <text id="S3" <text id="S4" <text id="S5" </svg>
font-size="25"> System </text> font-size="25"> Body </text> font-size="25"> Init </text> font-size="25"> Closedown </text> font-size="50"> * </text>
CSA ch 20 - p 276
HM64265/25
HM64265/25
Intel 740
Text only mode offered by original 8088 PC First mono graphics card 720 x 348
rst colour (4) graphics card from IBM 320 x 200 double horizontal resolution if limited to mono 16 colour graphics EGA compatible 16 colour high resolution 256 colours 256k colours (18 bit/pixel) 256 colours (8 bits/pixel) 24 bit true colour (3 bytes/pixel) 32768 colours (15 bits) 640 x 350
SVGA XGA
CSA ch 20 - p 277
1 11
Pin # 1 2 3 4 5 6 7 8 C1 C2 C3 C4 C5
Signal Name TMDS Data2TMDS Data2+ TMDS Data2/4 Shield TMDS Data4TMDS Data4+ DDC Clock [SCL] DDC Data [SDA] Analog Ver t Sync Analog Red Analog Green Analog Blue Analog Horiz Sync Analog GND Return
Pin # 9 10 11 12 13 14 15 16
Signal Name TMDS Data1TMDS Data1+ TMDS Data1/3 Shield TMDS Data3TMDS Data3+ +5 V Power Ground Hot Plug Detect
Pin # 17 18 19 20 21 22 23 24
Signal Name TMDS Data0TMDS Data0+ TMDS Data0/5 Shield TMDS Data5TMDS Data5+ TMDS Clock Shield TMDS Clock + TMDS Clock -
CSA ch 20 - p 278
23
B
8 bits 8 bits 8 bits
CRT DACs
Display Memor y
8 bit colour # image pointer row column Y X image data image base reg
04 03 02 01 00
8 bits
8 bits 8 bits
CRT
Display Memory
DACs
CSA ch 20 - p 279
60
0
Field Clock
V Sync
row 3
60ms
Raster control
row 2
Display memor y
19
row 1
CSA ch 20 - p 280
electron spray Erase lamp Cleaner Scanning head Hopper Paper Tray Toner paper feed Motor
CPU IRQ
I/O
Laser Printer
For a page represented as a 600 dpi image: single A4 page image = 11x 7x 600x 600 = 3. 5Mbytes 8
The same page may be represented by far less data if it is ASCII coded: Maximum number of characters on an A4 page = 60x 100 = 6000char The number of characters on a WP page is about 2500, 2.5 Kbytes of ASCII data. Thus, the compressing ratio would be: compression ratio = 2500 = 0. 0007 3500000
Such a size reduction is certainly wor th achieving but OCR software has only recently been improved enough to give acceptably fast and accurate performance.
CSA ch 20 - p 281
newpath 270 360 moveto 0 72 rlineto 72 0 rlineto 0 -72 rlineto closepath 4 setlinewidth stroke newpath 272 362 moveto 0 68 rlineto 68 0 rlineto 0 -68 rlineto closepath .8 setgray ll /Times-Roman ndfont 24 scalefont setfont 280 400 moveto 0 setgray (hello!) show showpage
hello!
**
emacs test1.ps
CSA ch 20 - p 282
newpath 1 0 0 setrgbcolor 200 200 moveto 0 160 rlineto 160 0 rlineto 0 -160 rlineto closepath ll newpath 360 280 moveto -80 0 rlineto 80 -40 rlineto closepath 1 setgray ll newpath 380 280 105 180 135 arcn 48 0 rlineto 0 -40 rlineto closepath 1 setgray ll /Helvetica ndfont 68 scalefont setfont 1 setgray 255 200 translate 90 rotate 0 0 moveto (UWE) show newpath 80 -130 120 0 180 arc 1 setgray 7 setlinewidth stroke 0 0 moveto -90 rotate /Helvetica ndfont 42 scalefont setfont 1 0 0 setrgbcolor -60 -40 rmoveto (BRISTOL) show showpage
**
emacs uwe_pacman.ps
UWE
BRISTOL
CSA ch 20 - p 283
rob [57] cat header ch_16 | groff -t -e -p -fH > ch_16.ps rob [58] gs -dNOPAUSE -dBATCH -r1200 -sDEVICE=pdfwrite -sOutputFile=ch_16.pdf ch_16.ps .... rob [57] ls -al ch_16* -rw------- 1 rwilliam csstaff -rwx------ 1 rwilliam csstaff 52114 Jul 1 08:42 ch_16 42253 Jun 28 13:26 ch_16.asc
-rw------- 1 rwilliam csstaff 840398 Jul 1 08:44 ch_16.pdf -rw------- 1 rwilliam csstaff 1212385 Jul 1 08:43 ch_16.ps -rw------- 1 rwilliam csstaff -rw------- 1 rwilliam csstaff -rw------- 1 rwilliam csstaff .... rob [58] acroread ch_l6.pdf & .... rob [59] ghostview ch_16.ps & .... rob [60] 22093 Feb 24 11:07 ch_16d 16437 Nov 5 1998 ch_16d 23975 Jun 16 16:42 ch_16
CSA ch 20 - p 284
%PDF-1.0 1 0 obj << /Type /Catalog /Pages 3 0 R /Outlines 2 0 R >> endobj 6 0 obj [/PDF /Text] endobj
7 0 obj << /Type /Font 2 0 obj /Subtype /Type1 << /Name /F1 /Type /Outlines /BaseFont /Helvetica Count 0 /Encoding /MacRomanEncoding >> >> endobj endobj xref 3 0 obj 0 8 << 0000000000 65535 f /Type /Pages 0000000009 00000 n /Count 1 0000000074 00000 n /Kids [4 0 R] 0000000120 00000 n >> 0000000179 00000 n endobj 0000000322 00000 n 0000000415 00000 n 4 0 obj 0000000445 00000 n << trailer /Type /Page << /Parent 3 0 R /Size 8 /Resources <</Font<</F1 7 0 R>>/ProcSet 6 0 /Root 1 0 R R>> /MediaBox [0 0 612 792] >> /Contents 5 0 R startxref >> 553 endobj %%EOF 5 0 obj << /Lengtb 44 >> stream BT /F1 72 Tf 100 50 Td (Hello World!) Tj ET endstream endobj
CSA ch 20 - p 285
CSA ch 20 - p 286
HyperBase
CSA ch 20 - p 287
Vir tual Device Inferface (GDI) Bitmaps, Icons & Metales Creating Windows Operating Windows On-screen Menu handling Dealing with Mouse and Keyboard Events Handling Dialog Boxes Timer Events Threads and Process Scheduling Exception Messages Free Memory Management Device handling Printing and Text output File Management Data interchange through Clipboard OLE / DDE data interchange System Parameter Registry Management System Information DLL Management functions Network Access Routines Passing and processing Messages Audio data management
CSA ch 20 - p 288
#include <windows.h> int WINAPI WinMain(HINSTANCE a, HINSTANCE b, LPSTR c, int d) { MessageBox(NULL, "Hello Worle!", "WSM", MB_OK); return NULL; }
CSA ch 20 - p 289
X-Windows Programming
80 63 0 127 0
mm7 mm6 mm5 mm4 mm3 mm2 mm1 mm0 f/p mmx
CSA ch 20 - p 290
CSA Ch 21
CSA Computers Fetch-execute cycle Hardware CPU Arithmetic Logic Unit Control Unit RISC features ARM processor Pentium Itanium Input-output Parallel communication Serial communication Networking Local Area Networks Ethernet USB Wide Area Networks Other Networks Point to point Visual output Memor y Memor y hierarchy Cache and main memory Disk ling Parallel processing Software Operating systems Unix MS Windows Tools Compilers and assemblers Subroutines and stacks WIMPs Users viewpoints Hardware engineer HLL programmer Systems administrator Systems programmer
CSA ch 21 - p 291
Operating System
CU Microcode
Functional hierarchy
CSA ch 21 - p 292
1. Single length instruction codes 2. Single clock cycle execution period 3. Limited arithmetical complexity supported 4. Extensive supply of CPU registers 5. Limited repetoire of machine instructions 6. Only straightforward addressing modes supported 7. Hardware support for procedure handling 8. No structured data types recognised 9. Compiler supplied to support the architecture 10. Hardware CU, pipelined decoding 11. Simplied interrupt facilities
100
10
i8086
i386
1 1970
i8080
1980
1985
1990
1995
2000
CSA ch 21 - p 293
Stack passing Parameters are pushed up onto the stack before transferring control (jumping) to the subroutine. The subroutine code shares the same stack and can access the parameters through the stack or frame pointer. Copies of VALUE parameters are simply pushed onto the stack, while reference, VAR, parameters are 32 bit addresses pointing back at data. Stack frame setup overheads, and access times to non-local variables within scope are an issue.
system stack
Main Memor y
Register passing Using CPU registers to hold the parameters is the fastest method, but limited by the number and size of registers available. Compilers select this technique only if a couple of simple (integer, char) variables are to be passed IN, and for the single OUT return value from functions.
CPU registers
Register windows This is a specialised stack technique used by SPARC processors to reduce the amount of stack PUSHing and POPping. By physically overlapping the stack frames for adjacent procedures, some of the local variables can be visible as parameters with no data copying. To fur ther speed up the process, SPARC CPUs have fast stack caches. Parameter blocks For machines without stacks, the problem of where to save the return address is solved by the CALL instruction inserting the return address at the top of the procedure code before transferring control. The parameters are cunningly inserted in a block immediately after the CALL instruction, thus giving the procedure access by using the return address as a pointer. Global access Fortran and BASIC would rely on global data blocks visible to all code. This system of memor y parameter blocks has been reinstituted for graphics and Windows programming, where the number of parameters is so great that little else could be suggested.
CSA ch 21 - p 294
Fetch
Decode
LD/ST
IF
ID
INT
RO
WB
FP
CSA ch 21 - p 295
Description RAW, read after write WAR, write after read WAW, write after write
Example MOV EAX,10 ADD EBX,EAX MOV EBX,EAX MOV EAX,10 MUL 100 ADD EAX,10 CMP AL,q JZ exit oating-point arithmetic
Control
the outcome of a previous instruction is essential for an instruction to complete limited availability of hardware resources
Resource
unit free
CSA ch 21 - p 296
Register File
ALU A Pipeline A
ALU B Pipeline B
ALU C Pipeline C
CSA ch 21 - p 297
Mapping Table
Valid Flag 0 1 2 3 4 5 1 6 7 8 1 9 Index
Register File
r5 r6 r7 r8 r9 r10 r11 r12 r13 r14
8 3
Register renaming
CSA ch 21 - p 298
Example core ARM1 ARM2 ARM3 ARM6 & ARM7DI ARM3M StrongArm ARM7TDMI ARM9TDMI
Description Original processor, 26 bit address, coprocessor for Beeb 32 bit multiplier, coprocessor included Acorn Archemedies/A3000 on-chip cache, semaphore support with swap instruction 32 bit address, CPSR/SPSR, MMU rst macro-cell product. enhanced multiply with 64 bit result LD/ST for 8/16 bit values, system mode iPAQ PDA, Compressed Thumb instruction set, MULA used for many mobile handsets
Pipeline 3 3 3 3 3 5 3 5 7
v5 v5TE v5TEJ v6
XScale ARM9E & ARM10E ARM7EJ & ARM926EJ ARM11 better MUL, extra DSP instcns Java option
5 5 8
CSA ch 21 - p 299
User & system r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 r13/sp r14 /lr r15/pc cpsr spsr_q spsr_irq spsr_svc spsr_undef spsr_abt Fast interrupt request r8_q r9_q r10_q r11_q r12_q r13_q r14_q Interrupt request r13_irq r14_irq Super visor trap r13_svc r14_svc Undened exception r13_undef r14_undef Abor t error r13_abt r14_abt
CSA ch 21 - p 300
11
7 6 5 4 3
shift-size sh/rot 0
11
Rindex
0
0 ldr/str
31 28 27 26 25 24 23 22 21 20 19 16 15
OR
condition
01 # P U B W L
Rn
Rd
offset eld
source/destination register base register load or store operation Rindex write back for auto indexing word or unsigned byte data backwards/forwards, sign bit for displacement pre/post index, bump pointer before or after data movement offset type, immediate or register predicate execution condition (Z, C, N, V)
N Z C V Q
F t
SVC
Jazelle Saturated Overow Carr y out Zero value Negative value, msb==1
CSA ch 21 - p 301
Opcode [31-28] 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111
Mnm EQ NE CS CC MI PL VS VC HI LS GE LT GT LE AL NV
Meaning equal values not equal carr y set carr y clear negative value positive value overow no overow unsign higher unsign lower greater or equal less than greater than less or equal always never use
Flag Z=1 Z=0 C=1 C=0 N=1 N=0 V=1 V=0 C=1 && Z=0 C=0 || Z=1 N=V N!=V Z=0 && N=V Z=1 || N!=V
CSA ch 21 - p 302
11
8 7
OR
7 6 5 4 3
shift-size sh/rot 0
11
Rindex
0
OR Rshift
8 4 6 5 4 3
0 sh/rot 1
Rindex
0
12 11
condition
00 #
opcode
Rn
Rd
operand 2
destination register operand register set condition status ags arithmetic/logic function selector operand 2 type predicate execution condition (Z, C, N, V)
opcode opcode 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111
Mnm and eor sub rsb add adc sbc rsc tst teq cmp cmn orr mov bic mvn
Meaning logical bit-wise AND logical bit-wise XOR subtract reverse sub arithmetic add add with carry in subtract with carry reverse sbc test test equal compare negated comp logical bit-wise OR copy register data bit clear negated mov
sh/rot Effect sh/rot Rd = Rn && Op2 00 Rd = Rn Op2 01 Rd = Rn - Op2 10 Rd = Op2- Rn 11 Rd = Rn + Op2 Rd = Rn+Op2+C Rd = Rn-Op2+C-1 Rd = Op2-Rn+C-1 Rn && Op2 RN Op2 Rn - Op2 Rn + Op2 Rd = Rn || Op2 Rd = Op2 Rd = Rn $$ Op2 Rd = Op2
Effect Rn, LSL #shift-size Rn, LSR #shift-size Rn, ASR #shift-size Rn, ASL #shift-size
CSA ch 21 - p 303
The HP iPAQ hx4700 Pocket PC, with XScale PXA 270 processor
HP iPAQ hx2400 PCB. The 420 MHz XScale CPU is shrouded by emission reduction foil
CSA Rob Williams Pearson Education (c) 2006
CSA ch 21 - p 304
Intel PXA270 624MHz processor 64 MB Mobile SDRAM 128 MB Flash: 2 x 64 Mbyte (Intel RD48F4400L0zb0) Up to 135 Mbyte of memory is available for user applications 100 mm transective TFT VGA 64K color display (480x640) Graphics controller (ATI Mobileon W3220) Touch screen (Texas Instruments TSC2046 /SPI) Touchpad (Synaptics NavPoint module /SPI), Removable & rechargeable Lithium-Ion battery (1800 mAh) Secure Digital (SDIO) slot Compact Flash I & II (CF) slot IrDA por t (Exar XR16L580IL 16550-compatible) WiFi LAN 802.11b capability (Texas Instruments TNETW1100B) Bluetooth (Texas Instruments BRF6150USB) RS232 port, 16550 compatible (PXA270) Integrated microphone, speaker and stereo headset jack Audio codec (AK4641) USB (PXA270) Weight: 186.7 g
CSA ch 21 - p 305
Bank 3 3 3 3 3 2 2 2 2 1 1 0 0 0 0 0 0
Sel line
MBytes 384 128 128 128 128 128 256 256 256 256 768 128 128 256 256 128 128 128 128
Physical Address Reserved zeros DRAM bank 3 DRAM bank 2 DRAM bank 1 DRAM bank 0 LCD & DMA registers Expansion & memor y SCM registers PM registers Reserved Flash/SRAM bank 5 Flash/SRAM bank 4 PCMIA socket 1 PCMIA socket 0 Flash/SRAM bank 3 Flash/SRAM bank 2 Flash/SRAM bank 1 Flash bank 0 FFFF_FFFFH
0000_0000H
CSA ch 21 - p 306
next PC
Pipeline 16 KByte
incr PC op code
+4
I-cache
branch addr
+disp
Register File
immediate elds
IR-1
decoder
+4
shifter
8 KByte
LD/ST address
D-cache
rotate
CSA ch 21 - p 307
oscil oscil
PLL PLL
IMMU DMMU
JTAG i/f
read buff
LCD control
Bridge
DMA control
A -A 0 25 D0-D31
CSA ch 21 - p 308
31 23
OUT
7
LOCAL OUT
0
GLOBAL
cwp
IN
LOCAL OUT
IN
LOCAL OUT
CPU registers
IN
LOCAL
Save
IN system stack
Restore
Main Memory
CSA ch 21 - p 309
CSA Ch 22
CSA Computers Fetch-execute cycle Hardware CPU Arithmetic Logic Unit Control Unit RISC features ARM processor Pentium Itanium Input-output Parallel communication Serial communication Networking Local Area Networks Ethernet USB Wide Area Networks Other Networks Point to point Visual output Memor y Memor y hierarchy Cache and main memory Disk ling Parallel processing Software Operating systems Unix MS Windows Tools Compilers and assemblers Subroutines and stacks WIMPs Users viewpoints Hardware engineer HLL programmer Systems administrator Systems programmer
CSA ch 22 - p 310
16 kbyte, 64 byte line 16 kbyte, 64 byte line, write-through 256 kbyte, 128 byte line, write-back 3-9 Mbyte, 128 byte line, write-back <1 Pbyte (264) 1.66 GHz 400 MHz, 128 bits wide 100 watts
CSA ch 22 - p 311
127
97 86
46 45
5 4
Instr 2
Instr 1
Instr 0
Templ
CSA ch 22 - p 312
81
63
IP
Application Regs
63
KR0 KR7 RSC BSP BSPstore RNAT FCR EFLAG CSD SSD CFLG FSR FIR FDR CCV UNAT FPSR ITC PFS LC EC
0 ar0
Predicate Flags
63 0
63 br0 gr125 gr126 gr127 br1 br2 br3 br4 37 br5 0 br6 br7
Branch Regs
CFM
ar127
CSA ch 22 - p 313
title gp
class constant special scratch preserved scratch special special scratch automatic automatic automatic automatic automatic
usage reads as zero global data pointer used with addl return values stack pointer thread pointer function params input registers local registers output registers rotating registers (groups of 8)
CSA ch 22 - p 314
Type A I M B F X
ALU operations, arithmetic on integers and logic multimedia, integer shifts, special register ops memory load/store operations branching, jumping and returning oating-point operations special instructions
CSA ch 22 - p 315
Template 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1F
Slot0 M-unit M-unit M-unit M-unit M-unit M-unit M-unit M-unit M-unit || M-unit || M-unit M-unit M-unit M-unit M-unit M-unit M-unit M-unit B-unit B-unit M-unit M-unit M-unit M-unit M-unit
Slot1 I-unit I-unit I-unit || I-unit || L-unit L-unit M-unit M-unit M-unit M-unit F-unit F-unit M-unit M-unit I-unit I-unit B-unit B-unit B-unit B-unit M-unit M-unit F-unit F-unit I-unit
Slot2 I-unit I-unit || I-unit I-unit || X-unit X-unit || I-unit I-unit || I-unit I-unit I-unit I-unit || F-unit F-unit || B-unit B-unit || B-unit B-unit || B-unit B-unit || B-unit B-unit || B-unit B-unit || I-unit
Template eld encoding for Itanium 2, showing the positions of inter-instruction stops
CSA ch 22 - p 316
#include <stdio.h> /* selection_sort.c A good basic sort routine. Works by scanning up through the array finding the "smallest" item, which it then swaps with the item at the start of the scan. It then scans again, starting at the second position, looking for the next smallest item... and so on. */ int selectionsort(char *pc[ ], int n ) { int min, i, j, k; char *pctemp; for (i = 0; i < n; i++) { min = i; for(j = i+1; j < n; j++) if (strcmp(pc[j], pc[min]) > 0) min = j; pctemp = pc[min]; pc[min] = pc[i]; pc[i] = pctemp; for(k=0; k<n; k++) printf("%s ", pc[k]); printf("\n"); } return 0; }
void main() { int i; char *names[7], *testset[7] = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunda for(i=0; i < 7; i++) names[i] = testset[i]; printf("\n\nSelection Sort\n"); i = selectionsort(names, 7); }
CSA ch 22 - p 317
.file "selection_sort.c" .pred.safe_across_calls p1-p5,p16-p63 .section .rodata .align 8 .LC0: stringz "%s " .align 8 .LC1: stringz "\n" .text .align 16 .global selectionsort# .proc selectionsort# selectionsort: .prologue 14, 34 .save ar.pfs, r35 alloc r35 = ar.pfs, 2, 4, 2, 0 .vframe r36 mov r36 = r12 adds r12 = -48, r12 mov r37 = r1 .save rp, r34 mov r34 = b0 .body ;; adds r14 = -32, r36 ;; st8 [r14] = r32 adds r14 = -24, r36 ;; st4 [r14] = r33 adds r14 = -16, r36 ;; st4 [r14] = r0 .L2: ; FOR i loop adds r14 = -16, r36 adds r15 = -24, r36 ;; ld4 r16 = [r14] ld4 r14 = [r15] ;; cmp4.gt p6, p7 = r14, r16 (p6) br.cond.dptk .L5 br .L3 ; Exit FOR i loop ;; .L5: adds r15 = -20, r36 adds r14 = -16, r36 ;; ld4 r14 = [r14] ;; st4 [r15] = r14 adds r15 = -12, r36 adds r14 = -16, r36 ; get ipntr ;; ld4 r14 = [r14] ; ;; adds r14 = 1, r14 ; incr i ;; st4 [r15] = r14 ;
; FOR j loop adds r14 = -12, r36 adds r15 = -24, r36 ;; ld4 r16 = [r14] ; get npntr ld4 r14 = [r15] ; get jpntr ;; cmp4.gt p6, p7 = r14, r16 (p6) br.cond.dptk .L9 br .L7 ; Exit j FOR loop ;; .L9: adds r14 = -12, r36 ;; ld4 r14 = [r14] ;; sxt4 r14 = r14 ;; shladd r15 = r14, 3, r0 adds r16 = -32, r36 ;; ld8 r14 = [r16] ;; add r16 = r15, r14 adds r14 = -20, r36 ;; ld4 r14 = [r14] ;; sxt4 r14 = r14 ;; shladd r15 = r14, 3, r0 adds r17 = -32, r36 ;; ld8 r14 = [r17] ;; add r14 = r15, r14 ld8 r38 = [r16] ;; ld8 r39 = [r14] br.call.sptk.many b0 = strcmp# mov r1 = r37 mov r14 = r8 ;; cmp4.ge p6, p7 = 0, r14 (p6) br.cond.dptk .L8 adds r14 = -20, r36 adds r15 = -12, r36 ;; ld4 r15 = [r15] ;; st4 [r14] = r15 .L8: adds r15 = -12, r36 adds r14 = -12, r36 ;; ld4 r14 = [r14] ;; adds r14 = 1, r14 ;; st4 [r15] = r14 br .L6 ;; .L6:
.L7: mov r16 = r36 ; get temppntr adds r14 = -20, r36 ;; ld4 r14 = [r14] ;; sxt4 r14 = r14 ;; shladd r15 = r14, 3, r0 adds r17 = -32, r36 ;; ld8 r14 = [r17] ;; add r14 = r15, r14 ;; ld8 r14 = [r14] ; ;; ; pctemp=pc[min] st8 [r16] = r14 ; adds r14 = -20, r36 ;; ld4 r14 = [r14] ;; sxt4 r14 = r14 ;; shladd r15 = r14, 3, r0 adds r16 = -32, r36 ;; ld8 r14 = [r16] ;; add r16 = r15, r14 adds r14 = -16, r36 ; get ipntr ;; ld4 r14 = [r14] ;; sxt4 r14 = r14 ; sign extend i ;; shladd r15 = r14, 3, r0; i x 8 adds r17 = -32, r36 ;; ld8 r14 = [r17] ;; add r14 = r15, r14 ; build pntr ;; ld8 r14 = [r14] ; ;; ; pc[min]=pc[i] st8 [r16] = r14 ; adds r14 = -16, r36 ; get ipntr ;; ld4 r14 = [r14] ; get i ;; sxt4 r14 = r14 ;; shladd r15 = r14, 3, r0; i x 8 adds r16 = -32, r36 ; get pc[] base ;; ld8 r14 = [r16] ;; add r15 = r15, r14 ; build pc[i] pntr mov r14 = r36 ; get pctemppntr ;; ld8 r14 = [r14] ; ;; ; pc[i]=pctemp st8 [r15] = r14 ; adds r14 = -8, r36 ; get kpntr ;; st4 [r14] = r0 ; zero k
.L11:
; FOR k loop adds r14 = -8, r36 ; get kpntr adds r15 = -24, r36 ;; ld4 r16 = [r14] ld4 r14 = [r15] ;; cmp4.gt p6, p7 = r14, r16 (p6) br.cond.dptk .L14 br .L12 ; Exit k FOR loop ;; .L14: adds r14 = -8, r36 ;; ld4 r14 = [r14] ;; sxt4 r14 = r14 ;; shladd r15 = r14, 3, r0 adds r17 = -32, r36 ;; ld8 r14 = [r17] ;; add r15 = r15, r14 addl r14 = @ltoffx(.LC0), r1 ;; ld8.mov r38 = [r14], .LC0 ld8 r39 = [r15] br.call.sptk.many b0 = printf# mov r1 = r37 adds r15 = -8, r36 ; get dest kpntr adds r14 = -8, r36 ; get src kpntr ;; ld4 r14 = [r14] ; ;; adds r14 = 1, r14 ; incr k ;; st4 [r15] = r14 ; br .L11 ;; .L12: addl r14 = @ltoffx(.LC1), r1 ;; ld8.mov r38 = [r14], .LC1 br.call.sptk.many b0 = printf# mov r1 = r37 adds r15 = -16, r36 ; get Dest ipntr adds r14 = -16, r36 ; get Src ipntr ;; ld4 r14 = [r14] ; ;; adds r14 = 1, r14 ; incr i ;; st4 [r15] = r14 ; br .L2 ; Bottom of i loop ;; .L3: mov r14 = r0 ;; mov r8 = r14 mov ar.pfs = r35 ; save FP mov b0 = r34 .restore sp mov r12 = r36 br.ret.sptk.many b0 ;; .endp selectionsort#
.text ; Code Section .align 16 .global main# .proc main# main: .prologue 14, 32 .save ar.pfs, r33 alloc r33 = ar.pfs, 0, 4, 2, 0 .vframe r34 mov r34 = r12 ; set FP from SP adds r12 = -144, r12 ; open stack frame mov r35 = r1 .save rp, r32 mov r32 = b0 ; save branch reg .body ;; adds r15 = -48, r34 ; build tablepntr addl r14 = @ltoffx(.LC2), r1; build RAM pntr ;; ; using offset+base pntr ld8.mov r14 = [r14], .LC2 ;; st8 [r15] = r14 ; save strnpntr in table adds r16 = 8, r15 :bump pntr addl r14 = @ltoffx(.LC3), r1 ;; ; "Tuesday" ld8.mov r14 = [r14], .LC3 ;; st8 [r16] = r14 ; save strnpntr in table adds r16 = 16, r15 addl r14 = @ltoffx(.LC4), r1 ;; ; "Wednesday" ld8.mov r14 = [r14], .LC4 ;; st8 [r16] = r14 ; save strnpntr in table adds r16 = 24, r15 addl r14 = @ltoffx(.LC5), r1 ;; ; "Thursday" ld8.mov r14 = [r14], .LC5 ;; st8 [r16] = r14 ; save strnpntr in table adds r16 = 32, r15 addl r14 = @ltoffx(.LC6), r1 ;; ; "Friday" ld8.mov r14 = [r14], .LC6 ;; st8 [r16] = r14 ; save strnpntr in table adds r16 = 40, r15 addl r14 = @ltoffx(.LC7), r1 ;; ; "Saturday" ld8.mov r14 = [r14], .LC7 ;; st8 [r16] = r14 ; save strnpntr in table adds r15 = 48, r15 addl r14 = @ltoffx(.LC8), r1 ;; ld8.mov r14 = [r14], .LC8 ;; ; "Sunday" st8 [r15] = r14 ; save strnpntr in table adds r14 = -128, r34 ; build ipntr ;; st4 [r14] = r0 ; clear i
; star t of FOR i loop adds r15 = -128, r34 ;; ; names[]=testset[] ld4 r14 = [r15] ; get i ;; cmp4.ge p6, p7 = 6, r14 (p6) br.cond.dptk .L19 ; test end of FOR loo br .L17 ;; .L19: adds r15 = -112, r34; get Destpntr adds r16 = -128, r34 ; get ipntr ;; ; local variables ld4 r14 = [r16] ; get i ;; sxt4 r14 = r14 ; sign extend ;; shladd r14 = r14, 3, r0; i x 8 ;; add r16 = r14, r15 ; index Destpntr adds r15 = -48, r34 ; get Srcpntr adds r17 = -128, r34 ; get ipntr ;; ld4 r14 = [r17] ; get i ;; sxt4 r14 = r14 ; sign extend ;; shladd r14 = r14, 3, r0:ix8 ;; add r14 = r14, r15 ; index Srcpntr ;; ld8 r14 = [r14] ; | get next_word ;; :| st8 [r16] = r14 ; | put next_word adds r15 = -128, r34 ; get ipntr ;; ld4 r14 = [r15] ; get i ;; adds r14 = 1, r14 ; incr i adds r16 = -128, r34 ; get ipntr ;; st4 [r16] = r14 ; save i br .L16 ; bottom of FOR ;; .L17: addl r14 = @ltoffx(.LC9), r1 ;; ld8.mov r36 = [r14],.LC9; print banner br.call.sptk.many b0 = printf# mov r1 = r35 ; return value adds r14 = -112, r34 ; get Destpntr ;; mov r36 = r14 ; param1=Destpntr addl r37 = 7, r0 ; param2=7 br.call.sptk.many b0 = selectionsort# ; c mov r1 = r35 ; get return value mov r14 = r8 adds r17 = -128, r34 ; get ipntr ;; st4 [r17] = r14 ; store in i mov ar.pfs = r33 mov b0 = r32 ; restore branch addr .restore sp mov r12 = r34 ; restore SP br.ret.sptk.many b0 RETURN to shell ;; .endp main# .ident "GCC: (GNU) 3.3.5 (Debian 1:3.3. .L16:
.section .align 8 .LC2: .align 8 .LC3: .align 8 .LC4: .align 8 .LC5: .align 8 .LC6: .align 8 .LC7: .align 8 .LC8: .align 8 .LC9:
.rodata
; Constants Section stringz stringz stringz stringz stringz stringz stringz stringz "Monday"; constant strings store "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday" "Sunday" "\n\nSelection Sort\n"
Browser window
Registers window
Disassembler window
gdb window
CSA ch 22 - p 322
CSA Ch 23
CSA Computers Fetch-execute cycle Hardware CPU Arithmetic Logic Unit Control Unit RISC features ARM processor Pentium Itanium Input-output Parallel communication Serial communication Networking Local Area Networks Ethernet USB Wide Area Networks Other Networks Point to point Visual output Memor y Memor y hierarchy Cache and main memory Disk ling Parallel processing Software Operating systems Unix MS Windows Tools Compilers and assemblers Subroutines and stacks WIMPs Users viewpoints Hardware engineer HLL programmer Systems administrator Systems programmer
CSA ch 23 - p 323
Program has N instructions Instructions take secs each to complete Uni-processor run time will be N x IDEALLY, P processors could reduce run time to (N )/P But only a fraction of real application code can be parallelized:
N (1 f ) P
While f is the fraction of the problem that must be carried out sequentially due to data or control dependencies, (1 f ) is the fraction which can run in parallel. Note that f + (1 f ) evaluates to 1. P is the number of processors available. The speed-up-ratio is then dened as the uni-processor-time divided by the (smaller!) multi-processor-time, which is:
speed _up_ratio: S =
N 1 = N (1 f ) f + (1 f )/P N f + P
CSA ch 23 - p 324
x5 S, speed-up ratio
x4
0.8
x3
0.7
x2
x1 2 4 6 8 10 12 14
P , number of CPUs
Amdahls Law plotted for 1-15 processors and 0.1 - 0.9 compliant code
CSA ch 23 - p 325
CPU1
CPU2
CPU3
CPU1
cache
CPU2
cache
CPU3
cache
CPU1
cache
CPU2
cache
CPU3
cache
Write
CSA ch 23 - p 326
local memor y
local memory
local memor y
CPU1
cache
CPU2
cache
CPU3
cache
CPU5
cache
CPU4
cache
CPU6
cache
local memor y
local memory
local memor y
CSA ch 23 - p 327
Storage Logic
256 kbyte
Local storage
I-fetch
Control Logic
Decode Dispatch
Front end
Execution Logic
BU
SCU
L/SU
Vperm
SPU1
SPU2
Byte
FX1
FX2
R-commit
Control unit
CSA ch 23 - p 328
SPE 7
SPE 3
SPE 6
SPE 2
SPE 5
SPE 1
SPE 4
SPE 0
MIC 2x XDR
BIC FlexIO
CSA ch 23 - p 329
workstations
Internet
Application originator
Grid computing
CSA ch 23 - p 330
CSA ch 23 - p 331