46
CS 2 CS 2 Main Memory Main Memory and and Backing Store Backing Store

CS 2 Main Memory and Backing Store. 2 0100 1000 Memory address (1) Memory is “place’ to store digital signals (0 1)

Embed Size (px)

Citation preview

Page 1: CS 2 Main Memory and Backing Store. 2 0100 1000 Memory address (1) Memory is “place’ to store digital signals (0 1)

CS 2 CS 2 Main Memory Main Memory

and and Backing StoreBacking Store

Page 2: CS 2 Main Memory and Backing Store. 2 0100 1000 Memory address (1) Memory is “place’ to store digital signals (0 1)

2

0100 10000100 1000

Memory address (1)Memory address (1)

Memory is “place’ Memory is “place’ to store digital to store digital signals (0 1)signals (0 1)

Page 3: CS 2 Main Memory and Backing Store. 2 0100 1000 Memory address (1) Memory is “place’ to store digital signals (0 1)

3

Memory address (2)Memory address (2)

0100 10000100 1000

0111 11000111 1100

0110 10100110 1010

……. ….... …...

0000 10100000 1010

Memory can allowed

Read / Write

To R/W data, you must

know where it is?

Address = location

0000 0000

0000 0001

0000 0010

1111 1111

Page 4: CS 2 Main Memory and Backing Store. 2 0100 1000 Memory address (1) Memory is “place’ to store digital signals (0 1)

4

Memory address (3)Memory address (3)

0 00 00 00 0

0 10 10 10 1

1 01 01 01 0

1 11 11 11 1

What is the MEORY SIZE?

0000 0000

0000 0001

0000 0010

1111 1111

…. ….

Page 5: CS 2 Main Memory and Backing Store. 2 0100 1000 Memory address (1) Memory is “place’ to store digital signals (0 1)

5

Memory Size (1)Memory Size (1)

00

00 00 00 00 00 00 00 00

WORDWORD??

Page 6: CS 2 Main Memory and Backing Store. 2 0100 1000 Memory address (1) Memory is “place’ to store digital signals (0 1)

6

Memory Size (2)Memory Size (2)

ONE ONE WORWOR

DD

Depends on Computer Type

Operating system Required word size

MS DOS 8 bits

MS Windows 3.1 16 bits

MS Windows 95/98/NT/2000/XP

32 bits

Linux 32 bits

Table of word sizes

Page 7: CS 2 Main Memory and Backing Store. 2 0100 1000 Memory address (1) Memory is “place’ to store digital signals (0 1)

7

Wikipedia – 64-bit

Page 8: CS 2 Main Memory and Backing Store. 2 0100 1000 Memory address (1) Memory is “place’ to store digital signals (0 1)

8

1 1 kilobytekilobyte (1 (1KB) = KB) = 2210 bytes =bytes =1024 bytes bytes

1 1 megabytemegabyte (1 (1MB) = MB) = 2210 KB KB = 2 = 220 bytesbytes

1 1 TbyteTbyte (1 (1TB) = TB) = 2210 GB GB = 2 = 240 bytesbytes

Memory Size (3)Memory Size (3)

1 1 gigabytegigabyte (1 (1GB) = GB) = 2210 MB MB = 2 = 230 bytesbytes

Questions ...Questions ...

Page 9: CS 2 Main Memory and Backing Store. 2 0100 1000 Memory address (1) Memory is “place’ to store digital signals (0 1)

9

CS 2.2Exercise

Page 10: CS 2 Main Memory and Backing Store. 2 0100 1000 Memory address (1) Memory is “place’ to store digital signals (0 1)

10

Exercise 1

1. How many bits are there in 1 Mbytes?

Soln:

1Mbytes

= 1 x 1024 x 1024 bytes

= 1048576 x 8 bits

= 8388608 bits

Page 11: CS 2 Main Memory and Backing Store. 2 0100 1000 Memory address (1) Memory is “place’ to store digital signals (0 1)

11

Exercise 1

2. A Computer has 4K words of main storage. Each word comprises 24 bits. How many bytes are there in the whole memory? How address lines are required?

Soln: # of bytes in whole memory= 4K x 3 bytes 12 KB

# of address lines required:Since 2n 12KB , 213 = 8192 and 214 = 16384 n = 14

Page 12: CS 2 Main Memory and Backing Store. 2 0100 1000 Memory address (1) Memory is “place’ to store digital signals (0 1)

12

Exercise 1

3. A 40 Mbytes memory chip is _______ times a 512 Kbytes chip.

Soln: 40MB 512 KB

= 40 x 1024 KB 512 KB= 80 A 40 Mbytes memory chip is 80 times a

512 Kbytes chip.

Page 13: CS 2 Main Memory and Backing Store. 2 0100 1000 Memory address (1) Memory is “place’ to store digital signals (0 1)

13

Exercise 1

4. If the addresses of the locations of a computer are from 0 to 20000, how many address bits are required for addresssing?

Soln:

# of address lines required:

Since 2n 20001,

and 215 = 32768

n = 15

Page 14: CS 2 Main Memory and Backing Store. 2 0100 1000 Memory address (1) Memory is “place’ to store digital signals (0 1)

14

StorageStorage─ ─ stores programs and datastores programs and data─ ─ stores programs and datastores programs and data

Storage UnitStorage Unit

Main Memory Backing Store

Random Random Access Access

Memory Memory (RAM)(RAM)

Random Random Access Access

Memory Memory (RAM)(RAM)

Read Only Read Only Memory Memory (ROM)(ROM)

Read Only Read Only Memory Memory (ROM)(ROM)

Store Store large amounts large amounts of data, of data, programs and information programs and information permanentlypermanently even when the even when the computer is turned off.computer is turned off.

Store Store large amounts large amounts of data, of data, programs and information programs and information permanentlypermanently even when the even when the computer is turned off.computer is turned off.

Page 15: CS 2 Main Memory and Backing Store. 2 0100 1000 Memory address (1) Memory is “place’ to store digital signals (0 1)

15

RRandom andom AAccess ccess MMemory (RAM)emory (RAM)

─ ─ temporarily stores programs temporarily stores programs and data that are to be executed and data that are to be executed or processed by the CPUor processed by the CPU

Any area of RAM can be Any area of RAM can be accessed directly and accessed directly and immediately by the CPU.immediately by the CPU.

Any area of RAM can be Any area of RAM can be accessed directly and accessed directly and immediately by the CPU.immediately by the CPU.

RAMRAM

Page 16: CS 2 Main Memory and Backing Store. 2 0100 1000 Memory address (1) Memory is “place’ to store digital signals (0 1)

16

RAMRAM

Virtual memory– Part of the Hard disk for extending RAM– Capacity of RAM is fixed– Data not frequently used are moved to the

hard disk to make room for new data

Swapping– Moving data between RAM and Hard disk– Done by the computer automatically– Transparent to user

Page 17: CS 2 Main Memory and Backing Store. 2 0100 1000 Memory address (1) Memory is “place’ to store digital signals (0 1)

17

RAMRAM

Too much Swapping– Reduce performance of computer, or– Lead to system crash

To reduce Swapping– Increase the size of RAM

Page 18: CS 2 Main Memory and Backing Store. 2 0100 1000 Memory address (1) Memory is “place’ to store digital signals (0 1)

18

RRead-ead-OOnly nly MMemory (ROM)emory (ROM)

- - stores the essential software of stores the essential software of the computer system.the computer system.

‘‘Read-only’ means ROM Read-only’ means ROM can be read but not changed.can be read but not changed.

‘‘Read-only’ means ROM Read-only’ means ROM can be read but not changed.can be read but not changed.

ROMROM

Page 19: CS 2 Main Memory and Backing Store. 2 0100 1000 Memory address (1) Memory is “place’ to store digital signals (0 1)

19

ROMROM

The contents of ROM are The contents of ROM are preset by the ROM preset by the ROM manufacturer, and can’t manufacturer, and can’t be changed by users.be changed by users.

BIOS is an example BIOS is an example of ROM..of ROM..

BIOS is an example BIOS is an example of ROM..of ROM..

Page 20: CS 2 Main Memory and Backing Store. 2 0100 1000 Memory address (1) Memory is “place’ to store digital signals (0 1)

20

RAM vs ROMRAM vs ROM

RAM ROMIt is volatile, i.e. data stored will disappear if the power supply is turned off.

It is non-volatile, i.e. the memory will retain its content even if the power is turned off.

Data can be read from it or written into, i.e. Read-write.

Data init can be read only and cannot be over written, i.e. Read-only.

It is used for temporary storage of running program and working data.

It is used for storing permanent system programs such as BIOS.

Page 21: CS 2 Main Memory and Backing Store. 2 0100 1000 Memory address (1) Memory is “place’ to store digital signals (0 1)

21

Complementary Metal-Oxide Semiconductor

Contents can be changed

Non-volatile

Stores configuration about a computer, including

Capacity of the hard disk

Types of existing ports, keyboard and monitor

Current time and date

CMOS does not store programs

CMOSCMOS

Page 22: CS 2 Main Memory and Backing Store. 2 0100 1000 Memory address (1) Memory is “place’ to store digital signals (0 1)

22

Small amount of high speed memory

Designed to supply CPU with the most frequently requested data and instruction

First locate in cache first, then RAM

CacheCache

Page 23: CS 2 Main Memory and Backing Store. 2 0100 1000 Memory address (1) Memory is “place’ to store digital signals (0 1)

23

ComparisonComparison

Page 24: CS 2 Main Memory and Backing Store. 2 0100 1000 Memory address (1) Memory is “place’ to store digital signals (0 1)

24

Why should we have secondary Why should we have secondary storage?storage?

Why should we have secondary Why should we have secondary storage?storage?

Backing StoreBacking Store

LargeLarge storage capacity storage capacity PermanentPermanent storage storage LowerLower cost cost

Secondary storage provides permanent storage for Secondary storage provides permanent storage for large amounts of programs and data that need not be large amounts of programs and data that need not be immediately accessed by the CPU.immediately accessed by the CPU.

Secondary storage provides permanent storage for Secondary storage provides permanent storage for large amounts of programs and data that need not be large amounts of programs and data that need not be immediately accessed by the CPU.immediately accessed by the CPU.

Page 25: CS 2 Main Memory and Backing Store. 2 0100 1000 Memory address (1) Memory is “place’ to store digital signals (0 1)

25

Magnetic TapeMagnetic Tape

used for used for backup backup

data in computersdata in computers

sequential accesssequential access

Magnetic Tape (1)Magnetic Tape (1)

Page 26: CS 2 Main Memory and Backing Store. 2 0100 1000 Memory address (1) Memory is “place’ to store digital signals (0 1)

26

File store on magnetic tapeFile store on magnetic tape

Magnetic Tape (2)Magnetic Tape (2)

Tape File consists on Tape File consists on HeaderHeader, , Data blocks Data blocks and and Inter Blocks Gap (IBG)Inter Blocks Gap (IBG)

To retrieve To retrieve aa record, you record, you must read must read allall record first. record first.

Sequential Sequential AccessAccess

Sequential Sequential AccessAccess

SLOWER!SLOWER!SLOWER!SLOWER!

Page 27: CS 2 Main Memory and Backing Store. 2 0100 1000 Memory address (1) Memory is “place’ to store digital signals (0 1)

27

Hard disk driveHard disk drive

Removable hard diskRemovable hard disk

Magnetic Disk (1)Magnetic Disk (1)Magnetic DiskMagnetic Disk

Floppy diskFloppy disk

Page 28: CS 2 Main Memory and Backing Store. 2 0100 1000 Memory address (1) Memory is “place’ to store digital signals (0 1)

28

Magnetic Disk FileMagnetic Disk File

Magnetic Disk (2)Magnetic Disk (2)

Page 29: CS 2 Main Memory and Backing Store. 2 0100 1000 Memory address (1) Memory is “place’ to store digital signals (0 1)

29

CD-ROM Drive

Direct access (fast)

CD Writer

It can be used to read It can be used to read data from and write data data from and write data to optical disks such as to optical disks such as CD-R and CD-RW.CD-R and CD-RW.

CD-ROM (1)CD-ROM (1)Optical Disk DriveOptical Disk Drive

Data is read-only.

Compact disk read-only memory

Page 30: CS 2 Main Memory and Backing Store. 2 0100 1000 Memory address (1) Memory is “place’ to store digital signals (0 1)

30

Optical DiskOptical DiskInformation is stored Information is stored by using a laser by using a laser beam to burn holes beam to burn holes on a thin coating of on a thin coating of metal.metal.

Information is stored Information is stored by using a laser by using a laser beam to burn holes beam to burn holes on a thin coating of on a thin coating of metal.metal.

Another laser beam is used to read the hole patterns.

Another laser beam is used to read the hole patterns.

CD-ROM (2)CD-ROM (2)

UsageUsage

EncyclopediasEncyclopedias

Film (VCD)Film (VCD)

Page 31: CS 2 Main Memory and Backing Store. 2 0100 1000 Memory address (1) Memory is “place’ to store digital signals (0 1)

31

CD-ROM (3)CD-ROM (3)

Page 32: CS 2 Main Memory and Backing Store. 2 0100 1000 Memory address (1) Memory is “place’ to store digital signals (0 1)

32

DVDDVD

•Digital Versatile Disk•DVDR, DVDRW, DVD-RAM

•4.7GB storage•DL (Dual / Double Layer)

•8.5GB storage

Page 33: CS 2 Main Memory and Backing Store. 2 0100 1000 Memory address (1) Memory is “place’ to store digital signals (0 1)

33

Hard Disk Hard Disk

Page 34: CS 2 Main Memory and Backing Store. 2 0100 1000 Memory address (1) Memory is “place’ to store digital signals (0 1)

34

Hard Disk Hard Disk

Page 35: CS 2 Main Memory and Backing Store. 2 0100 1000 Memory address (1) Memory is “place’ to store digital signals (0 1)

35

Semi-conducting MediaSemi-conducting Media(Flash memory cards)(Flash memory cards)

Uses semi-conductor to record data.

High speed in transferring data, small in size, portable and no mechanical movement.

Becomes popular.

E.g.: CF, MS, SD, MMC, xD, T-flash, etc.

Web site of SanDisk

Page 36: CS 2 Main Memory and Backing Store. 2 0100 1000 Memory address (1) Memory is “place’ to store digital signals (0 1)

36

Removable DisksRemovable Disks

Provide both the storage capacity and fact access time of hard disk and the probability of floppy disks.

Examples: – Iomega’s ZIP (100MB)– JAZ (1-2 GB)– Imation’s Superdisk (120MB)

Page 37: CS 2 Main Memory and Backing Store. 2 0100 1000 Memory address (1) Memory is “place’ to store digital signals (0 1)

37

BufferBuffer

Disk/ TapeDisk/ Tape

CPUCPU

Speed of CPU is MUCH Speed of CPU is MUCH FasterFaster than any Backing Store than any Backing Store

•Buffer is needed.Buffer is needed.•Usually is RAM or Cache.Usually is RAM or Cache.

•Buffer is needed.Buffer is needed.•Usually is RAM or Cache.Usually is RAM or Cache.

Page 38: CS 2 Main Memory and Backing Store. 2 0100 1000 Memory address (1) Memory is “place’ to store digital signals (0 1)

38

Comparison between different backing store

Cost (/ MB) Speed

Flash memory

$2 Fast

Hard disk $0.004

Compact disc $0.0006

Magnetic tape

$0.001

Floppy disk $1.4 Slow

Expensive

Cheap

Page 39: CS 2 Main Memory and Backing Store. 2 0100 1000 Memory address (1) Memory is “place’ to store digital signals (0 1)

39

Comparison between different backing store

Storage capacity

Access mode

Portable

Flash memory ??? Direct Yes

Hard disk Highest Direct No

Compact disc Direct Yes

Magnetic tape Sequential

Yes

Floppy disk Lowest Direct Yes

Page 40: CS 2 Main Memory and Backing Store. 2 0100 1000 Memory address (1) Memory is “place’ to store digital signals (0 1)

40

Factors affect the performance of computer

Speed of CPU

Capacity of RAM

Speed of hard disk

Free space of hard disk

Width of bus system

Speed of peripherals

Capability of Video cards

Cache memory

Page 41: CS 2 Main Memory and Backing Store. 2 0100 1000 Memory address (1) Memory is “place’ to store digital signals (0 1)

41

CS 2.4Exercise

Page 42: CS 2 Main Memory and Backing Store. 2 0100 1000 Memory address (1) Memory is “place’ to store digital signals (0 1)

42

Exercise 2

1. Which of the following are the units of data organisation for a magnetic disk?

(1) Cylinder(2) File(3) Record(4) Sector(5) Track

Page 43: CS 2 Main Memory and Backing Store. 2 0100 1000 Memory address (1) Memory is “place’ to store digital signals (0 1)

43

Exercise 2

2. Which of the following storage media is non-erasable?

A. Random access memoryB. Magnetic tapeC. Hard diskD. Read only memoryE. Floppy disk

Page 44: CS 2 Main Memory and Backing Store. 2 0100 1000 Memory address (1) Memory is “place’ to store digital signals (0 1)

44

Exercise 2

3. A secondary storage device is used because

(1) it provides non-volatile storage;

(2) it can store a large amount of data;

(3) it runs at a great speed.

Page 45: CS 2 Main Memory and Backing Store. 2 0100 1000 Memory address (1) Memory is “place’ to store digital signals (0 1)

45

Comparison between main memory and backing store

Main Memory Backing Store

Function Store processing program and data

Store program and data after processing

Storage capacity Low (512MB) High (160GB)

Cost High ($0.8-1.2/MB) Low ($0.004/MB)

Access mode Random access Disk: direct

Tape: sequential

Access time Fast Slow

Performance ROM: non-volatile

RAM: volatile

Non-volatile

Page 46: CS 2 Main Memory and Backing Store. 2 0100 1000 Memory address (1) Memory is “place’ to store digital signals (0 1)

ENDEND