Академический Документы
Профессиональный Документы
Культура Документы
Computational Thinking
Decomposition
Decomposition is the breaking down of a problem into smaller parts that are
easier to solve. Smaller parts can sometimes be run recursively.
Data Mining
Performance Modelling
May be necessary when it is not feasible to test all possibilities for reasons such
as:
Safety
Time
Expense
Mathematical considerations:
Statistics – existing data should be taken into account in the model
Randomisation – modelling uncertainty
Pipelining
Increases efficiency, particularly in RISC processors where
MARSARL
Paradigm
Assembly language
Assembly language is a low level language with a 1:1 ratio to machine code.
Machine code is what the processor’s architecture reads. Machine code consists
of a binary opcode and operand, while assembly language uses the same format
in a more readable way (e.g. LDA 3).
Instruction set
Each processor has its own unique instruction set. Programs require machine
code to be for the correct instruction set. RISC and CISC are two aspects of
processor architecture (covered later).
INP, OUT, STA, LDA, ADD, SUB, BRZ, BRP, BRA, HLT, DAT
Memory addressing
There are four main types of addressing data within the memory:
Object-orientated programming
Constructor
Code that is run to define or create methods in a class (or more generally). For
example, in Python exists the __init__() constructor.
Inheritance
Polymorphism
Encapsulation
This is the isolation of attributes and variables within a class so that they cannot
be altered by other classes.
CHAPTER 7 – SOFTWARE
Applications
Utilities
Utilities are small software packages which generally have a specific purpose or
task.
Operating Systems
Software that manages the system and provides for the user.
Kernel
The kernel is the ‘core’ of the operating system. It manages system resources
including memory management and scheduling. Lies below the user interface.
Applications use the kernel to send and receive data to and from hardware
devices.
Memory Management
Memory management allows programs to be stored in the computer’s memory
safely and efficiently. From a safety point of view, it is important that data of one
programs is protected from another, preventing possible malicious access or
amendments of data. The OS’s memory management deals with this.
Memory can be stored using segmentation, logically splitting the data into
modules or routines, or paging, where the data is split up in pages of the same
physical size.
Virtual Memory
Virtual memory uses the hard drive as an ‘extension’ of the RAM. If the system
is running low of RAM, a dedicated partition of the hard drive will be used. It is
stored temporarily to allow running processes to use the RAM and swapped with
other data when in use. Process is therefore slower that just using physical
memory. Disk thrashing occurs when the RAM is full, and pages are moved back
and forth between physical and virtual memory rapidly, significantly slowing the
system down.
Scheduling
Scheduling manages the amount of time different processes have in the CPU.
Scheduling allows multiple processes to run apparently simultaneously. Types of
scheduling algorithm:
First come first served – Processes are processed until complete in the
order they arrive in (like a shop queue). The downside to this is that if the
process takes a long time, no other processes can be worked on until it is
complete.
Shortest job first – This scheduling algorithm picks the job that will take
the shortest amount of time and runs it until it finishes. The algorithm
needs to know how long each process will take beforehand.
Shortest time remaining – The scheduler estimates the processing time for
each process and executes the quickest one. If a quicker process is added,
this will be executed instead until complete.
Interrupts occur when a device sends a signal to the CPU requiring its attention.
Polling is when the CPU checks each peripheral to see if it needs attention at
certain intervals. Interrupts are more efficient because the CPU is only involved
when attention is needed.
The contents of the program counter and other registers are copied to the
stack
The relevant ISR is loaded by changing the program counter to the
corresponding memory location of the ISR.
Once the ISR has completed, the previous values of the program counter
and other registers are restored to the CPU and continue as before.
If an even higher priority interrupt is raised whilst an ISR is being run, the
same process applies – the current ISR is added to the stack in the same way
and loaded from the stack once the higher priority ISR is complete.
Device Drivers
Virtual Machines
BIOS
Basic input/output systems are loaded when a computer is booted up. The bios is
stored on the EPROM (non-volatile) memory and point towards the operating
system for start-up. The power-on self-test (POST) tests that the computer is
functional (i.e. RAM installed and accessible and the processor is working). The
operating system’s kernel is then loaded during the boot process.
Open and closed source software
Closed source software is software where the source code is not publically
available. These programs will generally be protected by more copyright laws,
and users are not able to edit the source code, only the executable machine code
is visible.
Open source software has its source code publically available. Users can modify
code to suit their needs and the development process is more community
orientated.
Machine Code
Machine code is a low-level language which uses binary to represent opcodes and
operands. Different processors have different instruction sets.
Assembler
Assembly code is a way of writing machine code using three or four-letter codes
to represent the binary. Little man computing uses assembly language for
example, with commands such as LDA, STA and ADD. Assembly code has a one-
to-one relationship with machine code.
Compilers take the entire high-level language program and converts it into
object code. Debugging is harder as there is nothing to say where an error occurs,
the whole program will just fail to compile.
Object Code
Object code is an intermediary step sometimes taken before pure machine code is
produced. Object code makes up portions (libraries and subroutines) of code that
contains placeholders linking where this code needs to go. The linker links these
and produces the final executable program.
A sequence of stages occurs during the compiling process, moving closer to the
machine code:
Lexical analysis
This stage first removes all comments and whitespace
Tokens are identified which include operators, variables, and constants.
A symbol table keeps track of the variables and subroutines in the
program.
Syntax analysis
The syntax of the code is checked that it adheres to the program
languages rules.
If any errors occur, a list of syntax errors will be communicated to the
programmer.
An abstract syntax tree (AST) is created to represent the program.
Code generation
The AST is converted into object code
Optimisation
Lines of code which have no effect on the program are removed
Some instructions may be replaced by a more efficient means.
Libraries
Libraries are pre-written and contain functions and procedures that can be used
by the programmer without having to re-write them.
The linkers are included to make sure where library code is used. Static linkers
will insert the code into the correct position of the machine code, making the files
larger in size as the code is effectively copied. With dynamic linkers, the
compiled library is stored on the PC and run when needed by the OS. A loader is
responsible for loading a program into memory.
Feasibility study
Requirements specification
Understandable and measurable requirements from the end user’s needs. At the
end of a project, the initial requirements specification will be measured against
the final product to see if the developer has fulfilled the consumer’s
requirements.
Testing
Methodologies
Disadvantages – carries a risk; nothing tangible is created for the user to see
until the testing stage. If the task has been misunderstood at any stage, the
testing stage could show some significant misunderstandings and therefore a
waste of money and time.
Disadvantages – RAD focuses on the final product rather than how it works, so
code may be inefficient. The client must be able to make a commitment to review
prototypes or RAD is ineffective.
Spiral Model
Spiral model is designed to take into account risks within the project.
1. Determine objectives
2. Identify and resolve risks
3. Develop and test
4. Plan the next iteration
Agile Programming
CHAPTER 10
The Central Processing Unit
The CPU processes instructions passed on from the memory using transistors
which control binary circuits using logic gates.
Clock speed – this is measured in hertz and represents the number of cycles per
second.
Registers
Program Counter (PC) – This register keeps track of the memory location of the
line of machine code being executed. It is incremented to point to the next
instruction. The PC can also be changed when branching to subsections of code.
Memory Data Register (MDR) – The MDR stores the data that has been fetched
from or stored in memory
Memory Address Register (MAR) – The MAR stores the address of the data or
instructions that are to be fetched from or sent to memory.
Current Instruction Register (CIR) – The CIR stores the most recently fetched
instruction, which is waiting to be decoded and executed.
General Purpose Registers – Other registers are used to store intermediate data
rather than sending data all the way to the RAM.
Buses – Busses in the CPU are used as communication channels – to transfer
data from two locations. The USB is a type of bus.
Data bus – this sends data between the processor and memory
Address bus – this carries the memory addresses.
Control bus – this sends data to and from the control unit.
Arithmetic logic unit (ALU) – The ALU carries out calculations and logical
operations. The results are stored in the ALU.
Control Unit (CU) – the CU coordinates the processor by controlling how data
moves around the CPU and communicating through the control bus. Instructions
are decoded in the control unit.
Fetch
Decode
Execute
Clock speed – increasing clock speed increases the number of cycles per
second, thus increasing processing performance.
Cache memory – The CPU has different levels of cache memory inside (L1,
L2, L3 typically), where each vary in size, speed, and location. L1 is the
smallest, fastest, most expensive and closest to the core. L3 cache is often
shared between cores.
Multiple cores – Multiple cores allows multitasking where different cores
run different applications, however multiple cores can still work on one
task.
Pipelining – pipeloinging is used in modern processors where while one
instruction is being executed, the next instruction is being decoded, and
the next one after that being fetched. ‘Flushing the pipes’ occurs when
there is a branch in the program and the next instruction can’t be
predicted.
The GPU is designed to perform the calculations associated with graphics and
rendering. 3D graphics in games require real time rendering. GPUs have
dedicated instruction sets for graphics processing.
GPUs apply Single instruction multiple data (SIMD) to do the same calculation
for multiple points on the screen.
Graphics cards contain GPUs with their own memory, but GPUs can be
embedded one the main processor sharing the systems memory.
GPUs are not limited to graphics rendering; similar calculations for graphics
processing are useful for:
Modelling physical systems
Audio processing
Breaking passwords with brute force (number crunching)
Machine learning
Input/Output devices
Storage Devices
Memory
RAM
ROM
Computer Architectures
In the Von Neumann architecture, instructions and data are stored in the same
memory location. Therefore, data and instructions are send along the same data
bus, meaning instructions can’t be fetched at the same time as data is being
send, which causes a ‘Von Neumann bottleneck’ (i.e. pipelining not possible)
Harvard Architecture
Parallel Processing
Parallel processing is when the computer carries out multiple computations
simultaneously to solve a given problem.
SIMD and MIMD make use of multiple cores, and MIMD takes place on a larger
scale on supercomputers. Supercomputers are expensive to buy and run and
therefore distributed computing is a more viable alternative to parallel
processing. Distributed computing uses the internet to split problems between
machines.
Using 100 cores to solve a problem does not necessarily mean the process will be
completed 100x faster, as some problems don’t lend themselves to parallelisation.
RISC vs CISC
Reduced instruction sets (RISC) have more streamlined instruction sets. RISC
tends to have fewer addressing modes and more general-purpose registers. All
instructions in a RISC system should execute in the same time, ideally one clock
cycle.
RISC processors involve fewer transistors so they produce less heat, consume
less power, and cost less. However, compilers have a harder job compiling to
RISs.
Denary to Binary
Each binary digit represents a power of 2. From left to right: 20, 21, 22 etc.
Binary to Denary
This uses a sign bit to represent the sign (+/–) of the number. This is the left
most bit, called the most significant bit (MSB). If the sign bit is 1, the number is
negative.
An 8-bit sign and magnitude number can represent –127 < n < 127.
01000011 = 67
11000011 = –67
Two’s Complement
In two’s complement, the most significant bit (still the leftmost bit) represents
the negative version of that power of two if the bit is 1. In an 8-bit number, if the
MSB is 1, that means that –128 should be added to the number.
01000011 = 67
11000011 = –61
Hexadecimal
Hexadecimal is base-16, meaning each bit represents a value between 0-15. 0-9
use the corresponding number, and 10-15 use the letters A-F.
Binary to Hexadecimal
1011 0010 can be split into two nibbles. Each binary nibble represents a bit in
hexadecimal.
1011 = 11 = B
0010 = 2
Therefore 10110010 = B2
1 bit = 21 colours, 2
2 bit = 22 colours, 4
8 bit = 28 colours, 256
16 bit = 216 colours, 65,536
Sample rate determines the quality of a digital sound. The more samples, the
closer to the analogue audio.
Metadata
This is information stored about the image/file which contains misc information
as well as properties of the image for loading it e.g. width, height, bit depth,
resolution.
Representing Instructions
Binary Subtraction
Convert number to be subtracted into negative two’s complement form and add
as normal
Records are used to store data with attributes, typically in databases. The
attributes in records are not ordered but may sometimes be indexed.
Lists are ordered sets of data organised by indexes. Data is accessed through an
index, representing the position of the data within the list. Lists require less
setup than records as records need the attributes to be defined beforehand,
however identifying data by attribute is more user friendly than by index.
Stacks
A stack is a method for handling linear data structures (i.e. a list). Data is added
to and removed from the top of the stack. Adding data to a stack is ‘pushing’ and
removing is ‘popping’. Commands PUSH and POP used in assembly language.
Pushing to a stack:
If full, return error
Else, add 1 to the stack pointer
Set stack(new pointer) to the data
Queues
A queue uses first in first out (FIFO).
Popping removes the data at the start pointer, and the new start pointer
becomes the next value.
Pushing adds the data after the end pointer, and the new end pointer becomes
the location of the data just added.
Circular queues are created when the data ‘wraps around’ the queue so the end
pointer is less than the start pointer.
Linked lists
Linked lists store data using pointers. Each piece of data is attached to a pointer,
which points to the next piece of data in the list. Linked lists are are also a
linear, one way data structure. There may be multiple sets of pointers each
representing an attribute/property of the data.
Trees
Top of a tree is called the root node, and nodes are structured as parents and
children of related nodes.
Binary Trees
Binary trees have only two children and contain:
Data
Left pointer
Right pointer
Pre-order traversal:
Start at root node
Traverse left sub-tree
Traverse right sub-tree
Post-order traversal:
Traverse left sub-tree
Traverse right sub-tree
Return to root node
In-order traversal:
Traverse left sub-tree
Visit root node
Traverse right sub-tree
Post-order traversal of a tree converts between infix notation and reverse Polish.
Graphs
Traversal of graphs
Depth-first – Visit all the nodes attached to a node connected to a starting node
before visiting another node attatched to the starting node. Uses a stack
Breadth-first – Visit all the nodes attached directly to a starting node first. Uses
a queue.
Hash tables
NEED TO GO OVER
Truth tables represent all corresponding outputs for each combination of inputs
in the form of a table.
AND Gate
Output is TRUE if both inputs are TRUE
OR Gate
Output is TRUE if at least 1 input is TRUE
NOT Gate
Output is TRUE if input is FALSE
XOR Gate
Output is TRUE if exactly one input is TRUE
De Morgan’s Rules
(AB) = AB NOT(A OR B) = NOT A AND NOT B
(AB) = AB NOT(A AND B) = NOT A OR NOT B
Adder Circuits
NEED TO GO OVER
These are used to represent a truth table optimised to enable pattern recognition
for identifying minimal logical expressions (i.e. simplifying them)
Truth table outputs depend on previous values as outputs from one gate acts as
an input to another dependant gate.
Serial and sequential files
Serial – Records are organised one after the other. Structure of each record must
be the same. To search for a record, records must be examined one by one until a
match is found.
Sequential – Stored in the same way but records are orderd (e.g. alphabetically)
CRUD
Create
Update
Read
Delete
SQL
INSERT, SELECT, FROM, WHERE, JOIN, INNER JOIN, DELETE, INTO
HTML
<body><heading><br><div><link><li><script><html>
Levels of Database Views
ACID RULES
Layers of a Network
Application Layer
Network Layer
Physical Layer
OSI
TCP/IP Stack