SLR 5 Flashcards
Define library
Ready compiled and tested programs that can be run when needed
Library features
Typically grouped together into software libraries
Most programming languages have extensive libraries of pre built functions
Library pros
Quick and easy to use and hook into your own code
Pre tested, so you can be relatively sure they are already free from errors
Pre compiled so they are typically optimised to run quickly
Library cons
Adding functionality or making specific tweaks can be difficult- or impossible
Sometimes you are “black boxed” from the actual implementation
Have to trust that the developers will continue to maintain the library
Linker responsibility
Linker is responsible for putting the appropriate machine addresses in all the external call and return instructions so all modules and external library routines are linked together correctly
Static linking
All the required code from the libraries is included directly in finished machine code- this can result in large executable program files
Dynamic linking
Compiled versions of the required libraries are stored on the host computer
Operating systems links required code from library as the program is running
While this cuts down on the size of compiled machine code, if dynamic libraries change, the program may stop because it tries to call a subroutine in the wrong way
Define loader
The part of the operating system that loads the executable program file into memory, ready to be run
Loader for dynamic linking
When using dynamic linking, it will also be responsible for loading the required libraries into memory
What are the stages of compilation
Stage 1: lexical analysis
Stage 2: syntax analysis
Stage 3: code generation
Stage 4: optimisation
What happens during lexical analysis
Lexer starts by converting lexemes in the source code into a series of tokens
As the leder reads the source code, it scans the code letter by letter
When it encounters a white space, operator symbol or special symbol it decides a word (lexeme) is complete
It then checks if the lexeme is valid using a predefined set of rules that allow every lexeme to be identified as a valid token
What happens during syntax analysis
It receives its inputs in the form of tokens from lexical analysers
It analyses the syntactical structure of the input, checking if in correct syntax of programming language
Does this by analysing the token stream against production rules to detect any errors in the code:
- checking for errors and reporting them
- building an abstract syntax tree
Lexer can’t tell if tokens valid by syntax analyser can
If the check fails, the syntax analyser can report the failure to user letting them know exact line and location of error
The abstract syntax tree is created from the input token streams
What happens during code generation and optimisation
Machine code is generated
Code optimisation (can increase compilation time for a program) attempts to reduce the execution time of the program by:
- spotting redundant instructions and producing object code that achieves the same effect as the source code
- removing subroutines that are never called
- removing variables and constants that are never referenced
Lexical analysis summary
Comments and white space removed, remaining code turned into a series of tokens, symbol table created
Syntax analysis summary
Abstract syntax tree is built from tokens produced in previous stages, errors generated if any tokens break the rules of the language
Code generation summary
Abstract code tree converted to object code, object code is the machine code produced before final step is run
Optimisation summary
Tweaks code so it will run quickly and use as little memory as possible
What is an assembler
Translates assembly language into machine code
Takes basic commands and operations from assembly code and converts them into binary code that can be recognised by a specific type of processor
One to one translation process from assembly into machine code
Pros of assembler
Programs written in machine language can be replaced with mnemonics, which are easier to remember
Memory efficient
Speed of execution is faster
Hardware oriented
Requires fewer instructions to accomplish the same result
Cons of assembler
Lack of portability
Difficult to remember the syntax
Long programs written in such languages cannot be executed on small computers
It takes lots of time to code or write the program as it is more complex in nature
What is a compiler
Translates source code from high level languages into object code then machine code then processed by the CPU
Whole program is translated into machine code before it is translated
What is an interpreter
Translates source code from high level into machine code ready to be processed by CPU
Translated line by line as program is running
Pros of compiler
No need for translation at run time
Code is usually optimised
Speed of execution is faster
Original source code is kept secret
Cons of compiler
Designed for specific type of processor
Code needs to be recompiled when code is changed
Program will not run with syntax error
Pros of interpreter
Easy to write source code stops when syntax error
No need to recompile when code changed
Easy to try out commands when program has paused after finding an error
Cons of interpreter
Translation is required at run time
Speed of execution is slower
Source code is required
Code is not optimised
Define hardware
All physical parts of a computer system and its related devices both internal or external
Define software
General term covering all computer programs. Most software fakes into broad categories like application, system and utility software
Types of utility software
File repair
Backup
Compression
Device drivers
Defragmentation
Anti-malware
File management
File repair (aims etc)
Files can become corrupt or damaged for a number of reasons
File repair software attempts to correct these issues and restore the file to its original working state
A file repair facility is often built into certain applications, as well as being a separate, dedicated software tool found in most operating systems
Backup
Backups can be set up to be manual, automatic or scheduled
Full backup or incremental backup
Backup to different media or an off site cloud system
Backup software often comes with operating system but can be purchased separately
Data compression
Compression reduces the size of a file so it takes up less space and downloads faster over the internet
Compressed files must be extracted before they can be read
Depending on the algorithm data is either lost, reducing the quality of the file of represented in a different way using binary, retaining the original data in new compressed format
Defragmentation
Reorganised the files on a hard disk, putting fragments of files and free space back together
This process reduces the movement of the read/ write head across the surface of the disk, which speeds up file access
Anti malware
Helps keep your computer and files safe from many types of malware like: viruses, trojans, worms, spyware
Most operating systems come with malware protection already built in
Also companies who specialise in dedicated anti-malware programs
Open source features
Users can modify and distribute the software
Can be installed on any number of computers
Support provided by the community
May not be fully tested
Define open source
Can be used by anyone without a license and is distributed with the source code
Closed source features
Protected by the Copyright Design and Patents Act
Users cannot modify the software
Usually paid for and licensed per user or per computer
Supported by developers who do not release source code
Tested by developers prior to release, although it may run beta program
Define closed source
Requires the user to hold an appropriate license to use it. Users cannot access the source code as the company owns the copyright license.
Open source user pros
Software is free
Wide community modification
Open source user cons
Can be poorly supported
Some features might not be well tested
Open source creator pros
Gets their software out there to a wider community
Open source user cons
Little to no financial gain
Closed source user pros
Well supported, tested and professional built project
Closed source user cons
Cost or ongoing subscription fee
Closed source creator pros
They receive an income for their product
Closed source creator cons
Constant demand from community for more features and improvements
Piracy issues