OMSE%20510:%20Computing%20Foundations%20Intro%20Lecture - PowerPoint PPT Presentation

About This Presentation
Title:

OMSE%20510:%20Computing%20Foundations%20Intro%20Lecture

Description:

00000000 52 6F 6C 65 78 20 4E 65 77 62 69 65 20 46 41 51 Rolex Newbie FAQ ... 00000050 20 6D 79 20 6E 65 77 20 72 6F 6C 65 78 3F 0D 0A my new rolex? ... – PowerPoint PPT presentation

Number of Views:103
Avg rating:3.0/5.0
Slides: 72
Provided by: franci52
Learn more at: http://web.cecs.pdx.edu
Category:

less

Transcript and Presenter's Notes

Title: OMSE%20510:%20Computing%20Foundations%20Intro%20Lecture


1
OMSE 510 Computing FoundationsIntro Lecture
  • Chris Gilmore ltgrimjac_at_cs.pdx.edugt
  • Portland State University/OMSE

2
Website/mailing list
  • Website
  • http//web.cecs.pdx.edu/grimjack/OMSE510CF/Comput
    erFoundations.html
  • Mailing List
  • omse510_at_cecs.pdx.edu
  • Personal Email
  • grimjack_at_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
  1. I like feedback
  2. Its good to ask questions in class. Email is
    less good.
  3. If you dont understand, ask NOW. Probably other
    people dont understand. And we always build on
    existing material.
  4. One or two breaks in a 3 hour class.


7
The Basics
Todays lecture covers the very basics should
probably be review! If youre bored, thats
good! The interesting stuff comes later

8
Todays Lecture
  • Amdahls Law
  • Data Representation
  • Conventions (binary/hex/oct)
  • Unsigned/signed integers
  • Floating point
  • Brief on Compilers


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

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

11
Speedup
But time is important to us! Lets 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! Thats 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) Whered 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
Amdahls Law
The variables told 245 mins (Original
travel time) a 33 (Time actually spent
flying) k 2 (Speedup factor) tnew (1-a)
told x a told / k 66 245
mins x 33 245 mins / 2 205 mins

17
Amdahls Law
Speedup, S S told /tnew 1 / (1-a) a /k
1.2 Much less than 2x! Moral of the
story To improve the system, you have to work
harder than you want

18
Amdahls Law
Special case set k 8 S8 1 / (1
a) Most amount of speedup you can get out of
tuning one component. ie. Are you wasting your
time?

19
Amdahls 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 -gt Numbers Pictures -gt
Numbers Programs -gt 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 its 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 a104 b103
c102 d101 e100 110000 21000 3100
410 51 10000 2000 300 40 5
12345

26
Binary
Binary (Base 2) 10101 abcde Number a24
b23 c22 d21 e20 116 08 14
02 11 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 a84
b83 c82 d81 e80 14096 2512 364
48 51 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 0
5 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 a164
b163 c162 d161 e160 165536
24096 3256 416 51 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 1011
11 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
._at_ 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 weve 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 Twos 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 theres a lot
of good reasons for it

43
Twos 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 reqd reading )


44
Ones 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 theres 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 Twos
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 -gt Binary 0.5 -gt .1 1.5
-gt 1.1 2.5 -gt 10.1 0.25 -gt 0.01 0.75 -gt
0.11

47
Binary
This follows from our original definition 1010.101
0 abcd.efgh Number a23 b22 c21 d20
e2-1 f2-2 g2-3 h2-4
18 04 12 01 11/2
01/4 11/8 01/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. Lets 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

51
IEEE Floating Point
Standardized representation of floating
point (-1) sign mantissa 2exponent So
since our decimal point is floating, we have a
much larger expressible range. The mantissa is
unsigned, The exponent is expressed in bias
notation. Brian OHallaron calls it
significand instead of mantissa

52
IEEE Floating Point
An in-depth example (-1) sign mantissa
2exponent Suppose we have 9 bits to play with
sign (1 bit) mantissa (4 bits) exponent
(4 bits) sign s 0 or 1 mantissa, M Fixed point
number in the range 1,2) exponent, E Bias
notation in the range -6,7 Why not -7,8?
Those values used for something special

53
IEEE Floating Point
sign (1 bit) mantissa (4 bits) exponent
(4 bits) s abcd efgh Mantissa
Fixed point notation implied decimal
point a.bcd eg. 1.0 -gt
1.000 1.125 -gt 1.001 1.25 -gt 1.010 1.5
-gt 1.100 1.75 -gt 1.110

54
IEEE Floating Point
The mantissa encodes a value in the range
1,2) Realization The most significant digit is
always 1! Dont need to encode it! sign (1
bit) mantissa (4 bits) exponent (4 bits)
s 1.abcd efgh So the mantissa
has a precision of 2-4 1/16

55
IEEE Floating Point
sign (1 bit) mantissa (4 bits) exponent
(4 bits) s 1.abcd efgh Expone
nt, E has k-bits, in bias notation Bias is
2k-1-1 7 So the range is -7,8

56
IEEE Floating Point

Encoding Table
57
IEEE Floating Point
sign (1 bit) mantissa (4 bits) exponent
(4 bits) s 1.abcd efgh Specia
l Values for Exponent, E If exponent field is
all 0s, the number is considered denormalized
Mantissa does not have an implied leading 1. If
exponent field is all 1s, then theres a special
interpretation to encode values such as infinity,
and NaN So the range becomes is -6,7

58
IEEE Floating Point

Encoding Table
59
IEEE Floating Point
  • Closing notes
  • Some numbers, such as 0.2 cannot be represented
    exactly using any of the formats weve described
  • IEEE 32-bit Single-precision float (c float
    usually)
  • 1 sign bit, 23-bit mantissa, 8-bit exponent
  • Approximately 7 decimal digits of precision
  • IEEE 64-bit Double-precision float (c double
    usually)
  • 1 sign bit, 52-bit mantissa, 11-bit exponent
  • Rounding imprecision is a BIG problem with
    floating point numbers.
  • bool equal( float x, float y ) // Never do this
  • if ( x y ) return true
  • else return false
  • printf rounds floats to be more human readable


60
Units
  • Some terminology
  • - Byte Smallest addressable unit on an
    architecture. Usually an octet (8 bits)
  • Nibble Half a byte (4 bits)
  • Word Natural Unit of data on the architecture
  • 8086 8 bits IA32, PPC 32 bits
  • (Often the size of address space)
  • Dword (Double word), Quad-word
  • Caches often like 64 bytes (x86)
  • Memory Pages (x86 4096 bytes)
  • Disk Sectors (512 bytes common)


61
Units (for engineers)
b bits B bytes KB Kilobyte 210 1024 MB
Megabyte 220 10241024 1048576 GB
Gigabyte 230 1073741824 TB Terrabyte 240
1099511627776 Note MB Megabyte, Mb
Megabit k and K are used interchangeably

62
Units (for marketing)
b bits B bytes KB Kilobyte 10 1000 MB
Megabyte 102 1,000,000 GB Gigabyte 103
1,000,000,000 TB Terrabyte 104
1,000,000,000,000 Reason Makes numbers seem
bigger and cooler Note MB, mb, Mb all used
interchangeably

63
Computer System (Idealized)
Disk
Memory
CPU
Disk Controller
64
Making Programs
cat hello.c include ltstdio.hgt int main()
printf( "Hello, world\n" ) return 0
./hello Hello, world

65
Making Programs
But the computer doesnt understand C code! C is
for humans. Machine code looks like
this 00000000 4d5a 9000 0300 0000 0400 0000
ffff 0000 MZ.............. 00000010 b800 0000
0000 0000 4000 0000 0000 0000 8......._at_....... 000
00020 0000 0000 0000 0000 0000 0000 0000 0000
................ 00000030 0000 0000 0000 0000
0000 0000 8000 0000 ................ 00000040
0e1f ba0e 00b4 09cd 21b8 014c cd21 5468
....4.M!8.LM!Th 00000050 6973 2070 726f 6772
616d 2063 616e 6e6f is program canno 00000060
7420 6265 2072 756e 2069 6e20 444f 5320 t be run
in DOS 00000070 6d6f 6465 2e0d 0d0a 2400 0000
0000 0000 mode........... 00000080 5045 0000
4c01 0400 0951 ee42 000c 0000 PE..L....QnB.... 000
00090 f800 0000 e000 0703 0b01 0238 0004 0000
x.........8.... 000000a0 0004 0000 0002 0000
0010 0000 0010 0000 ................ 000000b0
0000 0000 0000 4000 0010 0000 0002 0000
......_at_.........

66
Enter the compiler
The compiler translates C to machine code
Hello.c (text file)
Hello (binary object)
Compiler Magic

gcc hello.c o hello ./hello Hello, world
67
Compilation System
Demystifying (slightly)
Hello.i (preprocessed simplified c)
Hello.o (preprocessed simplified c)
Hello.c (c code)
Hello (binary object)
Prepro- cessor
Compiler
Assembler
Compilation is divided into stages to simplify
it. Lets follow through hello world example
68
Step 0 Source
Start with source code include ltstdio.hgt int
main() printf( "Hello, world\n" ) return
0

69
Step 1 Preprocess stage
Translates C to simplified C. Translates
macros, resolves file references, preprocessor
conditionals include ltfile.hgt if, ifdef,
else, endif define gcc -E hello.c gthello.i

70
Step 2 Compilation Stage
  • Translates preprocessed C into a simple language
    called Assembly. Still human-readable, but
    barely. Very close to machine language
  • pushl ebp
  • movl esp, ebp
  • subl 8, esp
  • andl -16, esp
  • movl 0, eax
  • addl 15, eax
  • addl 15, eax
  • shrl 4, eax
  • sall 4, eax
  • movl eax, -4(ebp)
  • movl -4(ebp), eax
  • call __alloca
  • call ___main
  • movl LC0, (esp)
  • call _printf
  • movl 0, eax
  • leave
  • ret


71
Step 3 Assembling stage
Translates assembly to machine code. This stage
is very simple 11 mapping between assembly and
machine code 00000070 0000 0000 0000 0000 0000
0000 0000 0000 ................ 00000080 0000
0000 0000 0000 8000 00c0 2e72 6461
..........._at_.rda 00000090 7461 0000 0000 0000
0000 0000 1000 0000 ta.............. 000000a0
f400 0000 0000 0000 0000 0000 0000 0000
t............... 000000b0 4000 0040 5589 e583
ec08 83e4 f0b8 0000 _at_.._at_U.e.l..dp8.. 000000c0
0000 83c0 0f83 c00f c1e8 04c1 e004 8945
..._at_.._at_.Ah.A..E 000000d0 fc8b 45fc e800 0000
00e8 0000 0000 c704 .Eh....h....G. 000000e0
2400 0000 00e8 0000 0000 b800 0000 00c9
....h....8....I 000000f0 c390 9090 4865 6c6c
6f2c 2077 6f72 6c64 C...Hello, world gcc -c
hello.s o hello.o
Write a Comment
User Comments (0)
About PowerShow.com