1 / 71

OMSE 510: Computing Foundations Intro Lecture

OMSE 510: Computing Foundations Intro Lecture. Chris Gilmore <grimjac@cs.pdx.edu> Portland State University/OMSE. Website/mailing list. Website http://web.cecs.pdx.edu/~grimjack/OMSE510CF/ComputerFoundations.html Mailing List: omse510@cecs.pdx.edu Personal Email: grimjack@cs.pdx.edu.

Download Presentation

OMSE 510: Computing Foundations Intro Lecture

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. OMSE 510: Computing FoundationsIntro Lecture Chris Gilmore <grimjac@cs.pdx.edu> Portland State University/OMSE

  2. Website/mailing list • Website http://web.cecs.pdx.edu/~grimjack/OMSE510CF/ComputerFoundations.html • Mailing List: omse510@cecs.pdx.edu • Personal Email: grimjack@cs.pdx.edu

  3. About OMSE510 • Course Rationale: This course has been designed for graduate level software engineering students who are lacking key foundation computer science knowledge in the areas of computer architecture and operating systems. This course may also be taken by students needing or wanting to upgrade their knowledge in these areas. With the approval of an OMSE advisor, OMSE students may register in this course and count it for credit as an OMSE elective.

  4. Course Structure Divided into two halves • Computer Architecture • How the hardware works • 4 Sessions + Midterm • Operating Systems • How the software interacts with the hardware • 5 Sessions + Final • Four Assignments (40%), Midterm (30%), Final (30%)

  5. Things not covered • Transistors, logic gates & Lower-level functionality • In-depth Floating Point/Integer Arithmetic • Networking • Hardware Description Languages (Verilog, ISP’) • Security • The History of anything • Theoretical Architectures

  6. First Note • I like feedback • It’s good to ask questions in class. Email is less good. • If you don’t understand, ask NOW. Probably other people don’t understand. And we always build on existing material. • One or two breaks in a 3 hour class.

  7. The Basics Today’s lecture covers the very basics – should probably be review! If you’re bored, that’s good! The interesting stuff comes later

  8. Today’s Lecture • Amdahl’s Law • Data Representation • Conventions: (binary/hex/oct) • Unsigned/signed integers • Floating point • Brief on Compilers

  9. Amdahl’s Law Fundamental design principle in computer architecture design. Make things FAST. Amdahl’s law is a guideline for making things faster.

  10. Speedup Suppose some task that takes time torigminutes to perform Eg. Flying from PDX to YVR, 80 mins Boeing 727, ~900 km/h

  11. Speedup But time is important to us! Let’s take the Concorde instead! Flying from PDX to YVR - Boeing 727, ~900 km/h, 80 mins - Concorde, ~2200 km/h, 40 mins 40 minutes saved!

  12. Speedup Flying from PDX to YVR told = 80 mins (Boeing 727) tnew = 40 mins (Concorde) Speedup = = = 2 2x speed improvement! That’s great! .. But is it really? told tnew 80 min 40 min

  13. Speedup Time actually spent traveling from PDX to YVR: 30 mins MAX to airport 20 mins getting your ticket 45 mins getting through security 30 mins boarding/taxiing 80 mins flying 40 mins landing + customs = 245 minutes

  14. Speedup Time actually spent traveling from PDX to YVR: 245 minutes (Boeing 747) 205 minutes (Concorde) Where’d that 2x speedup go?

  15. Speedup 30 mins MAX to airport 20 mins getting your ticket 45 mins getting through security 30 mins boarding/taxiing 80 mins flying 40 mins landing + customs = 245 minutes Only 33% of total time!

  16. Amdahl’s Law The variables: told = 245 mins (Original travel time) α= 33% (Time actually spent flying) k = 2 (Speedup factor) tnew = (1-α) toldx α told / k = 66% * 245 mins x 33% * 245 mins / 2 = 205 mins

  17. Amdahl’s Law Speedup, S S = told /tnew = 1 / [ (1-α) + α /k ] = 1.2 Much less than 2x! Moral of the story: To improve the system, you have to work harder than you want

  18. Amdahl’s Law Special case – set k = ∞ S∞ = 1 / (1 – α) Most amount of speedup you can get out of tuning one component. ie. Are you wasting your time?

  19. Amdahl’s Law Most important to Computer Architecture/Operating system design: Speed! Not necessarily like regular programming. More important than correctness (almost)

  20. Data Representation Foundation Idea #2: Computers represent everything with numbers

  21. Data Representation Everything in a computer is represented as a number. Letters -> Numbers Pictures -> Numbers Programs -> Numbers Data = Numbers

  22. Numbers in different bases (This should be old hat for you) Non-negative Integers: Decimal (Human) Numbers: 0,1,2,…..256, …. 1024… 2048….

  23. Binary Data in computers only exist in 2 states, on and off. (1 or 0) This means it’s hard for them to count in decimal…

  24. Decimal / Binary Decimal Binary 0 0 1 1 2 10 3 11 4 100 5 101

  25. Decimal Decimal 12345 = abcde Number = a*104 + b*103 + c*102 + d*101 + e*100 = 1*10000 + 2*1000 + 3*100 + 4*10 + 5*1 = 10000 + 2000 + 300 + 40 + 5 = 12345

  26. Binary Binary (Base 2) 10101 = abcde Number = a*24 + b*23 + c*22 + d*21 + e*20 = 1*16 + 0*8 + 1*4 + 0*2 + 1*1 = 16 + 0 + 4 + 0 + 1 = 21

  27. Decimal / Binary Decimal Binary 0 0 1 1 2 10 3 11 4 100 5 101

  28. Octal/Hex Okay, computers like binary… But binary is too hard to read for humans. … But we want to express powers of two conveniently Octal 00, 01, 02,…, 07, 010, … 017, 020…..

  29. Octal Octal (Base 8) 012345 = 0abcde Number = a*84 + b*83 + c*82 + d*81 + e*80 = 1*4096+ 2*512 + 3*64 + 4*8 + 5*1 = 4096 + 1024 + 192 + 32 + 5 = 5349

  30. Decimal / Binary /Octal Decimal Binary Octal 0 0 00 1 1 01 2 10 02 3 11 03 4 100 04 5 101 05 8 1000 010 12 1100 014 47 101111 057

  31. Hexedecimal But octal still cumbersome, because computers often prefer grouping in sets of 4 binary digits. (Octal groups bits in sets of 3) Hex Format (The preferred choice) 0x0, 0x1, 0x2,…0xf, 0x10, 0x11, .. 0x1a,0x20

  32. Hexedecimal Hex (Base 16) 0x12345 = 0xabcde Number = a*164 + b*163 + c*162 + d*161 + e*160 = 1*65536+ 2*4096 + 3*256 + 4*16 + 5*1 = 65536 + 8192 + 768 + 64 + 5 = 74565

  33. Hexedecimal Hex Digits: Need more than 10 digits (0-9) So we use a b c d e f Decimal: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 Hexedecimal: 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF, 0x10,0x11

  34. Decimal / Binary /Octal / Hex Decimal Binary Octal Hex 0 0 00 0x0 1 1 01 0x1 2 10 02 0x2 3 11 03 0x3 4 100 04 0x4 5 101 05 0x5 8 1000 010 0x8 12 1100 014 0xC 47 101111 057 0x2F *Chinese Remainder Theorem to convert

  35. ASCII Oct Dec Hex Char ------------------------------- 101 65 41 A 102 66 42 B 103 67 43 C 104 68 44 D 105 69 45 E 106 70 46 F 107 71 47 G 110 72 48 H 111 73 49 I 112 74 4A J 113 75 4B K 114 76 4C L 115 77 4D M Oct Dec Hex Char ------------------------------- 116 78 4E N 117 79 4F O 120 80 50 P 121 81 51 Q 122 82 52 R 123 83 53 S 124 84 54 T 125 85 55 U 126 86 56 V 127 87 57 W 130 88 58 X 131 89 59 Y 132 90 5A Z

  36. Text in ASCII Rolex Newbie FAQ Is it okay to peel off the hologram sticker from the back of my new rolex? Yes. It will not devalue your watch, nor void your warranty. Hologram stickers are not a good way of differentiating real and fake Rolexes. Even fake ones often come with a hologram sticker. 00000000 52 6F 6C 65 78 20 4E 65 77 62 69 65 20 46 41 51 Rolex Newbie FAQ 00000010 0D 0A 0D 0A 49 73 20 69 74 20 6F 6B 61 79 20 74 ....Is it okay t 00000020 6F 20 70 65 65 6C 20 6F 66 66 20 74 68 65 20 68 o peel off the h 00000030 6F 6C 6F 67 72 61 6D 20 73 74 69 63 6B 65 72 20 ologram sticker 00000040 66 72 6F 6D 20 74 68 65 20 62 61 63 6B 20 6F 66 from the back of 00000050 20 6D 79 20 6E 65 77 20 72 6F 6C 65 78 3F 0D 0A my new rolex?.. 00000060 20 59 65 73 2E 20 49 74 20 77 69 6C 6C 20 6E 6F Yes. It will no 00000070 74 20 64 65 76 61 6C 75 65 20 79 6F 75 72 20 77 t devalue your w 00000080 61 74 63 68 2C 20 6E 6F 72 20 76 6F 69 64 20 79 atch, nor void y 00000090 6F 75 72 20 77 61 72 72 61 6E 74 79 2E 20 48 6F our warranty. Ho 000000A0 6C 6F 67 72 61 6D 20 73 74 69 63 6B 65 72 73 0D logram stickers. 000000B0 0A 20 61 72 65 20 6E 6F 74 20 61 20 67 6F 6F 64 . are not a good 000000C0 20 77 61 79 20 6F 66 20 64 69 66 66 65 72 65 6E way of differen

  37. Pictures in Binary Each Pixel is a 3-tuple, (Red, Green, Blue)

  38. Pictures in Binary $ dump lena.jpg 00000000 ffd8 ffe0 0010 4a46 4946 0001 0101 0048 .X.`..JFIF.....H 00000010 0048 0000 ffdb 0043 0006 0404 0405 0406 .H...[.C........ 00000020 0505 0609 0605 0609 0b08 0606 080b 0c0a ................ 00000030 0a0b 0a0a 0c10 0c0c 0c0c 0c0c 100c 0e0f ................ 00000040 100f 0e0c 1313 1414 1313 1c1b 1b1b 1c20 ............... 00000050 2020 2020 2020 2020 20ff db00 4301 0707 .[.C... 00000060 070d 0c0d 1810 1018 1a15 1115 1a20 2020 ............. 00000070 2020 2020 2020 2020 2020 2020 2020 2020 00000080 2020 2020 2020 2020 2020 2020 2020 2020 00000090 2020 2020 2020 2020 2020 2020 2020 ffc0 .@ 000000a0 0011 0802 5803 2003 0111 0002 1101 0311 ....X. ......... 000000b0 01ff c400 1c00 0001 0501 0101 0000 0000 ..D............. 000000c0 0000 0000 0000 0200 0103 0405 0607 08ff ................ 000000d0 c400 5310 0001 0203 0406 0607 0408 0307 D.S............. 000000e0 0303 0403 0102 0300 0411 0512 2131 0613 ............!1.. 000000f0 2241 5161 1432 7181 91a1 0723 4252 b1c1 "AQa.2q..!.#BR1A

  39. Unsigned Numbers All the numbers we’ve discussed are unsigned. (ie. Non-negative integers) Assume 8-bits of information: Eg. 0000 0000 = 0 0000 0001 = 1 1000 0000 = 128 1111 1111 = 255 Range is [0,255]

  40. Signed Numbers What if we want to represent negative numbers? Naïve Solution: Sign/Magnitude Notation Use first bit to represent +/- (sign bit) Eg. 0000 0000 = 0 0000 0001 = 1 1000 0001 = -1 0111 1111 = 127 1111 1111 = -127 Range is [-127,127]. But this is wasteful! There are two ways of representing 0! (+0, -0)

  41. Signed Numbers Another approach: Bias Notation Take the unsigned number, subtract b (eg. b = 127) Eg. 0000 0000 = 0 – 127 = -127 0000 0001 = 1 – 127 = -126 0111 1111 = 127 – 127 = 0 1000 0000 = 128 – 127 = 1 1111 1111 = 255 – 127 = 128 Range is [-127,128]. This works, and has its purposes, but usually we prefer….

  42. Signed Numbers Usual approach: Two’s Compliment MSB is considered to have negative weight. Eg. 0000 0000 = 0 0000 0001 = 1 1111 1111 = -1 1000 0000 = – 128 0111 1111 = 127 Range is [-128,127]. It seems goofy, but there’s a lot of good reasons for it

  43. Two’s Complement Advantages: • Easy to negate: Take the bitwise complement, add one • Efficient – adding and what logical operator? • Overflow is handled “gracefully” • Easy to tell if a number is negative – if MSB is set • More details in your req’d reading :)

  44. One’s Compliment Ones’ Compliment: Mostly theoretical (noone uses it) MSB is considered to have weight –(2w-1-1) instead of 2w-1. (eg. MSB = -127 instead of -128) Eg. 0000 0000 = 0 0000 0001 = 1 1111 1110 = -1 1000 0000 = – 127 0111 1111 = 127 1111 1111 = 0 Range is [-127,127]. Note again there’s two ways of representing 0

  45. What about fractions? Okay great, we know how to represent all kinds of integers: Non-negative Integers: Unsigned format Integers: Sign-Magnitude Bias Notation Two’s Complement Ones’ Complement But how do we represent fractional numbers? Eg. ½

  46. What about fractions? Idea: How do we represent it in decimals? ½ = 0.5 We can introduce a decimal point to binary: Decimal -> Binary 0.5 -> .1 1.5 -> 1.1 2.5 -> 10.1 0.25 -> 0.01 0.75 -> 0.11

  47. Binary This follows from our original definition 1010.1010 = abcd.efgh Number = a*23 + b*22 + c*21 + d*20 + e*2-1 + f*2-2 + g*2-3 + h*2-4 = 1*8 + 0*4 + 1*2 + 0*1 + 1*1/2 + 0*1/4 + 1*1/8 + 0*1/16 = 8 + 2 + .5 + .125 = 10.675

  48. Fixed Point So if we have 8 bits of information, and we say that the decimal point occurs between the two sets of 4 bits, we have a convention for representing fractions: 0000 0000 = 0 0001 0000 = 1 0000 1000 = 0.5 0001 1000 = 1.5 1010 1010 = 10.675 So called Fixed Point representation

  49. Fixed Point But with n bits, our range is still very small. [0,2w/2) We want to be able to express a very large range (and negative numbers) very compactly. Let’s think about scientific notation: 1.2e10 = 1.2 * 1010 Binary Equivalent!

  50. Floating Point Binary equivalent of scientific notation is called “floating point” value * 2exponent So since our decimal point is “floating”, we have a much larger expressible range

More Related