Summary:Low-level operations and computer architecture

From Higher Computing Science
Jump to: navigation, search

Computer architecture

  • A virtual machine is a software program which simulates a hardware platform. This means that it can allow a computer to run an Operating System within another operating system. The hosted OS acts as if it is running on a physical computer, but every hardware call is routed through the virtual machine.
  • Virtual machines contain the actions of the hosted Operating System because the software can control access to devices and networks.
  • Virtual machines use the processor of the computer directly (i.e. with the same machine code) but the programs run within the virtual machine can only interact with the hosted OS.
  • Virtual machines can also be created to run a program. The VM can protect the rest of the computer from being accessed by the program directly. This makes the program's execution much safer. This approach is called sandboxing. Sandboxing is used with Java, Python, Javascript and many other languages to separate the code being executed from the host computer.
  • Examples of virtual machines include PC-based solutions such as VirtualBox or VMWare, server based “Virtual Private Servers” such as Xen, or sandboxed Virtual Machines for programming languages such as Java.
  • An emulator is a software program that simulates a hardware platform including the processor. This means that a computer with one type of processor can run software designed for another type of computer - e.g. a Windows PC with an Intel processor can run Gameboy games, even though the Gameboy has a different set of hardware features and a Z80 processor.
  • Emulators are useful for running executables that use a different hardware platform and means that the software can be tested without the original device. This is used to test Android or iOS applications (running on ARM processors) on Intel computers.
  • Many applications are now developed for mobile devices, rather than PCs
  • Mobile applications have different requirements than PC applications:
    • Mobile apps often have limited access to memory or storage space
    • Mobile apps need to be power-efficient as they will run on batteries
    • Mobile apps will be using unreliable/wireless communication
    • Mobile apps can use sensors to detect location (GPS), movement (accelerometer), image data (digital camera)
  • Mobile apps are not developed on mobile phones. They are developed on PCs and emulators are used to test apps before they are deployed to mobile devices.

Data storage

  • Binary is the name given to the base 2 number system. Binary numbers are represented with two values, 0 and 1.
  • Computers store numbers as binary code.
  • Converting between decimal and binary can be carried out by grouping the number into values that represent each binary column: 128, 64, 32, 16, 8, 4, 2, 1
  • To convert a decimal number to binary, start with the highest possible number that is smaller (or equal to) the decimal number, and place a 1 under the column needed. Repeat the process with the remainder of the number. Place a 0 in any unused column.
  • To convert a binary number to decimal, add together the values of each column.
  • Two’s complement binary is used when numbers must be positive or negative
  • Two’s complement binary uses the highest value column to represent a negative number instead of a positive number (for example, an 8 bit two’s complement number stores the number -128 in the highest bit)
  • To calculate the two’s complement for a negative number, flip the bits of the binary for the positive version of the number, and add one. (e.g 65 is 01000001 so to get -65 you need to flip the bits to 10111110 and add one, giving 10111111). This can be double checked by adding the columns: -128 + 32 + 16 + 8 + 4 + 2 + 1
  • A real number is a simple data type stored as a floating point number – a number split into two parts
  • A real number is a number with a fractional part (or decimal place).
  • A real number is stored in parts called the mantissa and exponent. This kind of number is called a floating point number.
  • The mantissa is a number used to store the precision of the number. The number of bits reserved for the mantissa determines its precision.
  • The exponent is a number used to store the range of a number. The number of bits reserved for the exponent determines its range.
  • Floating point numbers can also used an extra bit called a signed bit to indicate whether a number is positive or negative


  • The ASCII character code uses 7 bits giving 128 possible characters. ASCII characters are stored in groups of 8 bits – the extra bit can be used for error checking.
  • ASCII stands for American Standard Code for Information Interchange and has been used as a standard character code by many computers for decades.
  • Unicode is an international version of ASCII that includes characters used in non-English alphabets. It uses 16 bits rather than 7 which gives 65536 possible characters.
  • Unicode characters take double the storage space of ASCII characters.


Graphics

  • Bitmap graphics are stored as a grid of pixels. Each pixel is represented by a number that tells the computer what colour the pixel should be.
  • The bit depth of an image is the number of bits used to represent each pixel. A bit depth of 1 will only allow a 1 or 0 per pixel (black or white). A bit depth of 8 will allow 8 bits per pixel meaning the computer has 256 colours to choose from.
  • The colour for each pixel is often represented by a colour code, which uses a number of bits for red, green and blue. In HTML, this is represented as a 24 bit number, with 3 numbers between 0 and 255 for each colour.
  • The size of a bitmap graphic can be calculated by multiplying the resolution of the image by the bit depth. The bit depth can be worked out from the number of colours.
  • Vector graphics store the attributes (position, colour, line thickness etc) of shapes and allow the user to perform operations (resize, delete, move) on the shapes. This means that the value of each pixel in a picture is not stored, just a list of instructions to create each shape on screen.
  • A vector image can be re-edited at any point because the computer can simply change the attributes the edit the picture. A bitmap image can only be edited at pixel level – no information about what shapes are used in the picture is stored.
  • Vectors are resolution independent. This means that the vector graphic can be redrawn at any scale on the screen. This is not the case with bitmaps, which pixelate when the user zooms in.

Sounds

  • MIDI stands for Musical Instrument Digital Interface. MIDI is a file format and protocol for communicating between devices. MIDI is used to send digital data about music between devices, rather than the resulting analogue sound.
  • A digital instrument (MIDI) sound file does not store samples. Like a vector graphic, a MIDI file is a set of instructions that is used to play music. Each note has attributes (sound, length, volume, time etc) that place it into the sequence of notes in the file. MIDI files can be played back by a computer using its own digital instruments.


  • Sampled sounds are stored by digitising the sound wave recorded by a microphone. The sound wave is sampled thousands of times per second and the values are recorded into a file.
  • The quality of a sound file is determined by how many samples per second are taken, and the sampling depth of each sample (the number of bits used to represent the sample)

Inside the computer

  • There are three main components to the processor: The ALU, Registers and Control Unit
  • The ALU (Arithmetic and Logic Unit) is the part of the processor where logical operations and calculations are carried out.
  • The Control Unit is used to control the flow of data between the processor and memory. The Control Unit interacts with the control bus to do this.
  • Registers store single items of data while they are being used in the processor.
  • A register called the Program Counter keeps track of the location of the current instruction in memory.
  • A register called the accumulator is used to store the result of any calculation.
  • Cache is fast, efficient memory that is used to speed up the retrieval of the most-used data and instructions from memory.
  • Cache is built onto the processor, or near to it on the motherboard, so that it can be accessed quickly.
  • Cache is expensive compared to RAM, so usually it is much smaller than RAM.
  • ROM chips are read-only memory. The data is written onto the chip when it is manufactured.
  • ROM chips are used to store programs and data that must be available to the computer when it boots up.
  • Bootstrap loaders, programs that help to identify the components of a PC and start up the Operating System from the hard drive, are often stored on ROMs.


  • Computers store programs and data currently in use in RAM (Random Access Memory)
  • RAM consists of a set of memory locations each with an individual address
  • RAM is not persistent – when the computer is switched off, RAM will lose its values.
  • RAM is used for storing programs and data when in use because its access time is much quicker than backing storage devices. RAM data access is measures in nanoseconds – hundreds of times faster than accessing a hard drive.
  • The control bus is a set of discrete lines that all indicate what more the processor is working in.
  • The read line on the control bus is set when a read operation is to be carried out
  • The write line on the control bus is set when a read operation is to be carried out
  • The clock line is switched on and off to provide a synchronising pulse for the processor to use when coordinating the movement of data
  • The interrupt line is used to change the state of the processor by replacing all the values in its registers (this is how programs can be switched)
  • The non-maskable interrupt line is used to change the state of the processor even when another program wishes to use the processor
  • The reset line zeroes all data in the processor and buses
  • The data bus sends data from the processor to memory and back again. The data bus only works in conjunction with the address bus (it must have a memory address to read from, or write to)
  • The data bus is bidirectional – data can travel from memory to processor or processor to memory.
  • The size of the data bus determines how many bits the processor can process in one operation. This is called the word size.
  • Increasing the size of the data bus improves system performance, as more bits can be transferred each clock cycle.


  • The address bus identifies locations in memory that can be used to read or write data. An address such as 10011001100110011110101101111001 would be used to identify the location in memory to read from, or write to.
  • The address bus is unidirectional – addresses only ever transfer from the processor to the memory.
  • The size of the address bus determines the number of locations in memory - 2 to the power of the number of lines on the address bus. This can be multiplied by the size of the data bus to calculate the total addressable memory.
  • An interface is a piece of hardware that allows to devices to communicate. An interface can also be used between internal components in a computer.
  • Interfaces are needed because different components/devices have different operating speeds, data formats and protocols