Fetch stage of the FDE cycle
Decode stage
Execute
Opcode executed on operand
Execute
Opcode executed on operand
pipelining
three separate instructions processed simultaneously, instruction one executed while instruction two is being decoded and instruction three is being fetched - reduces CPU idle time - can be broken down further to reduce idle time more
if predicts wrong branch the pipe must be flushed and benefits are lost as correct instruction is loaded
von neumann
original computer architecture has single CU, ALU, registers and memory units - memory shared by instructions and data as are the buses - uses stored program concept
harvard architecture
uses two memory storage units one for data and another for instructions, two copies of buses - more efficient, data and instructions fetched at the same time common in embedded system
contemporary architecture
combines Harvard and von neumann, main memory remains in von neumann format while cache is dived like with a Harvard system
CISC
systems using a larger instruction set (80-100), each instruction can be more complex so may take several clock cycles to complete one instruction.
+ easier to translate from high level to machine code
+ less ram required for less lines of code
+ specialized instructions used rarely
- larger due to increased storage for more instructions and more cooling required for increased power consumption
- decreased clock speed
- may require several clock cycles per instruction
-
RISC
a smaller instruction set (30-40) more simplistic - 1 instruction = 1 clock cycle
+ high level languages compiled to more efficient code
+ 1 clock cycle per instruction
+ smaller - reduced power and storage
+ decoding instructions more simple
+ cheaper - less components
- performance depends on skill of programmer
- longer compile time and longer machine code
- more effort for programmers
scheduling
function of operating system dividing CPU time between jobs - can be done pre-emptivly (stopping jobs during execution to giver others processor time) or non pre-emptivly (once a job is started it is not stopped until completed)
translators
a program which converts high level code to machine code
compiler
translates all code in one go, carries out all checks and reports errors before execution - whole program must be recompiled if change is made - compiled code is specific to the processor and operating system it is compiled on - can be ran without a translator present - creates executable separate to source code
interpreter
translates code line by line during execution - stop and produce error when found - slower as code is translated each time it is ran - useful for testing and debugging - interpreter required to run - more portable
assembler
translates assembly to machine code - platform specific - instructions dependent on specific processor - 1 assembly line = 1 machine line
stages of compilation
lexical analysis - white space and comments removed - key words variables and constants replaced with tokens, tokens stored in symbol table
syntax analysis - tokens are analyzed against rules of program - tokens that break the rules are flagged as syntax errors - an abstract syntax tree is produced representing source code - semantic analysis also spots logic errors
code generation - abstract syntax tree used to produce machine code
optimization - code optimized, adds time to translation but decreases execution time - excessive optimization can lead to behavioral changes
assembly language
very low level code (one up form machine code) - it is its own family of code - translated using an assembler - uses mnemonics rather than binary - non portable - allows for direct interaction with registers - used in embedded systems
little man computer mnemonics
ADD - Add the value at the given memory address to the value in the Accumulator
SUB - Subtract the value at the given memory address from the value in the Accumulator
STA - Store the value in the Accumulator at the given memory address
LDA - Load the value at the given memory address into the Accumulator
INP - Allows the user to input a value which will be held in the Accumulator
OUT - Prints the value currently held in the Accumulator
HLT - Stops the program at that line, preventing the rest of the code from executing.
DAT - Creates a flag with a label at which data is stored.
BRZ - Branch if zero - Branches to a given address if the value in the Accumulator is zero. This is a conditional branch.
BRP - Branch if positive - Branches to a given address if the value in the Accumulator is positive. This is a conditional branch.
BRA - Branch always - Branches to a given address no matter the value in the Accumulator. This is an unconditional branch.
Structured Query Language
declarative language used to manipulate databases - enables creating, removing and updating
SELECT collects data from a given field
FROM specifies a table to operate on
WHERE specifies operation criteria
ORDER BY orders field in Ascending or Descending order
JOIN combines multiple records from multiple tables on a common filed
CREATE makes a new database, must specify fields, PK data type and if it must be filled
ALTER add delete or modify columns
INSERT INTO inserts a new record
UPDATE updates a record
DELETE removes a record
referential integrity
ensuring consistency in a DB - ensures data is not removed if required elsewhere etc
transaction
a transaction is a single operation executed on data, a collection of operations can also be described as a transaction
ACID
Atomicity - A transaction should be processed in its entirety else not at all
Consistency - referential integrity rules must be maintained between liked tables
Isolation - simultaneous execution of transactions should lead to the same result as if they were executed consecutively
Durability - once executed a transaction will remain so regardless of circumstance ie powercuts
record locking
to prevent simultaneous access a record is locked to prevent inconsistency whilst a transaction is being processed
deadlock - where a record is locked by one process as it try’s to access another which is locked by another process trying to access the original record
redundancy
having multiple copies of valuable data in different physical locations - if one is damaged the others can be accessed to recover it