introduction to programming
play

Introduction to Programming Bertrand Meyer Last revised 1 December - PowerPoint PPT Presentation

1 Introduction to Programming Bertrand Meyer Last revised 1 December 2003 I ntroduction to Programming Lecture 15 Chair of Softw are Engineering 2 Lecture 15: A glimpse into the hardware I ntroduction to Programming Lecture 15


  1. 1 Introduction to Programming Bertrand Meyer Last revised 1 December 2003 I ntroduction to Programming – Lecture 15 Chair of Softw are Engineering

  2. 2 Lecture 15: A glimpse into the hardware I ntroduction to Programming – Lecture 15 Chair of Softw are Engineering

  3. Topics for this lecture 3 � Components of a computer system � Coding data � The memory hierarchy � Computer instructions � Computers´ power � Moore‘s law I ntroduction to Programming – Lecture 15 Chair of Softw are Engineering

  4. Components of a computer system 4 What is hardware? � computers and related devices � physical machinery on which programs run I ntroduction to Programming – Lecture 15 Chair of Softw are Engineering

  5. Coding data 5 � Data stored in computers’ memory represent diverse information: � Employee records � Images, sounds � Text in human languages � Numerical values for scientific computation � ... � Data must be represented (coded) in a way that is easy to read, write by computers � Binary coding is simple and efficient enough I ntroduction to Programming – Lecture 15 Chair of Softw are Engineering

  6. The binary system 6 � As the name says: a set of two values 0 and 1 � The bit is the atomic variable for storing data bit = binary digit (possible values 0 and 1) � Also denotes a physical device with two states � Electronic bits: two different voltages � Magnetic bits: magnetized and unmagnetized I ntroduction to Programming – Lecture 15 Chair of Softw are Engineering

  7. Computer revolution 7 Why did the binary systems displace all its competitors? Because the electronic industry lets us: � Build, pack very many bit representations into very small areas � Write and read these bits very quickly � Build devices storing these bits very cheaply I ntroduction to Programming – Lecture 15 Chair of Softw are Engineering

  8. Relevancy to programmers 8 Why should programmers care? � Source code in human readible languages � But in memory binary representation � Addressing also in binary To fully understand the software systems we build we must understand how the physical machine represents, stores and accesses the data I ntroduction to Programming – Lecture 15 Chair of Softw are Engineering

  9. Binary basics 9 � b2 b1 b0 bit byte sequence of 8 bits dec. (octet) 0 0 0 0 0 0 1 1 � w ord sequence of 4 bytes 0 1 0 2 (32 bits) 0 1 1 3 1 0 0 4 with n bits 2 n different � 1 0 1 5 1 1 0 6 values can be represented 1 1 1 7 n − 1 ∑ � decimal value of an n bit { } i dec : = b 2 , b ∈ 0 , 1 i i representation i 0 = I ntroduction to Programming – Lecture 15 Chair of Softw are Engineering

  10. Representations 10 The extended ASCII character set: � digits, special symbols (‘~ ‘,‘@‘,‘$‘), 26 lower case and 26 upper case letters, accented letters � represented on 8 bits (256 possible values) � Eiffel type CHARACTER Numeric information: � integers (19), rationals (3/ 2), reals ( π ) � Eiffel types: � INTEGER , 1 w ord , 2 32 possibilities � REAL , 1 w ord , 2 32 possibilities � DOUBLE , 2 w ords , 2 64 possibilities I ntroduction to Programming – Lecture 15 Chair of Softw are Engineering

  11. Addresses 11 � Address: starting position at which a data element appears in memory my_number : INTEGER ... 00000000 A18B0003h A18B0002h 00000000 my_number : = 5 A18B0001h 00000000 A18B0000h 00000101 start address of my_number 00000000h addresses memory I ntroduction to Programming – Lecture 15 Chair of Softw are Engineering

  12. Powers of two 12 2 n n Approxim ation Com m on by pow er of 1 0 nam e 0 1 1 2 2 4 3 8 4 1 6 5 3 2 6 6 4 7 1 2 8 8 2 5 6 9 5 1 2 1 0 3 ( thousand) 1 0 1 0 2 4 Kilo ( K) 1 6 6 5 5 3 6 1 0 6 ( m illion) 2 0 1 ,0 4 8 ,5 7 6 Mega ( M) 1 0 9 ( billion) 3 0 1 ,0 7 3 ,7 4 1 ,8 2 4 Giga ( G) 4 x1 0 9 3 2 4 ,2 9 4 ,9 6 7 ,2 9 6 1 0 1 2 4 0 Tera ( T) 1 0 1 5 5 0 Peta ( P) I ntroduction to Programming – Lecture 15 Chair of Softw are Engineering

  13. More on memory 13 What is the memory? � Where we put and access data � The place where we create and find objects Relevant parameters of memories: � persistency (persistent or transient) � access time (from ns to ms ) � capacity (from several KB to several GB) � maximum bandwidth (from GB/ s to MB/ s) � cost/ Byte I ntroduction to Programming – Lecture 15 Chair of Softw are Engineering

  14. Memory hierarchy 14 Capacity Access tim e Bandw idth < 1 KB faster Registers < 0 .5 ns sm aller 2 0 -1 0 0 GB/ s 1 6 MB Cache < 0 .5 -2 5 ns 5 -1 0 GB/ s < 8 GB Main memory < 6 0 -2 5 0 ns 1 -5 GB/ s > 1 0 0 GB < 5 -1 0 m s Disk ~ 1 0 0 MB/ s infinite Tape slow er sec-m in bigger < 0 .0 1 GB/ s I ntroduction to Programming – Lecture 15 Chair of Softw are Engineering

  15. Persistence 15 Memories are of two kind: Transient data are created and manipulated by programs, powering off the memory loses the data � transient memories: registers, cache, main memory � faster, smaller capacity, higher production cost � Persistent data remains forever unless deleted, powering off the memory has no effect on the data � persistent memories: disk, tape � slower, higher capacity, low production cost I ntroduction to Programming – Lecture 15 Chair of Softw are Engineering

  16. Transient memory 16 � Processor operations access and modify data in transient memory � Synonims for main memory: primary memory, RAM (Random Access Memory), core memory I ntroduction to Programming – Lecture 15 Chair of Softw are Engineering

  17. Persistent memory (1) 17 Secondary m em ory � extension for the main memory � attached to a computer � disk device (HDD) a pile of magnetized disks, with several reading heads � rotation speed, capacity, average access time, latency Rem ovable m em ory � devices for data backup � connected to a computer only episodically � disk devices, USB memory sticks, ZIP drives I ntroduction to Programming – Lecture 15 Chair of Softw are Engineering

  18. Persistent memory (2) 18 I ntroduction to Programming – Lecture 15 Chair of Softw are Engineering

  19. Moore’s “Law” 19 � Approximate doubling of computer power, for comparable price, every eighteen months Speed of Intel processors Pentium IV: 1.3 GHz 1 GHz (1 Hertz = 1 clock cycle per second) Pentium: 133 MHz 100 MHz 80486: 50 MHz 80386: 33 MHz 10 MHz to 1 GHz: 26 years 1 MHz from 1 to 2 GHz: 8 months 8008: < 1 MHz 1970 1980 1990 2000 I ntroduction to Programming – Lecture 15 Chair of Softw are Engineering

  20. 20 End of lecture 15 I ntroduction to Programming – Lecture 15 Chair of Softw are Engineering

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend