Module 1.1 - Hardware Components

You are most likely familiar with the term hardware: the physical equipment and devices that a computer is made of. In this section we will explore the three primary categories of hardware components:

  1. The CPU
  2. Primary Memory and Secondary Storage
  3. Peripherals

In the following section we will discuss software: the programs that run on the hardware.

The Central Processing Unit (CPU)

The "brain" of any computer is known as the CPU (or sometimes as just the processor). It performs most of the "computing".

In this course, we will not discuss how CPUs work in great detail. However, you might be surprised that most CPUs only perform a few very basic operations:

The magic of the CPU is twofold:

  1. A lot can be accomplished with those few basic operations, and
  2. CPUs are really really fast.

Each CPU has its own machine language that is used to give it instructions. Typically, instructions designed for one CPU will not work on another. However, many CPU manufacturers have chosen to make their machine languages compatible (e.g., Intel and AMD). In addition, there are ways to tackle CPU and hardware incompatibilities with software, which we will discuss later.

When you are buying a computer, the CPU is one of the most important components to consider. Unfortunately, depending on the computer you're looking at and where you're shopping, the CPU information may be prominently displayed with confusing acronyms, or it may be hidden away as an insignificant detail. This problem is made worse because of marketing materials intentionally designed to obfuscate (confuse) and mislead.

If buying a computer is analogous to buying a car, then the CPU is like the engine of the car. For some consumers, the make, model and capacity of the engine/CPU is extremely important, but for others the colour, size, and features of the car/computer are more important. As with a car engine, the CPU is one of the most significant costs of a computer, and so the price of the computer is often a reflection of the quality of the CPU.

There are a few key characteristics of a CPU that are worth paying attention to.

  1. Make & Model. Each manufacturer has different CPU models that will determine the characteristics of the CPU. For example, an Intel i7 processor is more powerful than an i3 processor.

  2. Speed. The speed of a modern CPU is measured in GHz (Gigahertz). A 3 GHz processor can theoretically perform 3 billion operations per second ("Giga" = billion, "hertz" = per second).

  3. Number of Cores. Most modern CPUs are a combination of several processors or cores. A quad-core processor has four independent processors built into a single chip. Effectively, a quad-core can do four times as much computation as a single core. Multitasking with multiple cores will be briefly discussed later.

  4. Power Consumption. With mobile devices, power consumption has become very important. The speed and number of cores can affect the power consumption. Some processors can even slow down their speed and switch to a "low power mode" to save battery life.

  5. Cache. Cache (pronounced cash) is briefly discussed below. For now, all you need to know is that a big cache is better.

The most popular CPUs for desktop computers (PCs and Mac) are Intel and AMD. For mobile devices, ARM-based CPUs are very popular because of their power consumption (e.g., Snapdragon and Apple's A9).

Primary Memory and Secondary Storage

Secondary Storage

We will describe secondary storage first because it is more tangible than primary memory and we can interact with it directly.

Secondary storage is the long term (permanent) storage of a computer. Secondary storage devices you are probably familiar with include hard drives, flash drives, CDs and DVDs. Historical devices include magnetic tapes and floppy disks.

For most of modern computing, the most common type of secondary storage devices have been hard drives. Inside of a hard drive there are several magnetic disks (or platters) that can store an incredible amount of information in a small amount of space. Hard drive capacities are measured in terabytes (TB) or trillions of bytes. Hard drives are called "drives" because there is a physical motor that spins the magnetic discs (just like you 'drive' a car when the engine spins the wheels around).

Flash drives are becoming increasingly popular as secondary storage devices. Although the technology behind flash drives is complicated, the core technology is more like static electricity than the magnetism used by hard drives. Flash drives include USB sticks and the SD cards made popular by digital cameras. There are also high speed and higher capacity flash drives known as Solid State Drives (SSDs). Because they have no moving parts, flash drives require significantly less power than hard drives, making them very popular in mobile devices. Modern SSDs are also faster than hard drives, but they have not completely replaced hard drives because (a) they currently have lower capacities and (b) they are more expensive. There is no reason to call a flash drive or SSD a "drive" because there is no motor or any moving parts, but the name has stuck to ease the transition for consumers.

The secondary storage of a computer typically contains:

Because the secondary storage stores everything you need, it begs the question what the primary memory is needed for.

Primary Memory

Every computer requires some primary memory (or main memory) to work properly. Primary memory has also traditionally been known as the RAM (Random Access Memory) of the computer. The primary memory is the "working space" of a computer and everything that is being "done" on the computer (executing, displaying, calculating) is stored in the primary memory.

The CPU cannot access secondary storage directly. Instead, the information is copied from the secondary storage to primary memory, where it can be "used". For example, because your application programs are stored in your secondary storage, when you launch an application the operating system first copies the program into your primary memory and then starts the program. This is why there may be a delay when you launch an application.

Similarly, when you open a file (or document), the file is copied from secondary storage to primary memory. When you save a file, it copies the document from primary memory back to secondary storage.

The save floppy disk

Fun Fact: Even in modern software, the image used to represent saving your data back to secondary storage is often a floppy disk (one of the earliest secondary storage devices).

Saving your information back to secondary storage is important because primary memory is not permanently saved. If your computer loses power or crashes, the information in primary memory is lost. Many programs such as Microsoft Excel will "autosave" your data back to secondary storage in case there is a crash or power loss. Some operating systems (e.g., Windows) can "hibernate", causing the contents of the primary memory to be saved to secondary storage before the power is lost.

When you turn on your computer, the primary memory is initially empty (or blank). The computer then "boots up" by running a tiny program known as a boot loader. This boot loader is stored on a separate chip known as ROM (read-only memory). This boot loader then copies (loads) the operating system from secondary storage into primary memory so it can be run. Eventually, the operating system and start-up programs are loaded into primary memory and the computer becomes usable.

To help understand how the CPU, primary memory and secondary storage interact, we will use an analogy.

Consider a person (Cooper) who's brain is the CPU. Unfortunately, Cooper suffers from chronic amnesia and cannot remember anything that is not in front of him. Cooper is sitting at a desk representing the primary memory. Cooper can only see the pieces of paper placed on his desk (and he can't cheat by stacking papers). Down the hall, in another room is a filing cabinet filled with pieces of paper representing the secondary storage. Cooper can't access the filing cabinet directly. If Cooper needs a piece of paper from the cabinet, he has his assistant (Aaron) make a copy of the page in the cabinet and then Aaron places the paper on Cooper's desk.

The 'desk' memory model

At the start of each day, the desk is empty. To begin work, Cooper has Aaron copy several pages from the filing cabinet and place them on his desk. Cooper's can now "see" those pages and "work" on them. Cooper can read the pages, follow instructions on them, and even make changes to the pages by writing on them. However, at the end of the day all of the papers on his desk are destroyed. If Cooper wants to "save" any of his work, he has Aaron make copies of his (modified) pages and then place them in the filing cabinet, possibly replacing the old pages.

This analogy holds up surprisingly well and highlights the significant differences between primary memory and secondary storage:

  1. Capacity. Primary memory is much smaller than secondary storage. You can store a lot more information in a filing cabinet than on a desk. Primary memory is typically a few gigabytes (whereas secondary storage is measured in terabytes).
  2. Speed. Primary memory is significantly faster than secondary storage. It is a lot faster to view information on a desk than retrieve it from a filing cabinet. Even the fastest SSDs are 50 times slower than primary memory and hard drives can be 1000 times slower.
  3. Connectivity. The CPU can communicate directly and "see" the information in primary memory (the desk) but not secondary storage.
  4. Permanency. Imagine that the filing cabinet (secondary storage) is secure and fireproof, but the desk is completely cleared whenever Cooper leaves (shuts down) for the day.

Consider the size (capacity) of Cooper's desk and how that affects his productivity. With a large desk, he can have several "projects" going on at the same time and can access them all, but with a small desk he can only manage a few projects.

What if Cooper has run out of space on his desk, but he needs to look at another piece of paper? In this situation, Cooper will simply shred one of the pages to make room. Of course, Cooper is not careless and will shred one of the pages he knows already exists in the filing cabinet. If Cooper needs that page again, he can simply have Aaron make a new copy for him again later. In a really bad scenario where there is very little space on the desk, Cooper may need to shred a page he has modified (written on), in which case he can first have Aaron copy the page and put it in the filing cabinet before he shreds it.

The size of Cooper's desk illustrates how having more primary memory can significantly speed up a computer. With more primary memory, more programs can be running at the same time. In addition, more of each program can be loaded into the primary memory to avoid having to access the slow secondary storage. If you have ever seen a computer slow down because of too many programs running at the same time, it is because the primary memory has filled up, and the computer has had to resort to access the secondary storage more often. In our analogy, when a computer really slows down it may be because Cooper is continuously shredding the same pages over and over again because he just doesn't have enough room on his desk to get the job done, meanwhile Aaron is going insane copying the same pages for Cooper over and over again.

Earlier, we mentioned that some CPUs have a cache. A cache is like a fast "short-term" memory built in to the CPU. It's neither primary memory nor secondary storage because it's built in to the CPU. Cache can be thought of as a type of "super" memory that is approximately 100 times faster than the primary memory (which in turn, is much faster than secondary storage).

In our previous analogy, Cooper had chronic amnesia and couldn't remember anything. He had to keep looking at his desk (primary memory) frequently. A cache would correspond to Cooper having a few post-it notes stuck to his arm. If Cooper can look at his arm without having to look at it on his desk, he will be much faster and productive. A larger CPU cache (more post-it notes) means that the CPU can perform more work before having to look information up in slower primary memory.

Peripherals

The last category of hardware is peripherals, which covers every piece of hardware and physical device other than the CPU, primary memory and secondary storage. Peripherals that you commonly interact with are:

Peripherals that you may use, but don't directly interact with are:

In the very early days of computing, peripherals were very complicated and it required a lot of customized hardware and software to get a peripheral to "talk" to the CPU.

A piece of software designed to let the hardware talk to the operating system is known as a device driver or simply driver. They are called a "driver" for similar historical reasons that we still refer to flash drives as "drives". To give you a basic idea of how peripherals work, we will describe the basics of how a mouse (event-based) and a camera (polling) work.

There is a special piece of hardware connected to your mouse that is completely dedicated to waiting for a mouse event to occur. This hardware sits outside of the CPU, but it has a connection to the CPU that we can imagine as a tiny "alarm bell" that can "wake up" the CPU. This hardware can also talk to the primary memory and put some information in a dedicated location. When a mouse event happens (either you move the mouse or you click a button) the hardware gets really excited (it was waiting a really long time) and puts the mouse information into primary memory (e.g., "the mouse was moved a tiny bit to the right"). The hardware then "rings the bell" and "wakes up" the CPU. The operating system then stops whatever it was doing (it is called an interruption) and uses dedicated software (the driver) to read in and properly interpret the information (e.g., "the mouse was moved a tiny bit to the right"). The operating system might then run some software to move the mouse cursor right a bit on the screen, or if you're playing a game, to tell that game that your elvish warrior is now looking a little bit more to the right. All of this occurs within a microsecond. Your computer is constantly being interrupted by event driven peripherals (touch screens, mice, keyboards) so it can properly respond to the events.

Using our analogy with Cooper and his desk, imagine that in that room there is another person (Evan) watching to see if someone moves the mouse. If Evan sees that the mouse was moved, he puts a special code on a piece of paper and then puts that paper on Cooper's desk. He then rings a bell or slaps Cooper to let him know that a mouse event happened. Cooper then stops what he was doing and looks at another piece of paper on his desk (the device driver) that helps him interpret Evan's code. Cooper now realizes that the mouse has moved and writes on other pieces of paper accordingly. Cooper then resumes whatever he was doing before.

The alternative to event-based peripherals are polling peripherals such as your camera. There is dedicated hardware like with the mouse, but the "alarm bell" works the other way around. In the case of polling-based peripherals, the operating system decides when it wants information from your peripheral and tells it to "wake up" and gather the information. So if you decide you want to take a picture, the operating system asks the camera (via the device driver) "what do you see now?" and then the camera puts some data in primary memory for the operating system to grab. When you want to take a movie, the operating system says "what do you see now?" "what do you see now?" typically 30 or 60 times per second. In the case of your display, it works similarly but instead it says "this is what you display now" "this is what you display now" 60 times per second.

Returning again to our analogy with Cooper, in this situation there is again someone else in the room (Polly) who controls the camera. When Cooper needs a picture taken with the camera, he taps Polly on the shoulder and then tells her to take a picture and where to put it on the desk. Cooper then goes back to whatever work he was doing. Polly would then take a picture, put it on Cooper's desk, and then put a note somewhere on the desk letting Cooper know the picture has been taken. Cooper would be periodically looking for that note, and when he sees it he knows the picture is ready and he can do something with it.

We briefly mentioned the screen/display, but it fits in our analogy quite nicely. Cooper dedicates a region of his desk to correspond to whatever is to be displayed on the screen. Every 60 seconds, he taps another person (Dennis) on the shoulder, and Dennis grabs the information from Cooper's desk and displays it on the screen.

To put it all together, consider this sequence of events. Evan slaps Cooper to let him know that the mouse button was clicked. Cooper then consults some of his pages and realizes that the mouse was over the "take picture" button. Cooper taps Polly on the shoulder and tells her to take a picture and then Cooper resumes his other work. Cooper sees the note that Polly is done, so he then takes the picture and copies it into the special display region of the desk. Cooper then taps Dennis on the shoulder and Dennis updates the display so the user can see the picture taken with the camera. To help put things in perspective, it may help to remember that Cooper is hundreds or even thousands of times faster than Evan, Polly and Dennis: to them, Cooper looks like the flash and is just a blur.

Polling peripherals are becoming increasingly more common, partly because they consume less power. We used the mouse as an example of an event-based peripheral, but modern mice are often polled "did the mouse just move?" "did the mouse just move?" "did the mouse just move?".

Modern operating systems are equipped with numerous device drivers so you can connect a wide variety of devices. The USB (Universal Serial Bus) standard was a great leap forward in standardizing how peripherals (and secondary storage devices) connect to computer.

Year after year, computers are being equipped with more and more peripherals. Can you imagine early computing pioneers envisioning that a GPS would connect to the computer? Why would you need a GPS when the computer weighed several tons and took up an entire room?

Hardware Convergence

As a final note on computer hardware, it is worth mentioning that hardware convergence is an increasingly popular trend driven by mobile computers. It is when the hardware (computer chips) for several different hardware components are combined together into a single chip. This is also known as a System on a Chip (SoC). The advantage is to decrease size, increase speed and reduce power consumption. For example, a single chip on a cell phone or tablet could contain the following hardware components:

While the components are all contained within a single piece of hardware, they are conceptually separate and their behaviour is the same.

Using our ongoing analogy, hardware convergence would be like someone welded together Cooper, his desk, Aaron, Dennis, Evan and Polly. They are still independent entities but they are all fused together and can fit in a much smaller space.