Computer Systems Architecture Dr Rob Williams 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 filing 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 Rob Williams Pearson Education (c) 2006 CSA ch 01 - p 1 CSA Rob Williams Pearson Education (c) 2006 CSA ch 01 - p 2 1. CSA - the Hardware / Software Interface Computer Architecture? h/w s/w Interaction of h/w & s/w User code myprog.c WIN32 API O/S Kernel CPU Graphics Sound Software Operating Systems Procedures Hardware Layered hierarchy of s/w on a h/w bed CSA Rob Williams Pearson Education (c) 2006 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 3µm 1985 1990 1995 2000 Circuit line width µm 1 10 2.0µm 1.0µm 0.4µm 0.35µm 0.15µm 0.1µm ? 0.1 Moore’s Law of technological progress ENTITY decoder8 IS PORT (sel: IN std_logic_vector (2 DOWNTO 0); -- select i/p signals sig: out std_logic_vector (7 downto 0)); -- eight o/p signals END decoder8; ARCHITECTURE rtl OF decoder8 BEGIN s 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 ASCII code table CSA Rob Williams Pearson Education (c) 2006 CSA ch 02 - p 15 #include void main() { putchar(7); } Ring the bell char letter; short count; unsigned int uk_population; long world_population; float body_weight; double building_weight; long double world_weight; Data types AIX CICS CP/M George ISIS MINIX MSDOS Multics OS/2 PRIMOS RSX/11 TDS UNIX VERSADOS VMS XENIX CDOS CMS MSDOS IDRIS LYNXOS MOP MVS OS-9 PICK RSTOS RTL/11 THE Ultrix VM MS WINDOWS Linux Operating Systems 1. Command line interpreter (CLI), shell script or desktop selections 2. Function calls from within user programs (API) Access to O/S facilities CSA Rob Williams Pearson Education (c) 2006 CSA ch 02 - p 16 rob[66] stty -icanon min 1 time 0 ; menu_prog Are you ready to proceed? [ Y / N ] : Unix unbuffered, nonblocked keyboard #include #include #include #include #define TIMEOUT -1 extern int errno; int sys_nerr; extern char * sys_errlist[]; void setterm(void) { struct termios tty; int status; status = ioctl(0,TCGETS, &tty); tty.c_lflag &= ˜ICANON; tty.c_cc[VTIME] = 0; tty.c_cc[VMIN] = 1; status = ioctl(0,TCSETS, &tty); if ( status == -1 ) { printf("ioctl error \n"); perror(sys_errlist[errno]); exit(); } } CSA Rob Williams Pearson Education (c) 2006 CSA ch 02 - p 17 User Applications CLI kernel hardware drivers Onion layered model for Operating Systems 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 Unix command shells CSA Rob Williams Pearson Education (c) 2006 CSA ch 02 - p 18 Screen Server Print Ser ver File Server Client-ser ver computing Client Request Message Reply Request Replies Request Ser ver time Xterm atari@pong [50] xterm & atari@pong [51] rlogin milly -l rwilliam Last login: Tue Jul 1 09:22:21 sister rwilliam@milly > CSA Rob Williams Pearson Education (c) 2006 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 filing 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 Rob Williams Pearson Education (c) 2006 CSA ch 03 - p 20 3. CSA - the Fetch-execute Cycle Computer Computer subsystems I/O Units Mouse socket Printer Connector Keyboard socket CPU Main Memory USB sockets MODEM socket LAN socket Slots for I/O Expansion Cards Sound I/O ATX Power Connector Hard Disk IDE Connectors Floppy disk Connector PCI Slots ChipSet VGA ISA Slot Lithium Batter y BIOS AGP Slot ChipSet Slots for Memory Modules + Socket 462 Crystal Fig 3.2 PC ATX Motherboard, showing the locations of the CPU, memor y and I/O card sockets CPU Fan Connector Pentium CPU and Heatsink Motherboard from a PC CSA Rob Williams Pearson Education (c) 2006 CSA ch 03 - p 21 System Clock CPU Interrupt Request System Bus Main Memory I/O Subsystem Subsystems joined by a bus highway Bus Point-to-point vs. bus interconnect schemes CPU ALU Control Unit CPU has two main component parts CSA Rob Williams Pearson Education (c) 2006 CSA ch 03 - p 22 1 1 000 000 000 fetch-execute 10 ns logic gate delay 5 ns SRAM access 15 ns 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 Rob Williams Pearson Education (c) 2006 CSA ch 03 - p 23 CPU AX IP IR System Clock System Bus MAR 10111000 00000000 00000001 Main Memory CPU AX IP IR AX IP ++ CPU IR Instruction Address Instruction Code Address bus Data bus MAR 10111000 00000000 00000001 MAR 10111000 00000000 00000001 Main Memory Main Memory The Fetch part of the Fetch-Execute Cycle CSA Rob Williams Pearson Education (c) 2006 CSA ch 03 - p 24 CPU AX IP IR AX CPU IR IP ++ Data Address Operand Data: 256 MAR 10111000 00000000 00000001 MAR 10111000 00000000 00000001 Main Memory Main Memory The execute part of the Fetch-Execute Cycle CPU activity for a Sun workstation CSA Rob Williams Pearson Education (c) 2006 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. System bus has three parts A System Clock Address R/W Addr1 B C Addr2 Addr3 Read Read Write Data Instr Fetch 10 ns Data Execute time-base Result Timing of synchronous bus activity CSA Rob Williams Pearson Education (c) 2006 CSA ch 03 - p 26 Addr1 Address ALE R/W Addr2 Addr3 A valid Fetch C valid valid Read Write Data Instr Data Result DTA B ok ok 10 ns ok time-base Timing of asynchronous bus activity Read instruction Decode instruction Read operand Execute op Write result A Single Instruction Cycle Timing of multi-phase instructions cycle CSA Rob Williams Pearson Education (c) 2006 CSA ch 03 - p 27 1011011 Robert Musical interference on FM receivers ideal pulse real pulse Clock speed limitation CSA Rob Williams Pearson Education (c) 2006 CSA ch 03 - p 28 IP Pre fetcher unit queue 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 Overlapped operations gives greater throughput Address Width 1111 1111 1111 1111 1111 1111 Top 16 MByte memor y length 0000 0000 0000 0000 0000 0000 Bottom memor y width Address width determines memory length CSA Rob Williams Pearson Education (c) 2006 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 Rob Williams Pearson Education (c) 2006 CSA ch 03 - p 30 Motorola 68030 b1[0] b2[0] Address 0FE032 0FE042 0FE052 0FE062 0FE072 0FE082 0FE092 Memory Contents In Hex 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 Byte ordering: big endian, little endian unsigned char b1[ ] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 251, 252, 253, 254, 255}; unsigned short b2[ ] = {1, 2, 3, 4, 5, 254, 255, 256, 257, 65532, 65533, 65534, 65535}; unsigned int b4[ ] = {1, 2, 3, 4, 5, 254, 255, 256, 4095, 4096, 4097, 4294967295}; CSA Rob Williams Pearson Education (c) 2006 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 Parallel data input & output ports CSA Rob Williams Pearson Education (c) 2006 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 filing 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 Rob Williams Pearson Education (c) 2006 CSA ch 04 - p 33 4. CSA - the Control Unit (CU) 5v 14 13 12 11 10 9 8 1 2 3 4 5 6 7 0v Inputs C A B A AND B 00 0 01 0 10 0 11 1 A B AND C 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 Basic logic gates with truth tables 1 1 1 1 0 1 0 1 0 1 1 1 Detect: 111 Detect: 101 Detect: 010 Using AND for pattern recognition DX 00 01 10 11 Out 0 0 0 1 D Data in X Off/On control line Data Out DX d0 d1 Out 0 d Using AND as a data valve CSA ch 04 - p 34 CSA Rob Williams Pearson Education (c) 2006 Control WXYZ 0001 0010 0100 1000 Data ABCD abcd abcd abcd abcd Out a b c d Data lines A B C D W X Output Control Y lines Z O = (A AND Z ) OR (B AND Y ) OR (C AND X ) OR (D AND W ) Data selector, 1 from 4 Selector YX 00 01 10 11 Line dcba 0001 0010 0100 1000 O = (A AND (X AND Y ) ) OR (B AND (X AND Y ) ) OR (C AND (X AND Y ) ) OR (D AND (X AND Y 2-to-4 line decoder, 1-out-of-4 line selector CSA Rob Williams Pearson Education (c) 2006 CSA ch 04 - p 35 Input Y X 2 Line Decoder A1 a Data lines D C B A A2 b Data c Output A3 A4 d a b c d A B C D Output A B C D O1 = (i 3 AND i 2 AND i 1) OR (i 4 AND i 3 AND i 2) OR (i 4 AND i 3 AND i 2 AND i 1) Data multiplexor, 1 from 4 CSA Rob Williams Pearson Education (c) 2006 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 i i i O1 O1 = (i 3 • i 2 • i 1) + (i 4 • i 3 • i 2) + (i 4 • i 3 • i 2 • i 1) Sum of Products solution XY 00 01 10 11 NAND 1 1 1 0 The 2 input NAND gate CSA Rob Williams Pearson Education (c) 2006 CSA ch 04 - p 37 i1 i2 i3 i 4 O1 O2 O3 O4 O5 O6 O7 O 8 Programmable Logic Array (PLA) CSA Rob Williams Pearson Education (c) 2006 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 000 001 010 011 100 101 110 111 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 X Y R A G X Y Z R A G r a N-S W-E R=X A =Y G = X AND Y g R = (X AND Y ) A = (X AND Z ) G = (X AND Y AND Z ) r = (X AND Y ) a = (X AND Z ) g = (X AND Y AND Z ) Traffic light controllers CSA Rob Williams Pearson Education (c) 2006 CSA ch 04 - p 39 Inputs Enable Select G1 G2 X1 0X 10 10 10 10 10 10 10 10 CBA XXX XXX 000 001 010 011 100 101 110 111 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 Rob Williams Pearson Education (c) 2006 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 g e d c 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 a Binar y to 7-segment decoder CSA Rob Williams Pearson Education (c) 2006 CSA ch 04 - p 41 READY SPIN FILL DRAIN HEAT RINSE DRAIN WASH 1 rev per 1 2 1 1000 hr → 2rph → rps → Hz → mHz → 0. 55mHz 2 3600 1800 1800 Washing machine Finite State Diagram (FSD) CSA Rob Williams Pearson Education (c) 2006 CSA ch 04 - p 42 from micro-switch 0 micro-switch 1 micro-switch 2 Micro switch 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 Valve Heat Motor Pump Open On F S 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 Washing machine sequence controller (FSM) CSA ch 04 - p 43 CSA Rob Williams Pearson Education (c) 2006 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 5 bit control word Control Lines Control 111 110 101 100 011 010 001 Store 00101 00001 10010 00001 00010 01000 10000 00000 JMP flag 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 Washing machine controller with conditional branching CSA Rob Williams Pearson Education (c) 2006 CSA ch 04 - p 44 internal data bus Instruction Register Addr Gen Pre-Decode System Clock Binar y Counter 000 001 010 011 Decoder 00001 00010 00100 01000 10000 Control Logic Gate Array Status Bits Condn Flags reset dedicated control signals Hardware logic Control Unit (RISC) CSA Rob Williams Pearson Education (c) 2006 CSA ch 04 - p 45 internal data bus IR Binar y System Clock Counter 000 001 010 011 Address Generator Logic Condn Flags Microaddr Reg reset Control Store PROM Micro IR dedicated control signals Microcoded Control Unit (CISC) CSA Rob Williams Pearson Education (c) 2006 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 filing 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 Rob Williams Pearson Education (c) 2006 CSA ch 05 - p 47 5. CSA - the Arithmetic & Logic Unit (ALU) (X AND Y ) ≡ (X OR Y ) ≡ ≡ (X OR Y ) ≡ (X AND Y ) while ( ! dog && ! cat ) { plant_flowers( ) ;} while (! (dog || cat )) { plant_flowers( ) ;} De Morgan’s equivalences X XY 00 01 10 11 ADD CS 00 01 01 10 X Y Carr y Y Carr y Sum Sum Alternative Half Adder (2 inputs) circuits CSA Rob Williams Pearson Education (c) 2006 CSA ch 05 - p 48 X Y Carr y Sum X Y Carr y Sum More Half Adder circuits XYZ 000 001 010 011 100 101 110 111 CS 00 01 01 10 01 10 10 11 X Y Z 1/2 Adder Full-adder C 1 Carry 1/2 Adder C 2 Sum Full Adder (3 inputs) circuit CSA Rob Williams Pearson Education (c) 2006 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 C 4 bit parallel adder circuit CSA Rob Williams Pearson Education (c) 2006 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 integers using Twos Compliment format negative 0 To form a two’s compliment negative: Take the positive number, invert all the bits, add 1. A B 1 - subtract 31 • • • • • 0 0 - add Carr y in 32 bit ALU (Parallel Adder) C 31 0 IR control lines CU ALU with positive and negative capability CSA Rob Williams Pearson Education (c) 2006 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 00011001 01010011 00101101 Test LS bit 01000 110 01010011 00100011 00101001 00101101 + 1 00101101 shift right 00100011 00101001 00101101 Test LS bit 01010000 00101001 00101000 00010100 00101101 + 1 00101101 shift right 00010100 00001010 00101101 Test LS bit 00001011 01001110 00101101 00000101 10100111 00101101 0 shift right Result 00010100 00001010 00101101 Test LS bit 00010100 00001010 00101101 00001010 00000101 00101101 0 shift right 8 x 8 multiply using two 16 bit registers CSA Rob Williams Pearson Education (c) 2006 CSA ch 05 - p 54 D7 D6 D5 D4 D3 D2 D1 D0 Data Registers Register select Internal CPU Data Bus A B Carr y in control lines CU ALU CPU Flags C ALU with data registers CSA Rob Williams Pearson Education (c) 2006 CSA ch 05 - p 55 Output Values, F S3 - S0 M=1 Logic Cin = 0 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 =A−B 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 ! pipe1 & rob@milly [82] cat pipe1 >! pipe2 & rob@milly [82] cat pipe2 >! pipe3 & Demonstrating Unix named pipes CSA Rob Williams Pearson Education (c) 2006 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 Rob Williams Pearson Education (c) 2006 CSA ch 13 - p 173 # Determine the i/p and o/p files (for last week’s 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 $OUTFILE rm /tmp/$$.freemem /tmp/$$.freeswap /tmp/$$.sar-f lp -d ps $OUTFILE sleep 60; rm $OUTFILE exit A Unix administration script for performance statistics CSA Rob Williams Pearson Education (c) 2006 CSA ch 13 - p 174 #include 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]) 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 sink null sink null users mail timserver nameserver nicname # usually to sri-nic #Internet Gopher http hostname rpcbind rpcbind # World Wide Web # usually to sri-nic TCP port numbers and their services from /etc/services CSA Rob Williams Pearson Education (c) 2006 CSA ch 15 - p 202 15 7 0 15 7 0 15 7 0 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 Header Version length TOS Length (Bytes) Sequence count (Identity) Flags TTL max hops Protocol Header checksum IP Source address (32 bits) IP Destination address (32 bits) Flags Tx window size TCP checksum Urgent pointer Optional facilities Payload Type TCP Frame (Data Payload) User Payload IP Frame (Data Payload) IP Header Structure TCP Header Structure CRC error detection Ethernet header IP header TCP header User Data Ethernet Packet Ethernet, IP, TCP encapsulation CSA ch 15 - p 203 CSA Rob Williams Pearson Education (c) 2006 Data packet single data packet sent immediately ACK ACKed multiple data packets sent all ACKed data sent no ACKs so Tx pauses Flow control using a four packet buffer ACKs received so Tx resumes Transmitter Receiver Router Network 1 Network 5 Bridge Differentiating Repeaters, Bridges, and Routers Network 2 Network 1 Network 1 Repeater Network 2 CSA Rob Williams Pearson Education (c) 2006 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] Destination host or network Recommended first hop Status Flags U - up and OK G - gateway / direct connection H - host / network address Local Ethernet por t Unix netstat utility showing the routing table CSA Rob Williams Pearson Education (c) 2006 CSA ch 15 - p 205 Traffic flooding without routing decisions RIP Operation IP Number # router hops 1st hop # ticks (56ms) IP Number # router hops 2nd hop # ticks RIP packet fields Region Europe N America S America Pacific Asia IP Numbers Reserved 194•000•000•000 - 195•255•255•255 198•000•000•000 - 199•255•255•255 200•000•000•000 - 201•255•255•255 202•000•000•000 - 203•255•255•255 CIDR IP number allocations address book DNS arp table User name Rober t Williams UWE, Bristol, UK user host id rob.williams olveston.uwe.ac.uk IP number 164.11.253.47 MAC number 08:00:20:8E:86:5F Identifier translation required for transmitters CSA Rob Williams Pearson Education (c) 2006 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-- Inspecting the local hosts file •org •net •com •edu •gov •mil •fr •de •uk •us •gov •ac •co •uwe •csm Hierarchical Domain Naming Structure (DNS) CSA ch 15 - p 207 CSA Rob Williams Pearson Education (c) 2006 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] Using the DNS name look-up facility CSA Rob Williams Pearson Education (c) 2006 CSA ch 15 - p 208 Netscape Navigator Web Browser URL = Protocol identifier/Machine name/file path CSA Rob Williams Pearson Education (c) 2006 CSA ch 15 - p 209 Introducing world.html to Netscape on Unix Tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . [Press] Functions Page delimiters Page heading http title (invis) Main text delimiters Body text font selection Font type, size & colour Subheading at level x Embolden font Italicize font Unordered list Ordered list Menu List star t Break text, \n New paragraph Horizontal line Nofill, preformatted Inser t image file here set up a Hyperlink Star ter set of HTML tags CSA Rob Williams Pearson Education (c) 2006 CSA ch 15 - p 210 http proxy [URL] - The proxy command allows a proxy HTTP server to be defined 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 file - The get command retrieves the document located at URL. The body of the document is written to file. The command returns the HTTP header as described for the http head command above. http post url filename_1 filename_2 - The post command posts the document in filename_1 to the location URL. The body of the returned document is written to filename_2. The command returns the HTTP header as described for the http head command above. http put URL file - The put command copies the file 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. Examples from Hypertext Transmission Protocol (http) CSA Rob Williams Pearson Education (c) 2006 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 / - - Using http/GET in place of ftp/get CSA Rob Williams Pearson Education (c) 2006 CSA ch 15 - p 212 DNS server Multiple Google ser vers Client broswer Index ser vers each with 80 dual Pentium cards with 2 GB DRAM & 80 GB IDE disks in cooled racking Schematic of Google search engine CSA Rob Williams Pearson Education (c) 2006 CSA ch 15 - p 213 Internet Fetched pages Crawlers Internet Queries Parser URL ser ver Anchors Repositor y of web pages (compressed by zlib) Lexicon Indexer wordID converter Word index store inverted file Index sor ter Document index store URL resolver Links Searchers hits PageRank Filter and sor ter Quer y allocate results list Google data-flow activity diagram CSA Rob Williams Pearson Education (c) 2006 CSA ch 15 - p 214 Application layer 7 Application program Presentation layer 6 transformation data formatting Session layer 5 computer dialogue control Transpor t layer 4 message packets Network layer 3 Vir tual circuit routing control packet sequencing Flow control error/lost block detection Link layer 2 Physical layer Communication sub-net layers 1 Voltage levels plug pinouts ISO Seven Layer OSI Model Application Application Presention Session TCP or UDP IP Network Transpor t Network Link Physical 7 6 5 4 3 2 1 Comparison of TCP/IP with ISO seven layers CSA Rob Williams Pearson Education (c) 2006 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 filing 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 Rob Williams Pearson Education (c) 2006 CSA ch 16 - p 216 16. CSA - Other Networks IXC IXC Trunk lines IXC Trunk Exch LXC LXC Local Exch Brr Brr! Brr Brr POTS, the traditional telephone network 1209 1336 1477 Hz 1 4 7 2 5 8 0 3 6 9 # 697 770 825 941 ∗ DTMF, touch-tone signalling key pad . .. . .. .. .. .. .. .. . .. .. .. . . .. .... .. . . . . . .. . . . . . . . . ..... . .... . . . . . . . ...... . . . . . . . . . . .. . . . .. . . . . .. . . .. . . . .. .. .. . . .. . . .. . . . . .. . .. .. .. . . .. .. . . .. .. . . .. .. . . .. .. .. . . .. .. . . .. .. . . . . .. .. . . . . . . . . . ... ... . .. .. .. . ... .... . . . . . . . ... ... . . . . . . . . . . .. . .. .... ..... ..... . . . . . .. . .. . . . .... . . . . . . . ... . . . . . . . ... .. . . . . .. . . . . .. .. . . . . . .. ... . . . . .. .. . . . . .. . . . . . . . .. . .. .. .. . .. .. .. . . . .. .. Analogue .. .. . . . signal 8 bits every 125 µs 01100101 00111100 11100101 00111101 Digital signal Line .............................................................................. Interface ........................................................................ Card Digitization of telephone speech signals CSA Rob Williams Pearson Education (c) 2006 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 = A V in 1 + log A where A = 87.6 Input Speech Signal Non-linear voice compression for transmission 2 x 106 103 2. 048M = = = 32 channels 64 x 103 32 64k 0 1 2 3 discrete voice channels 0 1 2 3 30 channel TDM trunk line Demultplx 28 29 30 31 Multiplexor 28 29 30 31 1 frame 125 µs 30 conversations C1 1 2 3 4 5 6 7 C2 24 25 26 27 28 29 30 C1 2 3 4 5 6 1 slot 10110110 8 bit speech sample, 3.9 µs Time Divison Multiplexing (TDM) for trunk line sharing CSA Rob Williams Pearson Education (c) 2006 CSA ch 16 - p 218 Înput Voice Channels 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 Control Computer Signal Channel Ouput Voice Channels Space division circuit switching with control processor 125 µs frame 1 5 8 2 0 8 4 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 Input Voice channels TDM Controller Output Voice channels 0 1 2 3 4 5 6 7 8 9 Time Division Circuit Switching CSA Rob Williams Pearson Education (c) 2006 CSA ch 16 - p 219 300 Hz 30 KHz LF 3 MHz MF coax cable 300 MHz gsm 30 GHz 3 THz 300 THz IR Vis optic fibre UV VLF HF VHF UHF SHF EHF twisted pair Bands within the electromagnetic spectrum .. .. . . .. . . .. . . .. . . .. . . .. .. . . .. . . .. . . .. . . .. ... .... .... ... .... .... .... .... .... .... .... .... .... .... ... ... .... .... .... .... .... .... .... .... .... .... .... .... .... .... . . . . . . . . ... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... .... . .. . .. . . .. .. . .. . .. . . . .. . . . . . .. . .. . . . . .. .. .. . . . . .. . .. . .. . .. . . . .. . .. . . . .. . .. . . . . . . . . . . .. . . . . . . . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . . .. . . . . . .. . . . .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. ............................................................. . . . .. . . . . . . . . . . . . . . . . . . . . . .. . . . . .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. . . . . . .. .. .. .. .. .. .. .. .. .. . .. . . . . . . . . . . .. .. .. . . . . . . .. .. .. . . .. . . . . .. .. . . .. .. . . . . .. .. .. .. . . .. .. .. .. .. .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . . . .. . . . . .. . . . . .. .. . . . . . . . . .. .. .. .. .. . . . . .. .. . .. .. . .. .. . .. .. . .. .. . . .. . . .. .. . .. .. . .. .. . .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . ... ... .. .. ... ... . .. .... ... .. . .... ... .. .. . . .. .. . .. .... .... .... ... . ... .... .... .... .. .. .. .. .. .... .... .... ... . . .. . . . . . . . .. . . ... . . . . . . . .. . . . . ... ... . . . . . . . . .. . . . . . . . . . . . .. ... .. . . . . .. . .. .. ... ... . . . . . . . . .. . . .. . .. .. . . . .. . .. ..... .... .. .. .. .. . . . . .. . . ... . . .. .. . .. . . . . . .. .. .. ..... .... .. .. .. .. . . . . .. .. .. ... . .. .. . .. . . . . . . . . . . . . . . .. .. ................ .. .. . . . . . .. . .. .. ... .............. .. .. . .. . . . . . .. .. .. .. ................ .. .. . . . . . .. . .. .. ... ............... .. .. . . .. . . . . . . . . . . . . . . .. . . .. . . . . . . . .. . . . . . . .. . . .. . . . . . . . . . .. . . . . ... .. .. . . . . . . . . .. . . . .. . . . .. . . . . . . . . . . .. . . . . . . . . . .. .. ... . .. . . . . .. ... . . . . . . ... . . . . . . . ... . . . .. . .. . . . . .. .. ... . .. . . . .. .. . . .. .. .. . . . . .. . . .. .. .. .. .. .. . . . .. ... ... .. .. . . . . . .. ... ... .. .. . ... . .. . . . . . . ... .. . . . .. ... .. .. ... . . . . .. . . . . .. . .. . . . .. .. . . . .. . . . . . ..... ... ... ... .. ... .... ... .... ... ... ... .. ... ... ... .... ... .. .. . .. . . .. .... .... .. .. .. .... .. .. .. .. .... .... .. .. .. .... .. .. .. .. .... .... .. . . . .. . . . . . . . . .. . .. . . . . . . . . .. . .. . . .. .. .. . . .. .. .. . . .. .. .. .. .. .. . . .. .. .. .. . .. .. .. .. .. .. ... .. . . . . . . . . .. . . . . .. .. . . . . . . . . . . . . .. .. . . . . . . . . . . . . .. . . .. . . . . . ... . . . .. . .. . .. . . . . . ... . . . . . .. . .. . . . . . . . . . . . .. . . . . . . .. . . . . . . . . . . . . . .. .. . . .. . . . . . . . . . .. .. . . .. . . . . . . . . . . . . . . .. .. . . . . . . . . . . . .. . . . . . . . . . . . . . . . . . . .. .. . . . . . . . . . . . . .. .. . . .. . . . . . . . . . . .. . . . . . . .. . . . . . . . . . . . . . . . . . . .. . .. . . . . . . .. . . . . . .. .. .. .. . . . . . . . . .. .. .. . . . . . . . . . . .. . . . .. . . . . . . . .. .. . .. .. . . . . . . .. . . .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. . . . .. . . . . . . . .. . . . .. . .. .. . . . . . . . .. . . . . . . . . . . . . . .. . Carr er requency Amp ude Modu a ed 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 Radio wave modulation using amplitude, frequency and phase techniques CSA Rob W ams Pearson Educa on (c) 2006 CSA ch 16 - p 220 Radio mast Base station Switch Switch Switch Radio cell equipment and interconnection 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 Utilization of radio frequency bands CSA Rob Williams Pearson Education (c) 2006 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 Cells with a repeat 7 pattern of radio frequencies 4 2 1 3 4 2 3 A cell arrangement with only repeat 4 pattern CSA Rob Williams Pearson Education (c) 2006 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 Equalizer Burst Disass De-cipher De-interleave Decoding Class 1 CRC ADC LNA MXR Filter Radio Unit Voice Codec Sig Proc Radio Modem gsm handset signal processing schematic Control Processor Protocol Stack User Interface Peripherals Control Voice Codec ADC DAC TDMA timer LCD display Memory : RAM FLASH ROM Keypad DSP Speech Encoder Radio Modem DAC ADC Analog Baseband PLL Equalizer Burst Disass De-cipher De-interleave Decoding Class 1 CRC SIM card Radio Transceiver Unit gsm handset functional modules CSA Rob Williams Pearson Education (c) 2006 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 Packet structure for gsm voice transmissions Circuit Switching Circuit Set up Path Arranged Packets Sent Vir tual Circuit Switching Datagram Packet Switching Voice data Packets Transfer Circuit Closed Message Complete Switch: 1 2 3 4 Path Closed 1 2 3 4 1 2 3 4 Circuit switched vs. packet switched message timing CSA Rob Williams Pearson Education (c) 2006 CSA ch 16 - p 224 Header 5 bytes Payload 48 bytes VPI VCI ECC The ATM frame structure 0 1 2 3 ATM Switch 28 29 30 31 0 1 2 3 155 Mbps ATM trunk line 28 29 30 31 ATM Switch Schematic ATM router switch data payload 10101000111000 ATM data cell 0 1 155 Mbps 2 3 addr 111 111 0 1 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 Interconnection inside an ATM Banynan Switch CSA Rob Williams Pearson Education (c) 2006 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 1010101010 Synchronization 1.125 sec 8 frames Batch 1.0625 sec Next Batch A/C address func CRC P Digital Paging word format CSA Rob Williams Pearson Education (c) 2006 CSA ch 16 - p 226 P 12 : 01 Enter car number first Tariff 1hr 40p Sun free Sat free Press for ticket Coins Application of packet radio data messaging customer premises Digital phone U ISDN i/f card Domestic Control maximum 8 devices NT1 Network terminator T ISDN Local Exchange Narrow Band ISDN defined interfaces Transmission Frame 48 bits in 250 µsecs D D D D B chan-1 B chan-2 B chan-1 B chan-2 2B-1D Narrowband ISDN protocol timing CSA Rob Williams Pearson Education (c) 2006 CSA ch 16 - p 227 0 0 0 1 1 0 1 1 0 1 0 1 1 0 1 Data 4B3T, Europe 0001 1011 0101 1010 2B1Q, USA 00 01 10 11 01 01 10 Multi-level baseband encoding Binar y data 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 3-level codes +0-+0 0-+ +-0 ++0 0++ +0+ +++ ++-++ +-+ +00 0+0 00+ 0+-0+ --0 0--0----+ +--+-00 0-0 00- Three-level 4B3T encoding table CSA Rob Williams Pearson Education (c) 2006 CSA ch 16 - p 228 Local Exchange Office PTT Local Exchage Voice Splitter ATM Switch DSL Modem Data Subscriber line 2.5 Km Subscriber premises Voice Splitter Data DSL Modem Digital Subscriber Line configuration Guard bands .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 04 Voice band 25 ..... . .. .. . .. . . . . . .. . .. . . . . . . . . . . . . . . . . . . . . . . . . . . .Data. . . . . . . . . . . up-link . . . . . . . . .band .. . . . . . . . . . . . . . . . . . . . . . . . 160 240 .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .... .. .. .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Data down-link . . . . . . . . . . . . band . . . . . . . . . . . . . . . . . . . . . . . . . . . Amplitude Frequency (kHz) 780 Subscriber line bandwidth allocation for ADSL CSA Rob Williams Pearson Education (c) 2006 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 PSTN Trunk lines Local Telephone Exchange Headend Set-top box Coax / Twisted Pair Twin cable Cable TV and telephone distribution scheme 5 40 54 MHz 59 Analogue TV Channels 575 600 750 Digital Outward Digital Inward Telephones Bandwidth allocation for a cable TV network CSA Rob Williams Pearson Education (c) 2006 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 filing 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 Rob Williams Pearson Education (c) 2006 CSA ch 17 - p 231 17. CSA - Introduction to Operating Systems, Unix IBM Ser ver On-line Batch Processing Real-time aw k ep gr Types of computer operating systems sed CSA ch 17 - p 232 CSA Rob Williams Pearson Education (c) 2006 BIOS boot h/w check Primary Bootstrap from disk Secondar y Bootstrap Unix kernel loaded init runs single user Multi-user mode star ts getty processes star ted login runs on demand Interactive user shell Unix boot sequence CSA Rob Williams Pearson Education (c) 2006 CSA ch 17 - p 233 Tool awk cat diff echo find grep lpr ls more ps sed sor t spell tr troff uniq users wc who Function text processing language opens and concatenates files file comparison repeats argument to stdout file 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 file sizer local user list Example cat file | awk ’$0 !˜ /ˆ$/ {print}’ cat header ch_01 | groff -petfH > /tmp/tmp.ps diff ch_01.a ch_01.b echo $PATH find ˜ -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’ file2 cat file | sort +1 -2 spell letter.txt tr -cs ’A-Za-z’ ’\012’ groff -petfH sor t | uniq -c | sort -n users > checkfile wc -w assignment.txt who Some Unix tools Tools API File manager Device drivers Applications GUI or Shell Scheduler Task dispatcher Graphic primitives Memor y allocation Computer hardware Typical operating system layered structure CSA Rob Williams Pearson Education (c) 2006 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 Summary contents of a TCB CSA Rob Williams Pearson Education (c) 2006 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 Task 3 Control Block Task stack area Tasks specified by their control blocks CSA Rob Williams Pearson Education (c) 2006 CSA ch 17 - p 236 TCB 1 Task stack area Task code TCB 2 Task stack area Task code TCB 3 Task stack area Task code TCB 4 Task stack area Task code Task Control Block queue CSA Rob Williams Pearson Education (c) 2006 CSA ch 17 - p 237 data ready Timed out Process Forked Exit Ready Executing i/o wait I/O Blocked Terminated Dispatched Freed Waiting Condition wait Zombie State Diagram showing the task lifecycle 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] Using ps & wc to count running tasks CSA Rob Williams Pearson Education (c) 2006 CSA ch 17 - p 238 UID PID PPID STIME (f,l) (all) (f,l) (f) 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. TTY TIME CMD S (all) (all) (all) (l) C (f,l) Information in the ps display, from the man page Time-slicing Demand preemption Cooperative Interrupt driven Process scheduling techniques CSA Rob Williams Pearson Education (c) 2006 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 Displaying Unix task list using ps CSA Rob Williams Pearson Education (c) 2006 CSA ch 17 - p 240 sched: init: pageout: fsflush: 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: filemgr: 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 flushes 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 file system (volume) management for CDROMs and floppy disk drives daemon to handle remote file 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 file manager, useful for floppy 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 Common Unix processes CSA Rob Williams Pearson Education (c) 2006 CSA ch 17 - p 241 Task 1 Task 2 Task 3 Task 4 Piping data between tasks in Unix rob> world > hello.txt rob> echo "Hello world!" > world.txt rob> tr "\r" < ch_10.asc > ch_10 rob> cat header ch_* > book rob> cat > letter Redirecting data from tasks and files in Unix Stdin 0 Unix process Stdout 1 Stderr 2 Standard I/O for Unix processes WAIT(sem_buff) . . . . //critical region code . . . . SIGNAL(sem_buff); Semaphore operators, WAIT and SIGNAL CSA Rob Williams Pearson Education (c) 2006 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 Semaphores protecting a cyclic data buffer #include #include #define MYSIG 44 /* Signal handler function, evoked by sig 44 reinstalls after each sig hit, prints number of hits */ void getsig(int s) { static int count = 0; printf("signal %d again, %dth time \n", s, ++count); signal(MYSIG, getsig); } /* Process to demonstrate signals, sets up a sig handler to count the number of sig hits received. Loops forever. Start using "kbdcnt &" and make note of pid value returned Recommend to use "kill -44 pid" to send signals Remove using "kill -9 pid" */ int main(void) { signal(MYSIG, getsig); printf("start counting kbd kills\n"); while(1) {}; return 0; } Unix signal handler to count and display signal hits CSA Rob Williams Pearson Education (c) 2006 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 compile the code run kbdcnt process send signal 44 Kill signal 44 kbdcnt Using a signal to notify a Unix process CSA Rob Williams Pearson Education (c) 2006 CSA ch 17 - p 244 #include #include #include #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 Rob Williams Pearson Education (c) 2006 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 Demonstrating the use of Signals by Unix Processes rob@olveston [52] a.out Child started Parent started Child hit! count = 1 Parent hit! count = 1 Child hit! count = 2 Parent hit! count = 2 Child hit! count = 3 Parent hit! count = 3 Child hit! count = 4 Parent hit! count = 4 Child hit! count = 5 ˆC rob@olveston [53] Signal demonstrator program running on Unix CSA Rob Williams Pearson Education (c) 2006 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] pid 469 Parent main() { cpid = fork(); 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] pid 469 Parent CMD tcsh trial trial main() { ...... ...... else { Parent continues ....... pid 472 Child main() { ...... if (cpid == 0 ) { Child process star t executing ...... Unix process creation using fork( ) Vir tual Address Segment number Page number Displacement Seg Table Reg Segment table Page table Vir tual to physical address translation sh csh bash tcsh ksh Original shell from Steve Bourne C shell from Bill Joy borne again shell Tenex shell, my favourite Korn shell, ver y popular Interactive Unix Shells CSA Rob Williams Pearson Education (c) 2006 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] Examples of shell command substitution echo "hello other window" > /dev/pts/0 value specifies which x-window to send to 0, 1, 2... CSA Rob Williams Pearson Education (c) 2006 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 Unix device drivers in directory /dev CSA Rob Williams Pearson Education (c) 2006 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\Exy %r %i %% %n %B %D 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 Some Unix termcap metacodes CSA Rob Williams Pearson Education (c) 2006 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 filing 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 Rob Williams Pearson Education (c) 2006 CSA ch 18 - p 252 18. CSA - Windows XP User Applications User Mode Win NT Subsystems Native API NT Executive Kernel Mode NT Kernel HAL Hardware Abstraction Layer Hardware Windows-NT/XP structure Applications Winr32 Subsys OS/2 Subsys Posix Subsys DOS Subsys Native API NT Kernel Win32 and the Kernel CSA Rob Williams Pearson Education (c) 2006 CSA ch 18 - p 253 Displaying the PC task list using the Task Manager CSA Rob Williams Pearson Education (c) 2006 CSA ch 18 - p 254 Registr y Editor windows displayed HKEY_LOCAL_MACHINE holds the hardware configuration, installed device drivers, network protocols, software classes. Configconfiguration parameters for local computer Enum device configuration Hardwareserial por t configuration Networkuser login information Securityremote administration permissions Softwareinstalled software Systembooting information HKEY_CURRENT_CONFIG holds the current hardware configuration, where options exist HKEY_CLASSES_ROOT HKEY_USERS HKEY_CURRENT_USER holds document types, file associations, shell interface holds login users’ software preferences and desktop configuration holds copies of the preferences of the curent user. Registr y top level keys CSA Rob Williams Pearson Education (c) 2006 CSA ch 18 - p 255 Setting network Shares and Permissions to a directory User name Passwords Machine name Workgroup names Share names 20 char 14 char 15 char 15 char 12 char Discrepency in effective string lengths CSA Rob Williams Pearson Education (c) 2006 CSA ch 18 - p 256 Installing a shared directory as a local virtual drive CSA Rob Williams Pearson Education (c) 2006 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 filing 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 Rob Williams Pearson Education (c) 2006 CSA ch 19 - p 258 19. CSA - Filing Systems Data organization Sequential Indexedsequential Direct Database Application type batch processing batch processing on-line on-line Advantages Simple, efficient difficult Sequential and direct access no data sorting No data sorting fast access flexible access Disadvantages Maintenance data needs sorting Index takes up space less efficient Space inefficient inconvenient to use Performance poor maintenance costs Data filing and databases Windows file browser showing the file hierarchy CSA Rob Williams Pearson Education (c) 2006 CSA ch 19 - p 259 Sun File Manager display with floppy disk browser Primary Par tition Secondar y Partitions Master Par tition Boot Record Hard Disk with Four Par titions CSA Rob Williams Pearson Education (c) 2006 CSA ch 19 - p 260 Cylinder 0 0 5 3 1 6 7 Cylinder 1 5 7 Cylinder 22 Cylinder 53 Cylinder 120 3 1 4 2 Platter 0 Platter 1 2 Platter 2 4 Platter 3 Drive spindle Alternative layouts for blocks 1, 2, 3, 4, 5 & 7 to reduce access times (Head Movement Delays) CSA Rob Williams Pearson Education (c) 2006 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 flag 3 Star t of partition 1 System Flag 3 End of Par tition 4 Star t of Sector 4 # sectors Disk Master Par tition Boot Record 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 A Par tition Boot Record (non Master) CSA Rob Williams Pearson Education (c) 2006 CSA ch 19 - p 262 file name file type owner id permissions file size create date disk address disk block Essential information for director y entries 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 . . . Unix mount table CSA Rob Williams Pearson Education (c) 2006 CSA ch 19 - p 263 file name TEST file ext DAT file attr reser v LBN create create 1st file time date cluster length CHS BIOS LBN Disk 4 10 9 8 FFFFH 8 3 1 10 2 2 2 4 bytes 7 6 5 4 3 6 10 Disk Directory: 32 byte entries FAT-16 Directory and File Allocation Table 7 Sector Size 512B 512B 512B 512B 512B Sectors per Cluster 4 16 32 64 16 Cluster Size 2kB 8kB 16kB 32kB 8kB Cluster Index Size 16bits 16bits 16bits 16bits 32bits Nax Volume Capacity 128MB 512MB 1GB 2GB 32TB 2 1 0 FAT FAT cluster size and volume capacity CSA Rob Williams Pearson Education (c) 2006 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 owner’s ID */ /* designated group id */ st_blocks; st_fstype[_ST_FSTYPSZ]; st_pad4[8]; /* expansion area */ Unix file system inode structure Boot Block Super Block owner uid gid of owner file type rwx access modes time of last access time modified time of inode change file 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 Unix inode file access records CSA Rob Williams Pearson Education (c) 2006 CSA ch 19 - p 265 directory name test.c inodp name name name name name name name name name inodp inodp inodp inodp inodp inodp inodp inodp inodp principal file 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 Data Block Data Block Data Block Unix inode pointers indicating a file’s data blocks CSA Rob Williams Pearson Education (c) 2006 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 Config 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 Data Block Data Block Data Block Relating Unix directories to the inode blocks CSA Rob Williams Pearson Education (c) 2006 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 Info Director y Block Name DOS Security Name Cluster Pointers Data Block Data Block Windows-NTFS Master File Table Read owner groupees any user Write/ delete Execute/ attach File and directory access control options CSA Rob Williams Pearson Education (c) 2006 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 RAID 1 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 Data Block RAID 5 strip 1 strip 2 strip 3 strip 4 chksum strip 5 strip 6 strip 7 chksum strip 8 strip 9 strip 10 chksum strip 11 strip 12 strip 13 chksum strip 14 strip 15 strip 16 chksum strip 17 strip 18 strip 19 strip 20 RAID disk configuations CSA Rob Williams Pearson Education (c) 2006 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] Sep 5 Sep 11 Jan 22 Apr 1 Sep 5 Sep 5 Apr 1 1998 1999 1999 1999 1998 1998 timezone tit to_arthur unzipit vorc vorcorn 1999 unzipit Apr 1 1999 unzipit Apr 1 1999 unzipit Setting File Access Permissions in Unix CSA Rob Williams Pearson Education (c) 2006 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 filing 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 Rob Williams Pearson Education (c) 2006 CSA ch 20 - p 271 20. CSA - Visual Output Display Full colour Reduced-range colour Grey-scale monochrome Black-white monochrome Pixel data 24 bits 8 bits 8 bits 1 bit Display size pixels 1024 x 768 Image size Bytes 2.25MB 0.75MB 0.75MB 96kB Data requirements for different display types Magnified view of pixels on the screen Vertical Fly Back Horizontal Fly Back Bitmapped raster display RGB electron guns Shadow mask BGR Glass front screen with phosphor coating Shadow mask inside a colour CRT CSA Rob Williams Pearson Education (c) 2006 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 Ver tical scan rate Hz 60 72 75 85 75 85 85 75 85 Horizontal scan rate kHz 31.5 37.8 46.9 53.7 60.0 68.8 77.6 80.0 91.2 Normal CRT horizontal and ver tical scan rates The time period for writing a single pixel onto the screen can be estimated: 1 = 21 ns/pixel 60 x 1024 x 768 100Hz driver clock light polarizing filter back plane electrode liquid crystal polarizing filter 0 1 Control signals in phase OFF out of phase ON Liquid crystal panels CSA Rob Williams Pearson Education (c) 2006 CSA ch 20 - p 273 Twisted nematic LCD panels, showing the polarized, ribbed panels CSA Rob Williams Pearson Education (c) 2006 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 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 Example pic script CSA Rob Williams Pearson Education (c) 2006 CSA ch 20 - p 275 * An SVG script, rendered by Firefox CSA Rob Williams Pearson Education (c) 2006 CSA ch 20 - p 276 DB-15 VGA socket to monitor HM64265/25 HM64265/25 Intel 740 Two tiered AGP connector An SVGA graphics adapter card with AGP interface Mono Hercules graphics CGA EGA VGA 1981 1983 1983 1984 1987 Text only mode offered by original 8088 PC First mono graphics card 720 x 348 first 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 640 x 480 320 x 200 (CGA) 1024 x 768 1280 x 1024 SVGA XGA 1990 1995 1997 Evolving range of standards for screen display CSA Rob Williams Pearson Education (c) 2006 CSA ch 20 - p 277 1 11 DVI-I dual standard monitor socket DB-15 SVGA Monitor Socket 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 - 29 pin DVI connector pinout and signal names Pin 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Mon id H Sync V Sync ground RED rtn GREEN rtn BLUE rtn key-pin SYNC rtn SVGA RED GREEN BLUE 15 pin SVG connector pinout and signal names CSA Rob Williams Pearson Education (c) 2006 CSA ch 20 - p 278 24bit colour value image pointer Y image data X 23 0 R G B 8 bits 8 bits 8 bits CRT DACs image base reg Display Memor y Driving a colour screen 23 0 8 bit colour # image pointer row column Y X image data image base reg RGB Palette table R G B 04 03 02 01 00 8 bits 8 bits 8 bits CRT Display Memory DACs Driving a PC screen using a palette table CSA Rob Williams Pearson Education (c) 2006 CSA ch 20 - p 279 65µs 14.31818 MHz Crystal Oscillator Pixel Clock 9 0 H Sync ÷ 1024 Line Clock 9 ÷ 60 0 Field Clock V Sync row 3 Screen column position Screen row position 0 60ms Raster control row 2 Display memor y 19 row 1 Display memory address Address to display memor y Synchronization of screen raster with display memor y CSA Rob Williams Pearson Education (c) 2006 CSA ch 20 - p 280 electron spray Erase lamp Cleaner Scanning head Hopper Paper Tray Toner paper feed Motor CPU IRQ Motor laser source PostScript Interpreter Memory I/O serial link from host computer 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 Rob Williams Pearson Education (c) 2006 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 fill /Times-Roman findfont 24 scalefont setfont 280 400 moveto 0 setgray (hello!) show showpage Ghostview, version 1.1 hello! ** emacs test1.ps PostScript development, script edited by emacs, rendered by ghostview CSA Rob Williams Pearson Education (c) 2006 CSA ch 20 - p 282 newpath 1 0 0 setrgbcolor 200 200 moveto 0 160 rlineto 160 0 rlineto 0 -160 rlineto closepath fill newpath 360 280 moveto -80 0 rlineto 80 -40 rlineto closepath 1 setgray fill newpath 380 280 105 180 135 arcn 48 0 rlineto 0 -40 rlineto closepath 1 setgray fill /Helvetica findfont 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 findfont 42 scalefont setfont 1 0 0 setrgbcolor -60 -40 rmoveto (BRISTOL) show showpage Ghostview, version 1.1 ** emacs uwe_pacman.ps More PostScript, but now in colour! gs -dNOPAUSE -dBATCH -r1200 -sDEVICE=pdfwrite -sOutputFile=ch_16.pdf ch_16. UWE BRISTOL CSA Rob Williams Pearson Education (c) 2006 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˜ Comparing file sizes: ASCII, ps and pdf CSA Rob Williams Pearson Education (c) 2006 CSA ch 20 - p 284 %PDF-1.0 1 0 obj > endobj 6 0 obj [/PDF /Text] endobj 7 0 obj >> endobj endobj xref 3 0 obj 0 8 > 0000000179 00000 n endobj 0000000322 00000 n 0000000415 00000 n 4 0 obj 0000000445 00000 n /Contents 5 0 R startxref >> 553 endobj %%EOF 5 0 obj > stream BT /F1 72 Tf 100 50 Td (Hello World!) Tj ET endstream endobj The "Hello World!" example in pdf code CSA Rob Williams Pearson Education (c) 2006 CSA ch 20 - p 285 Viewing the pdf File using Adobe Acrobat CSA Rob Williams Pearson Education (c) 2006 CSA ch 20 - p 286 File Edit View New Load Save Save As Quit HyperBase _ Layout of a typical window scheme CSA Rob Williams Pearson Education (c) 2006 CSA ch 20 - p 287 Vir tual Device Inferface (GDI) Bitmaps, Icons & Metafiles 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 Win32 API facilities CSA Rob Williams Pearson Education (c) 2006 CSA ch 20 - p 288 #include int WINAPI WinMain(HINSTANCE a, HINSTANCE b, LPSTR c, int d) { MessageBox(NULL, "Hello Worle!", "WSM", MB_OK); return NULL; } Your first Windows application CSA Rob Williams Pearson Education (c) 2006 CSA ch 20 - p 289 Application Code Intrinsics Widgets X-Lib X-Windows Programming 80 63 0 127 0 mm7 mm6 mm5 mm4 mm3 mm2 mm1 mm0 f/p mmx xmm7 xmm6 xmm5 xmm4 xmm3 xmm2 xmm1 xmm0 MMX and SSE data registers CSA Rob Williams Pearson Education (c) 2006 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 filing 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 Rob Williams Pearson Education (c) 2006 CSA ch 21 - p 291 21. CSA - RISC Processors Application code Operating System CU Microcode H/w Logic Units Functional hierarchy Sun Microsystems’ UltraSparc II CSA Rob Williams Pearson Education (c) 2006 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. Simplified interrupt facilities Principal features of RISC CPUs MHz 1000 AMD Athlon AMD K7 Pentium II Pentium Pro Pentium i486 100 10 i8086 i386 1 1970 i8080 1980 1985 1990 1995 2000 Increasing clock speed of microprocessors CSA Rob Williams Pearson Education (c) 2006 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. CPU stack registers Variety of parameter passing methods CSA Rob Williams Pearson Education (c) 2006 CSA ch 21 - p 294 Fetch Decode Readin Execute Writeback Cycle 1 Cycle 2 Cycle 3 Cycle 4 Cycle 5 Cycle 6 System Clock JMP NOP NOP NOP NOP AND ADD JMP NOP NOP NOP NOP ADD JMP NOP NOP NOP ADD JMP NOP NOP ADD JMP NOP Multi-stage pipeline decoding - parallel processing LD/ST IF ID INT RO WB 1 2 FP 4 5 A 5 stage superscalar achitecture with 3 execution units CSA Rob Williams Pearson Education (c) 2006 CSA ch 21 - p 295 Dependency Type Data 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 floating-point arithmetic Blocked until... EAX is loaded EAX is read sequence correct Z flag set Control the outcome of a previous instruction is essential for an instruction to complete limited availability of hardware resources Resource unit free Instruction pipeline dependencies CSA Rob Williams Pearson Education (c) 2006 CSA ch 21 - p 296 prefetchdecoderoperand execute store buffer stage 1 read result Register File Instructions from memor y ALU A Pipeline A Pre fetcher unit PC ALU B Pipeline B ALU C Pipeline C Use of Register File Store with superscalar processors CSA Rob Williams Pearson Education (c) 2006 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 Conditional Instruction address Branch Target address Prediction Confidence Value Control Unit Branch Prediction Table CSA Rob Williams Pearson Education (c) 2006 CSA ch 21 - p 298 Version v1 v2 v2a v3 v3M v4 v4T 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 first 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 Historic revisions of ARM architectures CSA Rob Williams Pearson Education (c) 2006 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_fiq spsr_irq spsr_svc spsr_undef spsr_abt Fast interrupt request r8_fiq r9_fiq r10_fiq r11_fiq r12_fiq r13_fiq r14_fiq Interrupt request r13_irq r14_irq Super visor trap r13_svc r14_svc Undefined exception r13_undef r14_undef Abor t error r13_abt r14_abt ARM CPU registers, showing the alternate sets CSA Rob Williams Pearson Education (c) 2006 CSA ch 21 - p 300 1 11 7 6 5 4 3 0 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 12 bit displacement (unsigned) 12 11 0 condition 01 # P U B W L Rn Rd offset field 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) Instruction formats for the ARM ldr & str instructions Condition codes 31 27 24 23 8 4 0 N Z C V Q J i F t SVC Jazelle Saturated Overflow Carr y out Zero value Negative value, msb==1 Thumb mode enabled Fast interrupt enabled Interrupt enabled ARM program status register CSA Rob Williams Pearson Education (c) 2006 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 overflow no overflow 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 ARM condition codes mov Rn, Rm ldr Rn, [Rm] str Rn, [Rm] add R0, R1, R2 cmp R0, R1 b addr bl addr mov R15, R14 ldmfd R13!, {Rm-Rn} stmfd R13!, {Rm-Rn} ldr Rn, =constant adr Rn, label copy data between registers get a variable from memory put a variable back in memory add two registers, result in third compare two registers jump to relative location (+ 32 MB) _ call subroutine (+ 32MB) _ return from subroutine pop registers from stack push registers onto stack Basic "starter" instructions for the ARM processor CSA Rob Williams Pearson Education (c) 2006 CSA ch 21 - p 302 1 11 8 7 0 shift-size 8 bit immediate data 11 0 OR 7 6 5 4 3 0 shift-size sh/rot 0 11 Rindex 0 0 mov and/add/sub/cmp tst/and/orrrrr/eor/bic 31 28 27 26 25 24 21 20 19 16 15 OR Rshift 8 4 6 5 4 3 0 sh/rot 1 Rindex 0 12 11 condition 00 # opcode S Rn Rd operand 2 destination register operand register set condition status flags 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 Instruction formats for move, arithmetic & logical instructions CSA Rob Williams Pearson Education (c) 2006 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 transflective 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 HP iPAQ hx4700 series Pocket PC CSA Rob Williams Pearson Education (c) 2006 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 RAS/CAS3 RAS/CAS2 RAS/CAS1 RAS/CAS0 CS5 CS4 PSTSEL !PSTSEL CS3 CS2 CS1 CS0 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 internal to SA1110 StrongARM 0000_0000H SA1110 StrongARM 4 GByte memory map CSA Rob Williams Pearson Education (c) 2006 CSA ch 21 - p 306 next PC → Pipeline 16 KByte incr PC op code → Stage 0 Fetch instr IR-0 from I-cache +4 I-cache ← branch offset R15/PC ↓ reg write decoder Stage 1 Decode, reg read, get branch addr. branch ←addr +disp Register File immediate fields ↓ IR-1 decoder +4 shifter Stage 2 Execute ALU/shift, LD/ST mem addr. ALU & multiply mux IR-2 B-repl 8 KByte → LD/ST address 0.5 KByte Minicache D-cache Stage 3 D-cache LD/ST rotate IR-3 Write Register Stage 4 Result write-back Block diagram for the StrongARM core CSA Rob Williams Pearson Education (c) 2006 CSA ch 21 - p 307 3.686 MHz 32.768 KHz oscil oscil PLL PLL IMMU DMMU Icache Dcache Minicache write buff ARM SA-1 core JTAG i/f RTC OS timer GP I/O Intr Cntrl Pwr Mngt Rst Contrl read buff LCD control Bridge DMA control Memory & PCMCIA control Serial channel 4 CODEC Serial channel 0 USB Serial channel 1 UART Serial channel 2 IrDA Serial channel 3 UART A -A 0 25 D0-D31 Intel SA1110 StrongARM microcontroller CSA Rob Williams Pearson Education (c) 2006 CSA ch 21 - p 308 31 23 0 OUT 7 LOCAL OUT 0 GLOBAL cwp 0 IN LOCAL OUT IN LOCAL OUT CPU registers IN LOCAL Save IN system stack Restore Main Memory Operation of the Register File during procedure calls CSA Rob Williams Pearson Education (c) 2006 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 filing 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 Rob Williams Pearson Education (c) 2006 CSA ch 22 - p 310 22. CSA - The EPIC Itanium processor L1 Icache L1 Dcache L2 L3 main memory Clock System bus CPU power 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 0) min = j; pctemp = pc[min]; pc[min] = pc[i]; pc[i] = pctemp; for(k=0; k