Thursday, 7 February 2013
RAM
RAM - Random Access Memory, or just "memory". RAM is the working scratchpad memory the computer uses to store code and data that are being actively used. RAM is effectively a storage area of bytes under the control of the CPU. RAM is relatively fast, able to retrieve the value of any particular byte in a few nanoseconds (1 nanosecond = 1 billionth of a second). The other main feature of RAM is that it only keeps its state so long as it is supplied with power. It is not "persistent". Suppose you are working on your computer and it suddenly loses power and the screen goes blank. You understand that what you were working on is gone .. RAM has been wiped clean, leaving you only with what you last saved to disk (below).
- RAM - Memory
- Temporary, working storage bytes
- e.g. new SimpleImage("flowers.jpg")
bytes of image loaded into RAM - e.g. pixel.setRed(0) ... manipulating bytes in RAM
- RAM is not persistent .. gone when power goes out
- e.g. You're working on a doc, then power goes out (vs. "Save")
RAM - Random Access Memory, or just "memory". RAM is the working scratchpad memory the computer uses to store code and data that are being actively used. RAM is effectively a storage area of bytes under the control of the CPU. RAM is relatively fast, able to retrieve the value of any particular byte in a few nanoseconds (1 nanosecond = 1 billionth of a second). The other main feature of RAM is that it only keeps its state so long as it is supplied with power. It is not "persistent". Suppose you are working on your computer and it suddenly loses power and the screen goes blank. You understand that what you were working on is gone .. RAM has been wiped clean, leaving you only with what you last saved to disk (below).
Persistent Storage: Hard Drive, Flash Drive
- Persistent storage
aka "non volatile" .. preserved when not powered - File system - files, folders
- Hard drive - stores bytes as a magnetic pattern on a spinning disk
High pitch spinning sound you may have heard - Flash drive - stores bytes as electrons in a chip
Solid state approach, aka "flash memory" - Flash drive forms - usb key, SD card in camera, flash chips built into a tablet
- Flash used to be very expensive, so most computers used drives
- However flash is getting cheaper (Moore's law)
- Not to be confused with "Adobe Flash", a proprietary media format
Persistent storage - long term storage for bytes as files and folders. Persistent meaning that the bytes are stored, even when power is removed. A laptop might use a spinning hard drive (also known as "hard disk") for persistent storage of files. Or it could use a "flash drive", also known as a Solid State Disk - SSD, to store bytes on flash chips. The hard drive reads and writes magnetic patterns on a spinning metal disk to store bytes, while flash is "solid state" .. no moving parts, just silicon chips to store bytes. In either case, the storage is persistent, in that it maintains its state even when the power is off. A flash drive is faster and uses less power than a hard disk. However, per byte, flash is significantly more expensive than hard drive storage. Flash has been getting cheaper, so it may take over niches at the expense of hard drives. Flash is much slower than RAM, so it is not a good replacement for RAM. Note that Adobe "flash" is an unrelated concept; it is a proprietary media format. Flash storage is what underlies USB thumb drives, SD cards for use in cameras, or the built-in storage in a tablet or phone, such as 16GB
Computer Hardware
There are three major parts that make up a computer -- CPU, RAM, and Persistent Storage. These three are found in a laptop, or a smart phone, or a tablet.
CPU
- CPU - Central Processing Unit
- The brains
- Performs simple operations
- e.g. Add two numbers
- Run button ... code "runs" on the CPU
CPU - Central Processing Unit - inevitably referred to as the "brains" of the computers. The CPU does the active "running" of code, manipulating data, while the other components have a more passive role, such as storing data. When we say that a computer can "add two numbers, a billion times a second" .. that's the CPU. When you hit the Run button, the CPU ultimately "runs" your code. Later on, we will complete the picture of how your Javascript code is run by the CPU.
Bytes
The space that data takes up in the computer is measured in by the "byte". One byte is big enough to hold a single typed letter, like 'a'. Here we'll look at storing data in RAM memory and in persistent storage like a hard drive. All of that storage space will be measured in bytes.
File System
- When you take a digital picture, where does it go?
- File system - organize the bytes of persistent storage
- "File" - a name, a handle to a block of bytes
- e.g. "flowers.jpg" refers to 48KB of image data
The hard drive or flash drive provides persistent storage as a flat, undifferentiated collection of bytes without any organizational structure. Typically the hard disk or flash disk is formatted with a "file system" which organizes the bytes into the familiar pattern of files and directories, where each file and directory has a somewhat useful name like "resume.txt". When you connect the drive to a computer, the computer presents the drive's file system to the user, allowing them open files, move file around, etc. Essentially, each file in the file system refers to a block of bytes, so the "flowers.jpg" name refers to a block of 48KB of bytes which are the data of that image. The file system in effect gives the user a name (and probably an icon) for a block of data bytes, and allows the user to perform operations on that data, like move it or copy it or open it with a program. The file system also tracks "meta information" about the bytes: how many there are, the time they were last modified. Microsoft uses the proprietary NTFS file system, and Mac OS X has its Apple proprietary HFS+ equivalent. Many devices (cameras, MP3 players) use the very old Microsoft FAT32 file system on their flash cards. FAT32 is an old and primitive file system, but it is good where wide support is important (Microsoft claims to hold patents needed to read or write FAT32, but it is widely implemented anyway). Proprietary and patented formats make it hard to store and use your own data.
Pictures of Hardware

Subscribe to:
Comments (Atom)