There are many parts of the modern world that seem to run on a strange type of magic – a sorcery based on doped silicates and rare earth metals. With a little attention, this magic looses it’s sheen and the sufficiently advanced technology behind it is revealed. In this article I will cover how some of the most fundamental parts of modern computing can be demystified.
To run, a program must be read from Secondary storage, storage that is not immediately available to the processor. This is because Primary storage, storage that is directly available to the processor, such as Random Access Memory (RAM) or Cache, cannot survive reboots, as when you reboot the computer, the data does not persist. So upon booting, the Central Processing Unit (CPU) asks the primary storage for the first partition. This partition usually contains the Basic Input Output System (BIOS) on older computers or the Unified Extended Firmware Interface (UEFI) loader on newer ones. The purpose of these pieces of software is to set up hardware in a way that allows it to be used by the Operating System, and usually to start the Boot loader, which finally loads the Operating System (OS). All this happens within a fraction of a second, well before any Windows logo shows up.
Let’s go into one of the smallest parts of the BIOS, the single Instruction. Let’s assume that the CPU has just finished handling the last instruction. A Register, a fast segment of memory under the direct control of the CPU, called the Program counter is copied into another register called the Memory Address Register (MAR). The contents of this register is sent to the RAM on a pathway called an Address Bus. Buses used to be parallel bundles of cable but they, like other old parts of computer architecture, have been updated – nowadays Buses refer to any method of transferring signals from one component to another. Once at the RAM, the RAM controller searches the RAM for the data and sends it back to the CPU on the Data bus. When it arrives the CPU, the program counter is incremented and the data from the Data bus is copied into the Memory Buffer Register; from here it is copied by the CPU’s Control Unit into the Current Instruction Register. The control unit then splits up the instruction into Opcode (short for ‘Operation Code’) which specifies the operation to be performed in a way understandable by the processor. This gets sent to the Arithmetic Logic Unit (ALU) which performs the operation and stores it in a temporary register called the Accumulator until it can be put to better use, possibly by the next instruction in storage3.
When you press any key on a keyboard, a Switch (mechanical or conductive) under the key is compressed, which either completes a circuit in the case of a mechanical keyboard or increases the current flowing under the key in the case of a capacitive one. Either way, this action generates a detectable signal which is sent to a Microprocessor on the keyboard itself. The microprocessor handles and processes this data into a form that the rest of the computer can read.2 This is then sent to the aptly-named Programmable Interrupt Controller (PIC) in the form of Scan Codes, which are usually a list of numbers indicating which keys have been pressed. Once the Scan Codes have arrived, the controller it sends the CPU an Interrupt, a signal that tells the CPU to drop everything and handle the request. Upon finishing its current instruction, the CPU checks the PIC for an interrupt and if one has occurred the CPU jumps to the location in memory that contains the part of the OS that handles the request. Once the operating system acknowledges the interrupt it then gathers data (in this case, what keys were pressed), bundles this data up and sends it to the currently running program4 . This program then decides how to handle the Key-event (to display it on screen in a Search Bar, for instance). On average this happens 3-4 times a second for the keyboard, and much more often for things like mouse movement which follows a similar process.
Your monitor and graphics cards are peripherals just like the keyboard and mouse, but unlike the keyboard and mouse which interrupt the graphics card, they use something called mapped memory. This means that, for example, setting the value of the 753664th5memory address could be the start of the Screen Buffer, an area of memory that contains the colours of the screen pixels. Therefore, in order to display an image, a program would have to load the image into RAM and then copy it into the buffer that the graphics card expects. If the program requires complex image manipulation, it could send commands from a library like OpenGL or Direct3D which provide high-level interfaces to the graphics hardware. The graphics card converts this data into digital (or analogue depending on age and connection type) signals that the monitor can understand. The monitor, which is essentially a back-light covered by colour and polarising filters, then blocks out light by using a filter polarised at 90 degrees to the constant filter at the sub-pixel level.
A Cat Photo
We have now covered the three of the four main aspects of modern computing: input, processing and output. The final one, Abstraction, simply means that the details of operation one part of a software system should have very little impact on the details of operation of another part of the system. i.e. It only matters that your monitor reads in some voltages and displays output to you, how it does its job is not your graphics card’s business. When dealing with abstraction can be difficult so lets tackle it with something simple: a cat photo.
When you click on a button you are interacting with the Application Layer: this layer is composed of the user and application handling raw data such as images, text, and html files. The next layer is the Presentation Layer: this layer deals with the protocols and interfaces used by the sender and receiver, and in this case, you are usually using http a protocol for sending documents over the internet in the form of requests and responses. The request looks something like this:
GET www.mycoolsite.tldshavegonetoofar/imgs/cat.gif HTTP/1.1.
Breaking this down, the GET portion means that the request is to retrieve (“get”) data (there are others like PUT, DELETE and TRACE but for now GET will do); the
www.mycoolsite.tldshavegonetoofar/imgs/cat.gif tells the receiver, in this case a server, that the thing we want is stored at the location
mycoolsite.tldshavegonetoofar. This data is sent as raw bytes to the the server then responds with a HTTP response formed of a status line containing the version number, the status code (such as ‘200’, ‘404’, ‘101’), and a phrase (‘OK’, ‘File not Found’ or ‘Switching Protocols’, for instance). This layer is also usually in charge of encryption. The next layer is called the Session Layer which is a layer that controls (initiates, manages and terminates) connections between computers. This layer is the last layer usually explicitly created in software and lowest layer still under control of the application – it is usually the web browser’s job to handle these connections. 1
Underneath that, there is the Transport Layer. This layer and the ones below it are responsible for transforming the data presented into a form that can be sent across a wire or over radio waves, splitting the data into packets and giving them a way of identifying what application they were sent from and what order they were sent. This layer also deals with the actual routing and path finding of the packets. To transfer the data between the individual computers, called nodes, the transport layer uses another layer, the Network Layer, which adds MAC and IP addresses to identify the source and destination nodes. Delivery of the packets on the Network Layer is not guaranteed to be reliable as packets can be dropped (when this happens it’s called a Black Hole); if they have been dropped, they are usually resent with a few confirming checks. Under this, there is yet another layer called the Data Link Layer, which splits packets into frames with headers and footers to distinguish the current packet from other packets on the same network. Finally you get down to the Physical Layer. This layer defines the electrical and physical properties of the connection, (the specification for an Ethernet cable, for instance). Now that we have gotten past all the abstractions in modern networking, let’s get back to the cat photo.
After the request has been sent, the transport layer selects and calculates a path between you and the server; the Network Layer handles the transmission to the next router in the path; the Data-Link and Physical layers actually transfer the data to the next router in the chain. When at the next router, it performs the same set of calculations and sends it on to the next router, so on until the destination is reached. At the destination (the server-end) the server’s layers undo the alterations made by the client’s layers, stripping headers and extracting the raw data, so that the server application can read the actual message body. It then sees that this is an image request and then creates a response with that image’s bytes embedded. A response is sent back in the same way, the client (your computer) decodes it and your web browser takes that cat photo data, decompresses it, and finally puts it on your screen.
This view of the modern networking is called the OSI model. Each layer has no interest in how the others do their job, dealing with only it’s own input and output. This allows the system as a whole to be very flexible as the implementation of each layer (e.g. Ethernet, a Web Browser) can be swapped out with any other (WiFi, a online video game) as long as it performs the same role in the system.
I hope that this article has made some of strange eccentricities of the modern world slightly clearer, explaining the fundamentals (input, output and processing) of modern computing as well as demonstrating just why it is so powerful (abstraction).
- Fielding, et al.. (2004). RFC 2616 Hypertext Transfer Protocol -- HTTP/1.1. Available: http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html. Last accessed 1st Sep 2015.
- Unknown. (2014). Comparing Mechanical, Membrane and Scissor-Switch Membrane Keyboards - Ergonomic Considerations of Keyswitch Type. Available: http://www.ergopedia.ca/ergonomic_concepts/Mechanical_Keyswitches_Membrane_Keyswitches_and_Scissor_Switch_Membrane_Keyswitches_Ergonomic_Considerations.html. Last accessed 31st Oct 2015.
- Bosky Agarwal. (2004). Instruction Fetch Execute Cycle. Available: http://web.archive.org/web/20090611211308/http://www.cs.montana.edu/~bosky/cs518/ife/IFE.pdf. Last accessed 31st Oct 2015.
- Wienand, I. (2013). Peripherals and busses. Available: http://www.bottomupcs.com/peripherals.html. Last accessed 31st Oct 2015.
- Numerous. (2014). GUI. Available: http://wiki.osdev.org/GUI. Last accessed 1st Sep 2015.