Filters

Other

D

Your name is required for this document. It is only stored on this local computer and no where else. Please enter your name below:

National 5 Computing Science Computer Systems Revision Notes

Knox badge
National 5 Computing Science Computer Systems Revision Notes
This is an HTML-based version of my revision notes.

Computer Structure

A computer system is made up of several components. For National 5, you need to have an understanding of the purpose of and the workings of several of these components.

The Central Processing Unit

The Central Processing Unit or CPU is the part of a the computer that carries out (executes) the instructions passed to it.

CPU

A CPU

The CPU speaks to the other parts of the computer and makes the hardware and software work together.

Computers these days can carry out billions of instructions per second.

A processor is made up of several different components itself.

The ALU

The ALU or Arithmetic and Logic Unit is the part of the brain responsible for performing mathematics calculations and logical decisions within the computer system.

This means it carries out operations such as addition, subtraction, multiplication and division, but also logical comparison such as comparing if one number is larger than another etc, and also making decisions based on logical expressions such as those containing and, or and not.

The ALU is designed in a way that it works very fast to make a computer system responsive at all times.

One of the key areas of research during the development of multicore CPUs was adding a second or third ALU to the CPU. This ended up being one of the key features of multicore CPUs.

The registers

The registers are a key part of the CPU that act as temporary memory locations. They are very small and only hold a couple of 1000 bytes of data.

Generally registers only store instructions and small amounts of data whilst the processor is working on them. To speed up a computer, the CPU also has a larger, yet slower temporary memory called cache memory.

The control unit

The control unit is the part of the computer which controls everything. The control unit sends out clock pulses that keep everything in sync (a clock pulse simply tells everything to work).

The control unit has a series of lines (wires) connected to it that allow the CPU to perform read and write operations from the RAM, reset the system and perform interrupts to the normal flow of a program (for example, PS/2 port mice interrupt the flow of the program when they are moved as the CPU has to deal with the mouse moving on the very microsecond it is moved).

RAM

RAM or Random Access Memory is a type of computer memory. It is volatile memory, meaning it is temporary.

RAM

Random Access Memory

The data stored in the memory is deleted when the program using it is closed. All data held in the memory is deleted when the computer is switched off.

Each piece of data held in the memory is given a unique address that the computer can easily retrieve. Each address can be accessed using the address bus using its unique ID.

SQA exam questions that come up normally look for you to state something about how each piece of data is given a unique address so make sure you remember to put something about that!

C programs use a special function called malloc to allocate memory to store data. This data can be directly retrieved using it's memory address in C, simply by writing an asterisk in front of it, e.g. *98. This is called a memory reference.

Buses

Computer systems join all the different parts together through different buses. For a long time, this was the front side bus, but it has since been replaced by PCI Express bus, the QuickPath Interconnect (QPI) bus, the Ultra Path Interconnect (UPI) bus, the Direct Media Interface (DMI) bus, the HyperTransport bus and and the Infinity Fabric bus.

These buses all do the same thing - they carry a bunch of instructions and interrupts between different components on the system. They do this using address lines, control lines, and data lines.

These lines make up three buses called the address bus, the data bus and the control bus.

Address Bus

The address bus holds the unique address in RAM when the processor is trying to access the RAM.

It is a unidirectional bus as it only send data from the process to the RAM.

Data Bus

The data bus carries data between the processor and the memory. It is a bidirectional bus as the processor transfers data to the RAM using it and the RAM transfers data to the processor using it.

Control Bus

The control bus is used to send control signals to different devices across the computer system.

Translator programs

Translator programs are an essential part of programming today.

Programming languages such as Python, Java, Visual Basic etc, all require translation that the programmer writes to something that the computer can understand.

A translator can turn code from a high-level language (the source code), that is, a language similar to English (such as Python or Java), into a low-level language, that is, a language a computer can understand.

The most common type of translator programs these days are ones that are transforming code from a high-level language to opcode or bytecode and then executing it, but there are still many compilers that translate the code directly into machine code (1s and 0s).

There are two types of translator programs you need to know about for National 5 Computing Science:

  • Compilers
  • Interpreters

Compilers

A compiler is a program that turns source code into object-code. A compiler is used to make code portable as, unlike an interpred program, it does not require additional software to run it.

One key difference between a compiler and an interpreter is in the way they deal with errors. A compiled program will crash when it finds unexpected code it will crash and display an error at the end.

Interpreters

An interpreter is a special piece of software that reads each line of code line-by-line and translates it to machine code.

By doing this line-by-line, it specify where the error is much more clearly than a compiler can.

Interpreted programs are slower than compiled programs and the interpreter program is required on the computer running the program to execute it.

Mr Balfour has created an SQA Reference Language compiler and runtime that you can download and actually find out how it works, too.

The Environmental Impact of Computers

Computer systems draw a lot of energy. According to statistics, as of 2024 there are around 2.2 billion computers in use in the world. If the average computer consumes around 70 watts of energy, we are looking 1.54 terawatts of energy being used by them every hour.

We need to think about steps to reduce the impact they are having on the environment by reducing their electricity draw.

Monitor settings

You can make changes to your monitor settings to reduce the amount of energy it consumes.

Some monitors support an eco mode which is designed to set the monitors settings to the best options for lower energy use. However, if it does not, these options can reduce the energy consumption of monitors:

  • Reducing the brightness manually can be one of the best ways to reduce the energy consumption of monitors. Some monitors come with sensors that determines the best brightness for the room.
  • Avoid screensavers and have the monitor switch to standby instead of this.
  • Reduce the refresh rate of the monitor (the SQA does not list this one, but it is indeed a correct answer)
  • Use energy efficient monitors (for example, an IPS display uses 2x as much energy as a TN display)

Power-down settings

Modern operating systems (from Windows XP+ and Mac OS X 10.1+) allow you to set specific settings to help reduce the amount of energy a computer uses by powering down devices when they are not in use.

The following is a list of actions that it can take to reduce power consumption:

  • Put the monitor on to a lower power state
  • Power the system down after a short period of time
  • Put the CPU into a lower power state (S0 - S6 are power states in modern ACPI compliant POSIX operating systems)
  • Slower mechanical hard drives use a lot of energy compared with modern solid state disks and therefore have settings to switch them to a lower power state
  • Network adapters can also enter a low power state when they are not being used.

Remember, a lot of these settings need to be turned on first.

Standby settings

Standby or sleep mode is a mode that was designed to keep the computer system powered but in a very low power state. It does this by keeping the CPU running in state S0 - i.e. the lowest power mode it has and keeps the RAM with all the data in it powered. It then switches everything else (the graphics card, hard drives, monitors etc) off. When the user wishes to continue again, the CPU moves up power states gradually and then sends signals to the other devices to start up.

In standby, the RAM remains powered so that resuming use with the computer can be very quick.

Another mode that is common is hibernate. This mode is similar to standby but is considerably better at saving energy as it puts the computer to sleep. The main difference between these two modes is that in hibernate mode, the computer copies the contents of the RAM to the storage device (hard disk or solid state drive) of the computer and then switches off entirely. When the user wishes to resume working on their computer, the computer copies the data from the storage device back to RAM again. This is considerably slower than standby when starting up, but with modern NVMe storage, this is becoming less of an issue.

Security Precautions

Computer crime is a big threat to everyone today. There are certain precautions we can all take to ensure our data and information is safe.

Firewalls

A firewall is a special piece of hardware or software that can either be used to determine what is allowed in and out of a computer network or computer.

Firewalls contain a set of rules that determine what packets are allowed in or out.

The rules could state which ports or which IP addresses are allowed to send/receive data.

Encryption

Encryption is used to prevent unauthorised access to data during transmission over a network. Encryption played a heavy role in World War II where the Germans relied heavily on it to send and receive instructions.

RAM

Random Access Memory

Encryption scrambles the content of the data to ensure that the only way to unscramble it is to use the decryption algorithm.

In asymmetric encryption, the data is encrypted using a public key and decrypted using a combination of the public key and a private key. This is common across the Internet.

Caesar Cipher

A simple type of encryption is the Caesar Cipher.

In this type of cipher, every letter is 'shifted' along the alphabet. If a shift of 3 is given:

a → d
b → e
...
z → c

Data Representation

Computers are often referred to as two-state machines. This is down to the way in which they work underneath. The two states, 1 or 0, are known as binary.

Computers are made up of tiny switches known as transistors that can either on or off.

Converting from binary to decimal

Converting from binary to decimal is easy, simply put the place values at the top, doubling each time from the right, then write your binary number below it:

128 64 32 16 8 4 2 1
1 0 1 1 0 1 0 1

To get the denary number from this simply add all the place values with a 1 under them together.

128 + 32 + 16 + 4 + 1 = 181

If you are given a series of 1s and no 0s, e.g. 1111 1111, you can easily get the answer to this by getting the next place value (e.g. 128 * 2 = 256) and then taking away 1 as this is the largest number that 8 bits can represent.

Denary to binary

Once again, start by writing out the place values:

128 64 32 16 8 4 2 1

In this example, we are going to use the number 73.

Now look from left to right and find the first value that is less than the number you are looking for and put a 1 underneath it:

128 64 32 16 8 4 2 1
1

Next, put a 0 under any numbers left of this one.

128 64 32 16 8 4 2 1
0 1

Now repeat this process until you are at the very right hand side or all of the place values with a 1 under them add up to the number you are looking for.

128 64 32 16 8 4 2 1
0 1 0 0 1 0 0 1

Range of numbers representable

The range of numbers (i.e. the smallest and the largest numbers) representable by binary are defined by the number of bits allocated.

To quickly calculate the largest number, simply use the following formula:

$$max = 2^n - 1$$

Where n is the number of bits given.

An unsigned integer uses a 32-bit binary string to represent a number, meaning it can represent a range of numbers from 0 to 4,294,967,295.

Floating point represetnation

For National 5, you need to know that floating point representation is a system used by computers to store large numbers. It consists of a mantissa and exponent.

Floating point is similar to standard form. In standard form we can write the number 14.3 as:

$$\rlap{\overbrace{\phantom{0.143}}^{mantissa}}0.143\times10\underbrace{^{2}}_{exponent}$$

You can see that this is the same number and that the exponent of 2 is how many times the decimal place has moved to the right.

ASCII

ASCII or American Stanard Code for Information Interchange is a standardised format for representing characters and symbols on a computer system.

ASCII maps several numbers (which are represented as binary strings) to characters and symbols:

A 65
C 67
! 49

Use this input box to tell you what the ASCII number of a key press is on your device:

The original iteration of ASCII had 7 bits to represent characters and symbols and could therefore represent just 128 characters and symbols.

This became a problem quickly as there are definitely more than 128 symbols let alone characters on a standard computer. As a result, Extended ASCII was developed. Extended ASCII partly fixed this by giving 8 bits to each characters representation. This meant 256 characters or symbols could be represented.

Bitmap graphics

A bitmap is a 2D array of pixels. A bitmap can be seen as being analogous of a table of pixels.

Bitmap graphics

The number of pixels going across (the width) multiplied by the number of pixels going up and down (the height) is called the resolution.

The bit depth is the number of bits required to store each pixel. Computers today use 24 bits per pixel, plus 8 bits for transparency. HDR (High Dynamic Range) displays and images use 40 bits per pixel including everything 32 bit has plus brightness to create a more immersive experience.

The higher the bit depth is, the more colours that can be represented by each pixel, and indeed the image.

Bit depth Representable colours
8 bit 28 = 256
16 bit 216 = 65,536
24 bit 224 = 16,777,216
32 bit 232 = 4,294,967,296
40 bit 240 = 1,099,511,627,776

Bitmap graphics are resolution dependent. This means when you resize them you'll lose quality.

The higher the resolution, the larger the file.

Vector graphics

Vector graphics work differently to bitmap graphics. Instead of storing data as pixels, they store a series of instructions that the computer must repaint each time it needs to display the graphic.

The instructions for SVG, for example, look very similar to HTML (that's because both SVG and HTML are dialects of XML):

<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0" y="0" width="148" height="148" viewBox="0, 0, 370, 370"> <g id="Background"> <rect x="0" y="0" width="370" height="370" fill="#000000" fill-opacity="0"/> </g> <defs> <linearGradient id="Gradient_1" gradientUnits="userSpaceOnUse" x1="59.842" y1="310.158" x2="310.158" y2="59.842"> <stop offset="0" stop-color="#FFA600"/> <stop offset="1" stop-color="#CC0FD8"/> </linearGradient> </defs> <g id="Layer_4"> <path d="M185,362 C87.246,362 8,282.754 8,185 C8,87.246 87.246,8 185,8 C282.754,8 362,87.246 362,185 C362,282.754 282.754,362 185,362 z" fill="url(#Gradient_1)"/> </g> <g id="Layer_5"> <path d="M185,353 C92.216,353 17,277.784 17,185 C17,92.216 92.216,17 185,17 C277.784,17 353,92.216 353,185 C353,277.784 277.784,353 185,353 z" fill="#222222"/> </g> <g id="Layer_3"> <g> <path d="M67.25,82.5 L67.25,287.6 L177.25,338 L177.25,32 L67.25,82.5 z M172.25,39.8 L172.25,131.2 L72.55,85.5 L172.25,39.8 z M72.25,90.9 L172.25,136.7 L172.25,233.3 L72.25,279.1 L72.25,90.9 z M172.25,330.2 L72.55,284.5 L172.25,238.8 L172.25,330.2 z" fill="#FFA600"/> <path d="M67.25,82.5 L67.25,287.6 L177.25,338 L177.25,32 L67.25,82.5 z M172.25,39.8 L172.25,131.2 L72.55,85.5 L172.25,39.8 z M72.25,90.9 L172.25,136.7 L172.25,233.3 L72.25,279.1 L72.25,90.9 z M172.25,330.2 L72.55,284.5 L172.25,238.8 L172.25,330.2 z" fill-opacity="0" stroke="#FFA600" stroke-width="6" stroke-miterlimit="10"/> </g> <g> <path d="M192.75,32 L192.75,337.9 L302.75,287.5 L302.75,82.5 L192.75,32 z M297.45,85.5 L197.75,131.2 L197.75,39.8 L297.45,85.5 z M297.75,279.1 L197.75,233.3 L197.75,136.7 L297.75,90.9 L297.75,279.1 z M197.75,238.8 L297.45,284.5 L197.75,330.2 L197.75,238.8 z" fill="#FFA600"/> <path d="M192.75,32 L192.75,337.9 L302.75,287.5 L302.75,82.5 L192.75,32 z M297.45,85.5 L197.75,131.2 L197.75,39.8 L297.45,85.5 z M297.75,279.1 L197.75,233.3 L197.75,136.7 L297.75,90.9 L297.75,279.1 z M197.75,238.8 L297.45,284.5 L197.75,330.2 L197.75,238.8 z" fill-opacity="0" stroke="#FFA600" stroke-width="6" stroke-miterlimit="10"/> </g> </g> <g id="Layer_6"> <path d="M63.8,254.3 L64,289.7 L167.8,337.1 L168.1,138.8 L110.9,112.3 L110.9,153.6" fill-opacity="0" stroke="#FFFFFF" stroke-width="6" stroke-miterlimit="10"/> <path d="M199,338 L311.6,284.6 L199,231.3 z" fill-opacity="0" stroke="#FFFFFF" stroke-width="6" stroke-miterlimit="10"/> <path d="M199,233.3 L311.6,187.2 L199,141.1 z" fill-opacity="0" stroke="#FFFFFF" stroke-width="6" stroke-miterlimit="10"/> </g> </svg>

Vector graphics are generally very small in size, even when the image itself is very big, but as you increase the number of objects in the graphic, the file size will increase due to the number of instructions in the graphic file increasing.

Vector graphic objects

There are four different objects you need to know about for National 5 Computing Science:

  • Line
  • Rectangle
  • Ellipse
  • Polygon
Line

A line, sometimes called a polyline is an object that simply connects two points together. Lines can be made complex by adding anchor points.

Rectangle

A rectangle object is simply a polygon with four points.

Ellipse

An ellipse is a curved object. An ellipse has a radius so that it can be made more or less curved.

In questions related to vector graphics and ellipses, do not answer with the words circle or oval.

Polygon

A polygon is any shape with at least three sides.

Vector graphic attributes

For National 5 you must be able to provide examples of different attributes that you might find on vector graphics.

  • Co-ordinates (x coordinate and y coordinate)
  • Fill colour
  • Line colour
!
-- DragonDocs version 0.9 --

20.08.2017

Started on DragonDocs
Created a YASS/PHP and HTML-based system for saving and retrieving data

21.08.2017
Added CSS styles to page
Added JavaScript code to the page

02.02.2018
Added the multipage option (used in my dissertation)
Added the XMLHttpRequest-based multipage requests

08.02.2018
Added the Accessibility features
Filters added

10.02.2018
Purple filter added

17.03.2018
Added the Note class
Added the Did You Know class

-- DragonDocs version 1.0 (Yosemite) --

02.10.2019
First trial of DragonDocs in teaching

04.10.2019
Added the Task, Starter, Review your learning sections

07.10.2019
Added the feedback feature
Added the Dark Mode toggle

19.09.2020
Performance gains through the removal of unnecessary code
Added the Learning Intentions and Success Criteria features
Added the school badge

31.09.2021
Changed the headings (h2) to be more consistent with my website
Added sections to the pages - sections must be preceded by a h2
Added the "I have read this section" buttons
Changed the main heading zone to gradient text like my website
Added the table of contents feature

02.02.2022
Added the Print feature
Updated the footer to feature a new gradient
Added the Test It! class
Added the green flag
Automated the table of contents using JavaScript

06.02.2022
Added the 'includes' feature to the document, allowing inclusion of other files easily
Removed the requirement that the IP address must be one of the schools I have taught at, opening these documents to the public

02.03.2022
Once a section has been read or completed, the user can now hide that section

10.10.2022
Added the Extension task class
Changed the scrollbar on Windows to match that of macOS

-- DragonDocs version 2.0 (Kilimanjaro) --

07.08.2023
Added the Save button and the ability to save 'results' or answers to a Word document

12.01.2024
Added the large numbers class
Removed the background of the page navigation

-- DragonDocs version 2.1 (Aurora) --

08.02.2024
Added the active class to active links in the bottom section

09.02.2024
Added the image upload feature

10.02.2024
Added a fix that prevents the upload of non-image files into an image upload
Added pasting images to the upload feature

11.02.2024
Added the ability to view the changelog from a document
Improved the feedback system by recording the DragonDocs User ID and the Document ID data
The feedback from DragonDocs can be accessed much easier

12.02.2024
Added the new step_by_step_mode feature, allowing sections to be viewed individually
Added the ability to lock and unlock DragonDocs

22.02.2024
Added new checkboxes to each list item in a .task or .step
Added functionality to said checkboxes to add a strikeout to steps completed

23.02.2024
Added the new 'step' class
Steps are now auto incremented in CSS so the name displays the step number
Activities are now also auto incremented to display the activity number

25.02.2024
Added the 'matcher' feature to DragonDocs
Fixed an issue in which a closed section would retain it's original height within the document navigation
Added starters and the lesson review to the navigation on the side
The learning intentions and success criteria in teaching documents have now been redesigned to match my slides design

26.02.2024
All buttons are now on the right hand side
The accessibility button now has WAI under it

-- DragonDocs version 2.2 (Serengeti) --

26.02.2024
Code has been rewritten from the ground up to be object-oriented, making additional features easier to add

28.08.2024
Changed the look of grouped multiple choice buttons

06.03.2024
Added the new dragondocs_name feature and the requires_name property which allows names to be prepended to saved documents

09.03.2024
Added code so when the user types in their name and hits the enter key it will save that data and close the modal window
Added the new DragonShow and DragonDocs Link - a connection between both services that allows the presenter to communicate with users of DragonDocs from a DragonShow
Added the new timer option which is sent from DragonShows

04.04.2024
The matcher feature is no longer embed from jamiebalfour.scot but actually a feature of DragonDocs
Made DragonDocs 100% object-oriented, meaning much better management and better performance

05.04.2024
Made subtle changes to the interface to tidy it up a bit

06.04.2024
The multiple choice questions are now also part of the object oriented interface

09.04.2024
As requested, h3 elements are now included in the 'floating navigation'
The active navigation element now becomes bold and the left border has been retired

Time left

: