Help: How it Works: 3 of 9

 

CPU and Memory

The PowerPC Central Processing Unit (CPU or "chip") is the "brain" inside your Mac, but it isn't much to look at. It's a little slab of silicon measuring about 1" square and 1/8" thick. Inside, however, are millions of transistors... tiny electronic switches that can be turned on or off to represent a constant stream of binary "Ones" and "Zeros."

Some of those transistors are used to create the CPU's most important internal components, the "registers." These incredibly fast, remarkably simple "adding machines" are where all the "computing" actually takes place. It is the Registers that process millions of individual data "bits" each second. Where do all those data bits come from? They are "fed" to the CPU by the Random Access Memory (RAM).

Like the CPU, RAM chips are also made of silicon and have millions of transistors inside. But, they don't contain "registers" to manipulate data. The function of RAM is to temporarily store all the instructions the CPU might need to perform the various tasks you request.

The most basic Macintosh operating instructions (referred to as "The Macintosh Tool Box") are stored on your Mac's internal ROM (Read Only Memory) chip. During startup, these basic instructions, along with the many additional instructions and "resource files" contained within your Mac's System Folder), are "loaded into RAM" (copied into an empty RAM space and made available to the CPU). The block of RAM space these instructions occupy is called the "System Heap."

The instructions stored in the system heap tell the CPU and RAM how to communicate with each other, and with all the other components. In addition, it is the basic instructions in the system heap that create the unique "look and feel" of the Macintosh graphical user interface (GUI). (This is why most software applications written for the Macintosh look and behave similarly. The basic instructions for displaying windows, menus and dialogue boxes are built into the Tool Box, so that all other applications can use them.)

Naturally, once all those instructions have been loaded into RAM, the CPU needs to know where it can find them. So, each and every data space inside RAM is given a unique "address."

Each RAM address inside the first Macs was defined using THREE Bytes of data (known as "24-bit Addressing"), which could identify a maximum of only 16.7 million (2 to the 24th power) RAM spaces. As RAM sizes increased above 16 MB, however, more addresses were needed. So the Macintosh operating system began to define RAM addresses using FOUR Bytes of data (32-bit Addressing), which can define for more than 4.3 Billion (2 to the 32nd power) unique RAM addresses. (NOTE: The Memory Control Panel in older versions of System Software allowed you to choose either 24-bit or 32-bit addressing. In MacOS 8.0+, 32-bit addressing is required.)

So, now that we know what RAM is, and how instructions are identified and stored inside, let's look at an example of how the CPU uses those instructions to let you to create a word processing document.

When you double-click the icon for your word processing software, the CPU asks the hard drive to find all of the word processing instructions and load them into empty RAM spaces. When all the instructions have been loaded, the CPU executes the Macintosh Tool Box instructions needed to "activate" the program. (This all happens behind the scenes while you wait for the application to open.)

Once your word processor is active, you might tell it (using mouse or keyboard actions) that you want to create a new document. The CPU responds by asking RAM for the instructions needed to create a new document. RAM sends those instructions (provided by the word processor) to the CPU, along with the Tool Box instructions the CPU will need to create a new document window on screen.

Then, you start typing. Each time you press a key, the CPU requests the "new character" instructions from RAM, executes those instructions to create a new character, executes the instructions that add the character to the growing document data file (which is stored in a RAM space of its own), and executes the instructions that tell the monitor how to display the new character on screen. This process is repeated again and again, each time you press a key, requiring the CPU to execute millions of individual instructions each second.

When you're done typing, you might want to check the spelling of your document, so you select the word processor's "Check Spelling" feature with the mouse. What happens? The CPU requests the "how to check spelling" instructions from RAM, and tells the hard drive to find all the dictionary files and load them into RAM, as well. Then, faster than you can imagine, the CPU looks at each word, compares it to the dictionary files now stored in RAM, approves or disapproves, then moves on to the next word. But, there is something a little different about this process - the use of "cache memory."

Cache (pronounced: "cash") is a small amount of EXTREMELY fast RAM. Some is already built into the CPU (known as "Level-1 Cache"). More may be available in a separate cache module on the logic board (Level-2 Cache) or directly attached to the CPU itself (Backside Cache.) The function of cache is to store the most frequently used instructions so that the CPU can access them faster than it can by getting them from RAM. When you check the spelling of your document, the CPU temporarily stores the "spelling instructions" in cache, so it can analyze each word in the document without waiting for new instructions.

When you're finished, you need to SAVE the new document. Once again, the CPU requests and receives the Toolbox instructions it needs to tell the hard drive, "Find some empty space, create an address for that space, and copy the document (as it currently exists in RAM) into that hard drive space."

Tired of typing? Fine! Let's play a game! Tell the CPU to go get the game software from the hard drive, load it into RAM, and start having fun. But wait! Before you get too involved with killing all those pesky space aliens, we should talk about what happens to the word processing instructions that were already stored in RAM.

If you have lots of RAM installed, there may be enough room for your game's software instructions "next to" the spaces that are already filled with the word processing and Toolbox instructions. But, if you don't have much RAM, the CPU analyzes all the data currently in RAM, identifies those instructions that won't be needed for a while (you probably won't need the spell-checking or dictionary files while you're zapping aliens) and moves them to the "Virtual Memory" space on your hard drive (sort of a holding bin for things you might need later).

Of course, if you've told your computer "Don't create a virtual memory space," there's nowhere for those old instructions to go. That might be a problem. If there isn't enough empty RAM space to hold all of the game instructions, your computer may bomb. Or, if you're lucky, you might see an error message that says "There is not enough memory to launch this application," and makes a suggestion to QUIT any open software applications. If you decide to "quit" the word processor at this time, the CPU tells RAM to "flush" (remove) all of the word processor instructions from RAM to make room for the game instructions.)

NOTE: Based on this example, you can see why adding RAM and turning Virtual Memory ON increases the stability of your Mac.

NOTE 2: After several hours of use, the constant loading and unloading of instructions can cause "RAM Fragmentation" (Instruction and data files scattered throughout RAM, separated by small pockets of empty space.) If you try to launch a new application, open a large data file or perform a task that requires lots of RAM space, the CPU may not realize that all the empty RAM space is actually broken into small fragments - none of which are large enough to hold ALL of the new instructions. When this happens, you may experience a bomb or freeze, or the application might "unexpectedly quit."

NOTE 3: Although adding RAM and turning on Virtual Memory can help you avoid fragmentation, it can never be completely eliminated. So, if you've been working for several hours using a variety of different applications, you may want to take a brief rest and restart the computer. This "flushes" ALL existing instructions and data from RAM and lets you start over again.

 

BACK

NEXT

HOME . SERVICES . HELP DESK . RESOURCES . WHY MAC . CREDENTIALS
Copyright 1998, 5-Minute Mac Consulting, Wampum, Pennsylvania, USA