Memory

From COMP15212 Wiki
On path: Pointers 1: Memory • 2: Arrays • 3: Pointers • 4: Pointer Exercise • 5: Structures • 6: Dynamic Memory Allocation • 7: Malloc Exercise • 8: Structs Exercise
On path: Memory 1: Memory • 2: Memory Management • 3: Memory Sizes • 4: Memory Mapping • 5: Memory Segmentation • 6: Memory Protection • 7: Virtual Memory • 8: Paging • 9: Memory Management Unit (MMU) • 10: Caching • 11: Cache • 12: Translation Look-aside Buffer (TLB)
Depends on Resources

This is a simple overview of computer memory. It covers the view which is seen by applications software. For a more ‘operating systems’ view, continue to virtual memory.

Computers hold data in a memory which is a (large) array of equal-sized storage spaces. By far the commonest strategy is that these locations store bytes.

Each location has its own identifier: this is usually expressed as a (hexadecimal) number. This is the address of the location.

Inside the store is a value which is the data. The data can represent whatever you choose it to represent: numbers, letters, colours …

That’s basically it.

The image depicts (part of) a small memory with an 8-bit address. Practical memories are usually somewhat larger.

Memory

Given an address, the data stored at that address can be looked up. Most computer memory can also be written to so you can store variables. A software variable name is simply an alias (in one way or another) for an address.

  • This address space – the total number of different locations which could be addressed – may or may not be fully populated with actual memory.
  • Most of the memory will be Random Access Memory (RAM), which is somewhat misleadingly named. “Random” has nothing random about it: it simply means that any address is as good as any other as far as the machine is concerned.
    “RAM” also implies (by convention) that the memory is writeable. This is true but other memories (such as the eponymous Read Only Memory (ROM) can also be ‘randomly’ accessed.

A very short test

Referring to the figure above:

  • What is the data in location 04?
Answer

The data byte is 48. There is only ever a single answer and every byte must contain something, even if you don’t know what it is. A location may be “undefined” - which means that attempting to access that location will yield a random value - but it can never be truly “empty”.


  • At which (visible) address(es) is the datum 6C stored?
Answer

This byte occurs at both addresses 06 and 07. It may also be present in other places which we can’t see.


Also refer to: Operating System Concepts, 10th Edition: Chapter 9.1, pages 349-356