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

introduction to programming
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

I ntroduction to Programming – Lecture 15

1

Chair of Softw are Engineering

Introduction to Programming

Bertrand Meyer

Last revised 1 December 2003

slide-2
SLIDE 2

I ntroduction to Programming – Lecture 15

2

Chair of Softw are Engineering

Lecture 15: A glimpse into the hardware

slide-3
SLIDE 3

I ntroduction to Programming – Lecture 15

3

Chair of Softw are Engineering

Topics for this lecture

Components of a computer system Coding data The memory hierarchy Computer instructions Computers´ power Moore‘s law

slide-4
SLIDE 4

I ntroduction to Programming – Lecture 15

4

Chair of Softw are Engineering

Components of a computer system

What is hardware?

  • computers and related devices
  • physical machinery on which programs run
slide-5
SLIDE 5

I ntroduction to Programming – Lecture 15

5

Chair of Softw are Engineering

Coding data

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

slide-6
SLIDE 6

I ntroduction to Programming – Lecture 15

6

Chair of Softw are Engineering

The binary system

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

slide-7
SLIDE 7

I ntroduction to Programming – Lecture 15

7

Chair of Softw are Engineering

Computer revolution

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

slide-8
SLIDE 8

I ntroduction to Programming – Lecture 15

8

Chair of Softw are Engineering

Relevancy to programmers

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

slide-9
SLIDE 9

I ntroduction to Programming – Lecture 15

9

Chair of Softw are Engineering

Binary basics

  • byte sequence of 8 bits

(octet)

  • w ord sequence of 4 bytes

(32 bits)

  • with n bits 2n different

values can be represented

  • decimal value of an n bit

representation

7 1 1 1 6 1 1 5 1 1 4 1 3 1 1 2 1 1 1 bit dec. b0 b1 b2

{ }

− =

∈ =

1

1 , , 2 :

n i i i i

b b dec

slide-10
SLIDE 10

I ntroduction to Programming – Lecture 15

10

Chair of Softw are Engineering

Representations

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, 232 possibilities REAL, 1 w ord, 232 possibilities DOUBLE, 2 w ords, 264 possibilities

slide-11
SLIDE 11

I ntroduction to Programming – Lecture 15

11

Chair of Softw are Engineering

00000000 00000000 00000000 00000101

Addresses

Address: starting position at which a data element appears in memory my_number: INTEGER ... my_number : = 5

00000000h A18B0003h A18B0002h A18B0001h A18B0000h

addresses memory start address of my_number

slide-12
SLIDE 12

I ntroduction to Programming – Lecture 15

12

Chair of Softw are Engineering

Powers of two

Peta ( P) 1 0 1 5 5 0 Tera ( T) 1 0 1 2 4 0 4 x1 0 9 4 ,2 9 4 ,9 6 7 ,2 9 6 3 2 Giga ( G) 1 0 9 ( billion) 1 ,0 7 3 ,7 4 1 ,8 2 4 3 0 Mega ( M) 1 0 6 ( m illion) 1 ,0 4 8 ,5 7 6 2 0 6 5 5 3 6 1 6 Kilo ( K) 1 0 3 ( thousand) 1 0 2 4 1 0 5 1 2 9 2 5 6 8 1 2 8 7 6 4 6 3 2 5 1 6 4 8 3 4 2 2 1 1 Com m on nam e Approxim ation by pow er of 1 0 2 n n

slide-13
SLIDE 13

I ntroduction to Programming – Lecture 15

13

Chair of Softw are Engineering

More on memory

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
slide-14
SLIDE 14

I ntroduction to Programming – Lecture 15

14

Chair of Softw are Engineering

Memory hierarchy

Registers Cache Main memory Disk Tape

Capacity Access tim e Bandw idth

< 1 KB < 0 .5 ns 2 0 -1 0 0 GB/ s 1 6 MB < 0 .5 -2 5 ns 5 -1 0 GB/ s < 8 GB < 6 0 -2 5 0 ns 1 -5 GB/ s > 1 0 0 GB < 5 -1 0 m s ~ 1 0 0 MB/ s infinite sec-m in < 0 .0 1 GB/ s faster sm aller slow er bigger

slide-15
SLIDE 15

I ntroduction to Programming – Lecture 15

15

Chair of Softw are Engineering

Persistence

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

slide-16
SLIDE 16

I ntroduction to Programming – Lecture 15

16

Chair of Softw are Engineering

Transient memory

  • Processor operations access and modify data in transient

memory

  • Synonims for main memory: primary memory, RAM

(Random Access Memory), core memory

slide-17
SLIDE 17

I ntroduction to Programming – Lecture 15

17

Chair of Softw are Engineering

Persistent memory (1)

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

slide-18
SLIDE 18

I ntroduction to Programming – Lecture 15

18

Chair of Softw are Engineering

Persistent memory (2)

slide-19
SLIDE 19

I ntroduction to Programming – Lecture 15

19

Chair of Softw are Engineering

Moore’s “Law”

  • Approximate doubling of computer power, for comparable

price, every eighteen months

2000

1 MHz 10 MHz 1 GHz 100 MHz

1990 1980 1970

8008: < 1 MHz 80386: 33 MHz 80486: 50 MHz Pentium: 133 MHz Pentium IV: 1.3 GHz

to 1 GHz: 26 years from 1 to 2 GHz: 8 months

Speed of Intel processors

(1 Hertz = 1 clock cycle per second)

slide-20
SLIDE 20

I ntroduction to Programming – Lecture 15

20

Chair of Softw are Engineering

End of lecture 15