16 - system software + virtual machines Flashcards
interpreter
- executes the program line by line - outputs error messages as it encounters them
- used evert time a program is executed
- constructs a symbol table - allocates space in memory for constants, variables and data
compiler
- the source code is input and either object code or error messages are output at the end
- source code can be run without translation again/ distrubuted
- constructs a symbol table
stages of compilation
- lexical analysis
- syntax analysis
- code generation
- optimisation
translators
compiler
interpreter
assembler
lexical analysis
first stage in compilation
- all unnecessary characters eg white space/ comments are removed
- program is converted into tokens - tokenisation
- variables and constants are also added to a symbol table
keyword table
- all the reserved words and symbols that can be used in the programming language are stored - with their corresponding token eg 2 hex numbers
tokenisation
in lexical analysis to convert the program into tokens
- a key word table is used that contains all tokens for words/ symbols in a programing lang
syntax analysis
- the output from lexical analysis is checked for syntax errors
- the tokenised list is checked for errors using syntax rules for the programming lang (parsing)
- if errors found each statement and the errors are output but in the next stage code generation wont be attempted
- if error free its passes to the next stage to generate object code
parsing
checking the tokenised list for errors using grammatical rules for the programming lang
lexeme
each meaningful character or collection of characters
may be used as an identifier or may be a key word
- in lexical analysis the whitespace and comments are removed and each lexeme is identified before categorising each lexeme to tokenise it
code generation
produces object code to perform the task defined by the source code
- must be syntactically correct to produce obj code
- in machine code (binary)
- either in executable machine code or an intermediate form (converted to MC when program is loaded)
benefits of intermediate code (code generation)
supports
- use of relocatable code so program can be stored anywhere in main memory
- addition of library routines to minimise storage size
- linking of programs to run together
optimisation
- improves efficiency
- performs task with minimum resources used
eg time, storage space, memory and CPU use - can take place after syntax analysis or as part of code regeneration
bootstrap
- loads part of the OS into RAM from the hard disk
- initiates start up procedures
when comp is switched on
BIOS starts off bootstrap
flash memory
used as main memory on phones - explains why their start up is so fast
2 parts
- OS - read only - can be updated by manufacturers but user cant access
- apps (+ data) - user cant access
resource management
split into 3 areas: CPU, memory, I/O system
- involves scheduling to allow for better utilisation of time and resources
- for I/O operations deals with: I/O operations that have been initiated, I/O operations that occur wile software is run and resources are requested
direct memory access controller (DMA)
- allows hardware to access main memory independently of CPU
- frees up the CPU to allow it to do other tasks while slower I/O operations take place
- initiates data transfers - CPU does other tasks at same time
- once data transfer is done an interrupt is sent to the CPU from the DMA
kernel
- central component of OS
- responsible for communication between hardware, software and memory
- responsible for process
management, device management, memory management, interrupt handling and input/output file
communications
how the OS hides the complexity of hardware from users
- using GUI interfaces
- using device drivers (simplifies the complexity of hardware interfaces)
- simplifying saving/ retrieving data from memory and storage
- carrying out background utilities eg virus scanning
syntax diagrams
- anything with alternatives eg variable, letter, digit, operators goes in a square
- items with no alternatives eg a specfic symbol or letter goes in a circle
- have arrows showing the order of things
- if in parallel you can have either of those options - iteration eg multiple letters is shown with an arrow looping
Backus Naur form (BNF)
- set of symbols used to describe the grammar rules in a programming language
BNF notation symbols
<> encloses an item
::= separates an item from its definition ‘is defined as’
; end of a rule
eg <variable> ::= <letter> | <digit>;</digit></letter></variable>
<letter> ::= A | B | C;
<digit> ::= 1 | 2 | 3;
a vairbale consisting of any number of letters or digits could be defined as
<variable> ::= <Letter>|<variable><Letter>|<variable><Digit>
| between items indicates a choice
</Digit></variable></Letter></variable></Letter></variable></digit></letter>
Reverse Polish notation (RPN)
- used to represent an arithmetic or logical expression - without brackets or special punctuation
- uses postfix notation - operator is after the variables it acts on eg A+ B > A B +
- compilers use bc any expression is processed left to right without backtracking - converted using a binary tree
how to evaluate to RPN
eg a+ b *c
whichever has the higher precidence in this case * is done first
so put bc *
then after put a on the far left and. + on the righ to give
abc * +
the comp will automatically do the 2 things next to the operator first then result, next one and the next operator
evaluating RPN using a stack
- values are added to the stack in turn from left to right
- when you get to an operator it is used to operate on the top two values which are popped off
- the result is then pushed back on
- this is repeated until there is one value on the stack - the answer to the expression
converting back from RPN
whenever you have two variables and a sign after them pit the sign in the middle and rewrite the expression
eg ba * cda ++-
(ba)c(d+a)+-
(ba)(c+d+a)-
(b*a) - (c+d+a)
prcoess managemtn
- multitasking
- low level scheduling
- process scheduler
multitasking
- comps can carry out more than one task
- scheduling is used to decide which is carried out at each time
- monitors state of each process
- gives appearance that prcoess are carried out a same time
- kernel overlaps the execution of each process using scheduling
- 2 types - preemtive, non preemtive
preemptive
processes pre-empted after each quantum
- resources allocated for a limited time
- can be interrupted
- high priority processes arriving frequently means there is a risk low priorit processes are starved
- more flexible