The main components: an overview (image source).
Moves data around on the bus, the "highway system" of the computer.
Some OS's are really only intended to be used graphically, i.e. visually manipulating windows using the keyboard and mouse (notably: Microsoft Windows and Mac OS X). For scientific computing, non-graphical 'command-line' interfaces are potentially much more powerful, though a learning curve must be cleared: every single operation is instantiated using keyboard commands only, and the only feedback to the user comes in the form of text output in terminal window.
Where the Host OS 'directs' the computer in the tasks it is to perform, a virtual machine is a Guest OS: it issues precisely the same commands it would if it were a 'proper' Host OS itself, but the commands are 'intercepted' by the Host before their delivered to the hardware. There are many flavours of virtualisation, each with different optimal usage cases. We will be introduced to the strategy shown in this image, in which a sofware (VirtualBox) emulates hardware, and enables us to run a Linux OS on Windows (and Mac) PCs.
"Driven" (only) by data in memory; only data in memory can be processed (limits on computations).
In [ ]:
import random
secret_number = random.randint(0, 9)
guessed = False
while not guessed:
cur_guess = int(input('Guess the 1-digit number: '))
if cur_guess == secret_number:
guessed = True
print('You guessed it!')
What the CPU is actually doing is quite simple, shown below in charicature-form. The first column is a memory address (here just a running sequence). The second column is the contents of the memory address: an instruction or some data.
1 BEGIN Guessing game
2 LOAD secret number from memory address 743
3 OUTput letter to screen
4 G
5 OUTput letter to screen
6 u
...
51 GET keyboard input (blocking, execution halted)
52 PUT keyboard input to address 1197
53 COMPARE memory address 1197 to address 743
54 IF comparison EQUAL, JUMP to memory address 104
55 OUTput letter to screen
56 G
57 OUTput letter to screen
58 u
...("Guess again: ")
103 JUMP to memory address 51
104 OUTput...
..."You guessed it!"
152 END Guessing game
...
743 [some random number generated by other program/code]
...
1197 [input from subject placed in free portion of memory, somewhere]
The controller unit deciphering CPU instructions can only process one command per cycle/tick of the internal clock (today measured in GHz -> billion ops per sec). The feeling we have as users of fluidity of a UI is an illusion: the CPU very rapidly switches between different tasks.
To first order, everything in a CPU happens in a serial fashion with rapid switching.
The name for logically separate streams of serial tasks is a thread. Think of them as lines of thought of the CPU. A modern OS has dozens of open threads at any time, and it more or less cleverly splits its time between the threads in most need (e.g. the thread listening to data transfer on a USB port becomes active with incoming data, which the CPU needs to allocate "cycles" to move into memory as appropriate). But always: just one thread at a time!
Today's CPUs are actually able to perform multiple instructions per clock tick, but to leverage that requires the programmer to think about the problem being solved. It's not something normal users need to consider.
A more significant evolution of the CPU is that today's consist of multiple cores. Fundamentally each core can process a thread independently and concurrently with other cores, leading to a form of parallelism.