Lecture 1 - Intro To Systems Programming Flashcards
What is systems proramming?
Activity of writing computer system software that will be used as a platform for other software. i.e. there is a layer of abstraction
Examples of system software…
Drivers , OS , compilers
What is the software that is contrasted with system software?
Application software
What are the performance constraints usually imposed on system software?
- fast execution time
- low memory consumption
- low energy usage
What do systems programming languages provide?
More fine grained control over the execution of programs
What are the two examples of system programming languages?
C and C++
What are the 4 programmig paradigms?
imperative
structured
object-oriented
functional
What is imperative programming?
Computations are sequences of statements that change program state
What is structred programming?
Structured programming organises programs with subroutines and structured control
flow constructs
What is object-oriented programming?
Object-oriented programming organises programs into objects that contain data and
encapsulate behaviou
What is functional programming?
In functional programming programs are mathematical functions and avoid explicit
change of state
What is the Python statement that gets the size of variable in memory?
sys.getsizeof(variable)
What is the C statement that gets the size of a variable in memory?
sizeof(variable)
Why should we use C for systems programming?
Has a high level of control, which allows strong reasoning about the program’s performance and execution behaviour
- we can be more confident about the program overhead
What must we do to a C program to execute it?
Compile it
What does the compiler do?
Translates source code to machine code via a number of steps.
How to compile a C program using clang?
clang source.c -o name
What happens when attempting to compile?
- Preprocessor expands macros
- Source code is parsed and turned into intermediate code
3.machine-specific assembly code is generated
4.machinecode is generated in an object file
5.The linker combines multiple object files into an executable, if required
How to generate the result of the preprocessor stage?
clang source.c -E -o name.e
How to generate the result of the intermediate representation stage?
clang source.c -emit-llvm -S -o source.llvm
How to generate the assembly code?
clang source.c -S -o source.s
How to generate the machine code?
clang source.c -c -o source.o
What does the linker do?
Linker combines one or more object files into a single executable. It does so by checking if all functions have machine code available, if not and it cannot be found it throws up an error.