Memory - Can You Compute?

advertisement
Memory
COMPUTING
What is memory?

Memory is a device where data and instructions can be stored
and retrieved.

Usually, when we talk about memory we are talking about
storage in the computer’s main memory, this is often the
computer’s RAM.

RAM is not the only kind of memory though.

There are lots of other kinds of memory.
Why does a computer
need memory?

The computer needs a place to store the instructions of a
program that it is going to carry out.

The computer needs a place to store data that is to be
processed.

Data and instructions that the CPU need are stored in the
computer’s memory.
Storing and keeping
things that we need

When you type the lines of a program into a
computer, you want the computer to
remember them.

You don’t want the lines of code to disappear
or vanish after you type each one. They need
to be stored or “remembered”.

When you try to execute the program, the
computer will need the instructions. If it has not
stored them somewhere, how will it know what
to do?
Storing and keeping
things that we need

When you type in some data e.g. the name and details of a
person, you may want it again in the future.

Data needs to be stored by the computer, ready for when it is
needed.

You may want the computer to use the data more than once.

You don’t want to type the data in again and again every time it is
needed.

You want the computer to remember it.
There are different kinds of
memory

Processor Registers.

Cache memory.

Main memory e.g. RAM.

Virtual memory.

Secondary storage – (backing storage) is not
really memory.
For GCSE you need to
know about each one of
these.
RAM

This is a SIMM (single in-line memory module) of RAM (Random
Access Memory).

It is a circuit board that holds RAM chips.

The label tells us the whole SIMM can hold 512 megabytes of
data. (8 chips x 64 MB)
Single RAM chip
RAM

The SIMM of RAM chips plugs into the computer’s
motherboard.
You can plug in
extra SIMMs to
add more memory
to your computer.
What is RAM?

RAM stands for Random Access Memory.

You can read data that is stored in RAM.

You can change (write) data stored in RAM – the contents of
RAM can be changed.

You change any part of RAM in any order (randomly) without
needing to start at the first memory location.
What is ROM?

ROM stands for Read Only Memory.

You can read the contents of ROM, but you cannot change
them (write to them).

Whatever is stored in ROM cannot be changed.

ROM is non-volatile. Whatever is stored in ROM is not lost when
the computer or device is turned off.
Storing things in RAM or

While the computer is switched on (and has
ROM?
electricity running through it’s circuits)
programs that are being executed and data
needed by the programs can be stored in
RAM (the main memory of the computer).
 RAM is volatile. It can only store things while
the computer is switched on, while it has
electricity in the RAM circuits.
 When the computer is switched off, without
electricity, anything stored in RAM is lost or
erased.
Storing things in RAM or
ROM?

Some important programs are sometimes
stored in ROM (read only memory) so that
they cannot accidentally be erased or
changed.

Programs stored in ROM are still kept stored
even when the computer is switched off.

After switching on a computer, simple
instructions telling it how to load the
operating system are read in from a special
ROM chip called the BIOS.
What is memory?

RAM and ROM are both made up of memory locations.

Each memory location is like a box that can hold a number
(either a data value or a program instruction).
Memory locations

All of the boxes are exactly the same size – they can hold a
certain sized number

e.g. an 8-bit number.

Each box can hold only one thing at a time.

You can’t put more than one thing in a box at the same time.
01011010
Store in this
memory location
Reading and storing
values

Each box has a memory address (it has a
number) so that you don’t mix it up with the other
different boxes.

The memory address helps you to find what you
have stored in memory.

Our data 01011010 is in box number 3.
Box
1
Box
2
Box
3
01011010
Box
4
Reading and storing
values

You can read what is in a memory location (look
at and see what is in the box).

We can read the contents of location 3. It
contains 01011010.

You can re-use the memory location. Storing new
data can over-write what was previously in a
location (replace what was in the box).
Box
1
Box
2
Box
3
01011010
Box
4
Memory map

So computer memory is made up of millions or
billions of memory locations.

Each location is like a box that can only store one
value at a time.

It helps to draw a map or diagram of memory
locations and what they are used for.

This is called a memory-map.

We don’t usually draw the locations as cardboard
boxes!
Memory map



We usually draw a map
of memory locations
and what is stored in
each of them like this…
The value 0101101 is
stored in location 2.
Memory normally
contains billions of
locations. Each has it’s
own address so that
you can find and use it.
Memory
address
Contents
(what is in this
memory location)
0
00000000
1
00000000
2
01011010
3
00000000
4
00000000
5
00000000
6
00000000
7
00000000
8
00000000
9
00000000
10
00000000
11
00000000
12
00000000
13
00000000
14
00000000
15
00000000
How memory is organised

Once you have stored something in memory, you
need to be able to find it again.

Each location in memory has a memory address.

Imagine that each box has a number written on
the outside.

We can tell the computer to show us what is in
box number 39. It will open the box and show us.
RAM – random access

You can access any RAM location you like at any
time – it is random access (you can look in the
boxes in any order).

You do not need to start at the beginning and
read through all of the locations until you get to
the location that you want.

We can go to any of the boxes we want to at any
time.
Can RAM get used up?

Programs use memory to store their instructions and data that
they need.

When every memory location has been allocated (given) to
programs to use up, the memory is full.

There is no more free memory to give to any programs that ask
to use it.
Can RAM get used up?

Not being able to get more memory can make a program
crash.

Sometimes a program will slow down if it needs more memory
and there is none available.

This is why adding more RAM to your PC can make it run
programs faster. Programs are not kept waiting for memory to
become available.
A clever idea… Virtual
memory

All of the programs running on the computer
need memory – RAM.

But there is only a certain amount of RAM to be
shared between them.

If a program needs memory to store data but
there is no more free RAM, the program will not be
able to continue running.
Virtual memory

Virtual memory is data temporarily held in a file on secondary
storage (e.g. hard disk drive) so that it does not take up
storage space in the computer’s main memory.

The Windows “swap file” is virtual memory. It holds data for a
program that is running on the computer, rather than keeping
all of the data that the program needs in memory all at the
same time.
A problem… Thrashing




A computer that does not have enough RAM
may need to use virtual memory or swap files a
lot.
The computer might spend more time transferring
data between RAM and virtual memory than it
does actually processing the data and doing
useful work.
This is called thrashing (because the busy hard
disk drive makes a lot of noise as it copies data).
The programs on the computer might appear to
run very slowly. The user is kept waiting.
Registers in the CPU

Inside the central processing unit there is a very small amount of
very fast memory.

These memory locations are called registers.

There are only a few registers in the processor.

The registers are used when executing each simple machine
code instruction.

Data values to be processed by an instruction are stored ready
for use in the registers.

Once the instruction is executed, the results are stored in the
registers.
Registers in the CPU

The most important register is called the
accumulator.

Registers are extremely fast to use. It is much faster
to read the contents of this memory and write
changes to it than the rest of the memory in the
computer.
Cache memory

The cache is an area of very fast memory that links the CPU
with main memory.

The cache is used to temporarily store data and instructions
that the CPU is likely to need imminently or more than once.

Cache memory is faster than main memory. There is usually
much less cache memory in the computer than main memory
– it is expensive!
Levels of cache memory

Level 1 cache memory is the fastest type of cache.

It is physically located closer to the processor on the
motherboard.

Level 2 cache memory is still very fast, but not as fast a level 1
cache memory.

Level 2 cache memory is not quite as close to the processor as
the level 1 cache memory.

There is usually more level 2 cache memory than level 1
cache memory.
Computer
Secondary
storage
e.g. Hard disk drive
Registers
Processor
(CPU)
Level 1
Cache
Memory
Level 2
Cache
Memory
RAM
Random
Access
Memory
Cache memory

How do you control what gets held in the cache memory?

A special caching algorithm decides what to be store in the
cache that the CPU is likely to need.
Flash memory

USB flash drives act like a disk drive.

You can read and write files to them, just like saving to disk.

The files are stored on a memory chip.
The memory chip
that stores your
files.
Flash memory

There are no moving parts in flash memory so they
can withstand shocks and rough treatment.

(The same kind of flash memory chips are used in
“black-box” flight recorders for air-crash data.)
Flash memory

Flash memory is getting cheaper to make than it
used to be.

Flash memory can be faster than a hard-disk
drive to access data, but it is slower than the main
RAM of a computer.

Some flash memory drives can store 8 GB or more.
How much can be stored? Memory
capacity
1 bit (a 0 or 1 binary digit)

A bit is the smallest amount that a computer can store (using ON or OFF in a
circuit).
1 nibble = 4 bits
1 byte = 8 bits (an ASCII character takes 1 byte.)

So 1 byte = 2 nibbles!
1 kilobyte = 1024 bytes
1 megabyte = 1024 kilobytes (or 1024 x 1024 bytes)
1 gigabyte = 1024 megabytes (or 1024 x 1024
kilobytes)
1 terabyte = 1024 gigabytes
Download