CS 452/652 Winter 2022 - Lecture 4
January 12, 2022
prev next
Programming
- use unit testing where possible
- use assertions generously!
- availability of resources: track < ARM < developer < PC
- hardware emulation, such as QEMU → unclear cost/benefit
- important principle: KISS
- related: "premature optimization is the root of all evil" (Donald Knuth)
- think strategically about
- functionality: start simple, add functionality in small steps
- test (and commit) at each step
- data structures: encapsulate, start simple, exchange later
- bugs: not every bug is a show-stopper
Optimization
Processor Configuration
- ARM 920T has instruction- and data-cache → enable!
- RedBoot disables before starting program with 'go'
- Related features (not relevant for CS 452/652)
- lockdown mode: lock specific code/data into fast cache memory
- Thumb mode: use simpler/smaller instruction set to reduce memory footprint
- MMU enabled with default setting → no need to tinker with
- details: see control register CP15 in EP93XX and ARM documentation
Compiler Optimization
- code without side effects might be removed
- repetitions might be removed
- loops unrolled
- code reordered based on performance of microarchitecture
- compiler understands data dependencies in synchronous control flow
- C/C++ keyword "volatile"
- goal is complete understanding of what we are doing ⇒ enable optimization!
Runtime Optimization
- pipelining and out-of-order execution
- very important challenge in other areas!
- old processor with one core → not relevant for CS 452/652
- Java keyword "volatile" handles this (different from C/C++)
Kernel Overview
- microkernel → device drivers outside kernel
- normal scope: memory, threading, communication
- here: tasks and message passing
- do not use shared memory between tasks
- hardware protection optional
- entry/exit between kernel and user-level tasks
- software interrupt - system call
- hardware interrupt - device activity
Generic Kernel Loop
void kmain() {
initialize(); // includes starting the first user task
for (;;) {
currtask = schedule();
request = activate(currtask);
handle(request);
}
}