Clever Rocks Chapter 1: What is a Computer?

James du Plessis
3 min readJul 1, 2019

When your a programmer that enjoys a cheeky beverage, you will inevitably find yourself on the receiving end of the same sort of questions from your intoxicated friends.

“So, how do computers really work?”, “If I install Windows 10 twice will I get Windows 20?”, “Can you fix my printer?”. These are all valid, and important questions. But my favourite to talk about is the first.

And that’s how this series came about. In it I will try to explain how a piece of silicon thinks. Partly because that’s insanely awesome, and partly so I have a place to point the next curious person to. I’ll also talk about memories shorter and longer than an elephant’s, the Operating System zoo, and Buses much faster than your average double-decker… I will assume no prior knowledge on the part of the reader.

The Computer

So… what is a computer? Its a machine that can automatically carry out instructions given to it. It can do this incredibly quickly. The advantages of this are clear; it alleviates the boredom of people who used to have to solve problems slowly on pen and paper. It also lets us look at cute pictures of cats and dogs.

A single instruction may be something along the lines of “Add 5 to 5”, or “Take this value and save it somewhere safe for later”. These operations are all well and good, but they don’t achieve much alone. That’s why we group these instructions together to solve real world problems. This sequential set of instructions is called a “program”. Those who write them are called programmers. Most computers have a fixed set of instructions they can use, called an instruction set (more on this when I write a blog about CPUs).

Of course, there is some core infrastructure needed to run these programs, and that leads me neatly into the basic layout of the computer.

The three layers of a computer system

A computer, physically, is built out of metal (no smooth jazz here). That’s the hardware layer. The metal is responsible for carrying out instructions, saving your data, displaying the screen, and allowing you to interact with the computer. Above this sits a very important program(s), the Operating System (think Windows 10, Linux etc). It is always running when the computer is switched on (apart from when the computer first starts!).

The Operating System (OS) has two key responsibilities. Firstly, it manages the hardware. This includes scheduling programs to run on the Central Processing Unit (CPU), managing memory, dealing with interactions between the computer and external devices (like your mouse and keyboard) etc.

Secondly, it provides us with neat abstractions from the details of the hardware. Hardware is often very complicated, and requires intimate knowledge to program directly. My favourite example is the file. Files help you organise your data, but the hardware itself has no idea what a file is. Its the OS that provides this abstraction to make your life easier. If the hardware had it its way you would be fiddling around with disk blocks, sectors, and mechanical arms directly. Yuck…

The top layer is the “Application Layer”. This consists of all the programs you know and love, like web browsers, email, games etc. These applications all sit above the OS and never deal with the hardware directly. Whenever they require access to hardware they simply ask the OS to get the resource they need for them.

Applications that cannot access the hardware are said to run in “User Mode”, and apps that do run in “Kernel Mode”. Kernel? Wtf! Don’t worry. Here it just refers to the most core part of the OS, the heart if you will. In User Mode one has access to a reduced set of the computers instructions. In Kernel Mode you have access to all of them.

Tune in next time for a brief history of the modern computer, and the Von Neumann architecture we still use to build computers with to this day :)

Icons made by https://www.freepik.com/?__hstc=57440181.1dd1812553c7ecc7e7a6eee60feabcf4.1562009325593.1562009325593.1562009325593.1&__hssc=57440181.11.1562009325594&__hsfp=462428578, https://www.flaticon.com/authors/pixel-buddha, https://www.flaticon.com/authors/prettycons from www.flaticon.com

--

--

James du Plessis

Software Engineer with a passion for programming, gaming, music, and physical sciences.