McHenry Sportsmen's Club: Engineering

Computer Memory


Return to Engineering Home Page
Return to HOME PAGE


by: Tom Carneal (last updated: 03/09/2006)

Computer memory is what is used to store program instructions and data in a computer.
There are different types of memory, dictated mainly by usage.

Bits and Bytes

A BIT is the smallest unit of memory on a computer.

  • A bit represents either a binary 0 or a 1.

    Because computers are electronic, a numbering system which consists of either 0 or 1 (binary) is all that can be used.

    A BYTE is the smallest ADDRESSABLE unit of storage on a computer.

  • A byte consists of eight bits.
  • A byte can hold a binary number from 00000000 to 11111111 (0 to 255 in base 10).
  • This means a byte can be in one of 256 unique states.
  • It normally takes a single byte to represent a character in a computer.
  • If you want to store the name: MARY, you need four bytes to hold that particular character string.
  • Your programs can also string bytes together and use then to store integers to perform arithmetic on.
  • Computer instructions that are executed in your programs are also stored in strings of bytes.
  • By the way, a "string" is jargon for a contiguous group of bytes.
  • It gets far more complicated than this, but for now, this is good to know.

    Computer Memory Size Terms:

    So.. You think you have a lot of memory in your computer...
    The following table shows just how much memory "could" be available under the current 64 bit addressing scheme:

    Symbol Power of 2 Bytes (Decimal Value)
    K (Kilobyte) 2**10 1,024
    M (Megabyte) 2**20 1,048,576
    G (Gigabyte) 2**30 1,073,741,824
    T (Terabyte) 2**40 1,099,511,627,776
    P (Petabyte) 2**50 1,125,899,906,842,624
    E (Exabyte) 2**60 1,152,921,504,606,846,976
    16 Exabytes 2**64 18,446,744,073,709,551,616

    Yes... this is: 17,179,869,184 Gigabytes !!!

    This is how much memory that can be mapped in a single physical address space using the 64 bit addressing model.
    Not to worry... 1/2 Gigabytes (512 Megabytes) of RAM is more than enough for the needs of most people.
    Disk storage... that is a horse of a different color. Most people can do just fine with 200 Gigabytes).
    Read on and see what we are talking about:

    RAM (Random Access Memory)

    This is memory that holds currently executing programs and data being operated on by these programs.
    Operating system code (such as Windows) gets loaded into RAM when you "boot" your computer.
    As you start running applications, they are also loaded into RAM.
    Data that may be needed by your executing programs are also placed in RAM.
    Ram is very fast and not intended to hold information permanently.
    RAM is erased when you turn off your computer.

    Ram is normally stated in Megabytes (MB), with 512 MB being the preferred amount to have in your computer for the average user. The more you have, the faster your machine runs until you have enough. After that, more RAM may actually slow down your machine. Yes,, you read that right... it can actually slow down your machine. To understand why, you would need a good understanding of how "Virtual Storage" and "Address Space" architectures works, and know how memory is accessed by the CPU.

    An address space is a chunk of RAM that has a starting address of zero and contains a fixed number of bytes.
    The size of the "chunk" is dictated by the addressing scheme employed by the processor and its operating system.
    Commercially, there are several addressing schemes: 24, 31, 32 and 64 bit.
    For example 32 bit addressing can provide an address space of 4 gigabytes.
    The number of bits is 2 raised to that power.
    24 bit addressing can provide an address space of 16 Megabytes.
    64 bit addressing can provide an address space of 16 Exabytes.

    Normally programmers write programs that execute in an address space.
    When you launch a program, an unique address space is assigned and the program is loaded into it for execution.
    You normally launch more than one program and they run concurrently.
    You can potentially have thousands of address spaces active when you use your computer, but you seldon have that many.

    Now you may ask... how can this be? I only have 512 Megabytes of RAM.
    How can I have thousands of address spaces when I only have one memory?

    A long time ago RCA invented something called Virtual Storage for their SPECTRA/70 mainframe computers.
    IBM jumped in on it and turned Virtual Storage into a piece of art with their S/370 line of mainframe computers.

    Microsoft also exploited this technology as well as other Personal Computer Operating System vendors.

    Virtual Storage (under the hood)

    Virtual storage is the key to how Operating Systems manage RAM and keep one program from interfering with another. It used to be in the "old days" that if you ran two programs at the same time on a single computer, the potential for one to interfere with the other was high.

    All kinds of schemes were developed to address this but none of them came close to what the industry needed to address this issue. At the same time, RAM was very expensive. A very large computer only had 512 Kilobytes (yes, that was kilobytes).

    Virtual storage was developed to address both the cost of memory and the ability to isolate concurrently running programs from "having each other for lunch".

    The concept of Virtual Storage is quite simple, but very hard to design and put into operation.
    • First, the Operating System must own ALL of the RAM on the system.
    • Second, you need to make each concurrent running task (thread) "think" it is the only one running on your system.

    The way this is currently accomplished is the Operating System creates a "Virtual Address Space" for each task running of the system. A program runs in a Virtual Address space and accesses memory as if it were RAM and it owns all of it (the program is fat, dumb and happy). A hardware function typically called "Dynamic Address Translation" intercepts storage addresses requested by programs and locates their corresponding "REAL" storage in RAM. The program "thinks" it is referencing storage at a particular address but in fact the address is Virtual. The REAL address is only known to the hardware and the Operating System managing it.

    This is why this is called: "Virtual Storage" (or VS).

    The physical RAM is divided up into 4K storage "pages" which are assigned to address spaces on demand. The pages have real storage addresses, but programs refer to the storage by its Virtual Storage address. The Operating System and the hardware perform the address translations "under the covers" (like magic).

    RAM actually looks like a checkerboard full of 4K squares (containing pieces of storage owned by Virtual Storage address spaces).

    When the workload running on your system requests more storage pages then are contained in RAM, RAM becomes saturated and the Operating System's storage manager starts to "thrash" between RAM and the SWAP file. The system will continue to run your workload by copying the oldest referenced pages in RAM out to DISK (SWAP file) and start making the pages available to new requests. This is where the problem starts.

    The system will run whatever you launch. However, once you require more virtual storage than you have pages in RAM, the system writes oldest used pages to its paging file (in Windows, this is your SWAP file) on DISK. Disk is very slow compared to RAM and you will notice it. If this becomes excessive, your system starts to slow down until it is so slow you cannot tolerate it anymore.

    If you increase the amount of RAM (open the case and add more memory sticks), you provide more space for the system to page into and life becomes good again. If you increase the amount of RAM and there is no demand for it, the system may use it to buffer I/o (Input/Output) requests in an effort to reduce DISK I/O which is also a very good thing.

    ROM (Read Only Memory)

    This memory is used to hold specialized programs (such as the BIOS on your motherboard and Video Adapters).
    It acts just like RAM, except it is normally written once and conceptually is never erased. When someone tells you that you need a BIOS Upgrade, they are talking about changing the contents of ROM. There are many types of ROM and it is not important to really understand much more about ROM unless you are a computer expert.

    You really do not care how much you have, or that you have it at all. ROM is normally used "under the covers".

    The most common device that is in this memory class is a CD-ROM device. Compact Disks initially could only be created and never altered. This is still true, with the exception of certain CD media (and their drives) that allow you to alter the contents of the CD media itself.

    CD Burners allow you to create CD media. A CD is considered a ROM media. After all; ROM must be "created" somewhere. The CD burner simply gives you that ability.

    Disk Drives

    This memory is electro-mechanical in nature and is used to "permanently" store programs and data. We all know you can "delete" things from a disk, but you are doing it. As long as the device works, you can normally always access the data on it using the proper software programs.

    The Hard Disk Drive (HDD) is something we have all come to know, love, hate or all of the above.

    Floppy disk drives (FDD) work like hard drives but their storage capacity are much... much smaller.

    Introducing: Mr. Hard Drive

    It comes with your computer, you fill it up and then start deleting files to make more room.

    We sometimes purchase larger ones to allow us to hold more data.

    We cry when we delete the wrong stuff from it (why the thing fills up in the first place).

    Some of us actually back the "big fellow" up (make logical copies of the data), but how many of us really know how to "restore" the lost data?

    Hard drives have known to "crash" (after all, they are still mechanical in nature).

    Think of your hard drive as your computer's "filing Cabinet".

    How Mr. Hard Drive gets the job done:

  • A disk drive contains a motor which spins at a rather fast speed (7200 RPM or faster).
  • Attached to the motor's shaft are magnetic platters (a concept like what is on audio tape).
  • There is an "actuator arm" that has a read/write head for each platter.
  • The data is transferred between the disk and your system using these read/write heads.
  • The recoding media itself is organized in something called: Tracks and Cylinders.
  • If there are 5 platters, there will be 10 recoding surfaces (one on each side of each platter).
  • A recoding surface is divided up into "circles" (like grooves on a phonograph record).
  • The circles are discrete and do not connect to each other (like rings on a bulls-eye target).
  • These circles are called "Tracks" (sometimes called "heads").
  • Each track has a number, starting with 0 to how ever many there are on the recording surface.
  • Looking down on the stack of recording surfaces on the platters, the collection of all the tracks with the SAME NUMBER on all the recording surfaces is referred to as being a "Cylinder".

    An example would be a disk with 5 platters (10 recording surfaces) with 500 tracks on each surface would be:
    The device has 500 cylinders with 10 tracks per cylinder.
    The total number of tracks would be 5000 (a very small disk drive).
    Accessing data on this beast would be: "give me the data at Cylinder 75, track 3).
    This operation would cause the disk drive's "access arm" to move its read/write head under cylinder 75 and start I/O operations from track 3.

  • The data contained on the actual track can be in almost any format.
  • PC disk file systems use a fixed block architecture (a track is divided up into 512 byte segments).
  • Mainframe computers are more flexible and can support something called "Count Key Data" which means "anything goes".
  • On the PC, groups of segments are grouped together to form "clusters".
  • The cluster is how your programs locate data using tables maintained by programs on your computer (FAT/FAT32 and NTFS).

    Hard drives used to be rated by MB capacity, but now are rated by Gigabytes (GB).
    If you do not have enough, you get messages from your file system telling you "no space", etc.).
    There is no penalty to have too much disk space (unless it gets fragmented).
    Good hard drives are fast, but most of all are reliable.

    Hard drives work like a record player, as noted in the above discussion.

    The disk actuating arm must move from where it is to where it has to be...
    This is called: SEEK TIME.

    The arm must wait until the proper segment is under the read/write head...
    This is called: ROTATIONAL DELAY.

    The data must be read from (or written to) the desired segments on the disk...
    This is called: DATA TRANSFER TIME.

    This is why you sometimes hear the "clicking" coming out of your PC when you access programs and data.

    The clicking is the arm going back and forth looking for the proper cylinders containing your data. (Like picking up a tone arm on a record and putting it on another album cut).

    Hard drives are sold as capacity (GB), seek time and transfer speed.

    The transfer time is related to the speed of what you connect the device to (bus).

    Rotational delay is an "average" delay directly related to the fact that media is spinning and even if the arm is where it needs to be, the data may not be.
    The desired data may have just past the arm, which means we wait one full revolution.
    The data may be exactly where we need it to be, so we have no rotational delay at all.
    Rotational delay is almost always specified as AVERAGE Rotational delay.

    Normally it is the rotational speed (in RPMs) divided by 2 computed to fractional seconds (average rotational delay).

    Seek time is stated on the drive.

    There is much more, but I am sure you are scratching your head by now... so we move on.


    Last Update Thrusday, March 2, 2006
    Copyright © 2004-2006 www.mchenry-sc.org
    Site Email Contact: