COMP2323 - Computer Systems II

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/284

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 1:38 AM on 5/25/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

285 Terms

1
New cards

Why are embedded systems expected to be incredibly reliable? (2)

  • Often used in environments that are hard to access

  • Therefore have to be able to handle any issues by themselves

2
New cards

What are some examples of where we commonly see embedded systems? (4)

  • Robotics
  • Mobility
  • Sensor Networks
  • IoT
3
New cards

What is an important thing we need to consider when designing OS for embedded systems? (1)

  • Power consumption - embedded systems often run on limited power
4
New cards

What is baremetal programming in essence? (2)

  • It is about coding without an operating system to interface between our code and the bare metal
  • About interacting directly with the hardware
5
New cards

What is baremetal programming used for? (1)

  • To create operating systems - allows for file systems/drives etc.
6
New cards

How do we ensure security of a system at the baremetal stage? (2)

  • Security is often highly intertwined with reliability
  • The more reliable a system is, the more secure it will be - less vulnerabilities to expose
7
New cards

What is an operating system used for? (5)

  • To provide a uniform interface for users (and more crucially programs)
  • Resource management
  • Interaction management
  • To abstract away the complexity of hardware limitations
  • (ie. it should provide a standard interface that allows programs to run, no matter the hardware beneath it. It is the responsibility of the OS to handle hardware changes - not the program)
8
New cards

What is resource management and what are the different types? (4)

  • Resource management is all about how a system (OS) manages its hardware to maximise efficiency
  • Device Access: IO, Serial Ports
  • CPU timing and scheduling
  • Memory: Assigning tasks to memory and moving things around
9
New cards

What is important to consider in realtime systems and scheduling them? (2)

  • Important to remember to include interrupts (often realtime systems need things to be executed at certain times no matter what)
  • Scheduling is important as we need to be able to provide certain guarantees
10
New cards

In resource management, are the resources real or not and why? (3)

  • Most of the time, the resources are not real
  • Resources are made virtual for efficiency and ensuring the OS is fast/doesn't consume too much energy
  • Often done by making the virtual resource larger than the actual resource
11
New cards

What are the two main types of interaction management? (2)

  • Desired Interactions: Includes things that the user should be able to do and the OS should provide/support (eg. sharing files over a network)
  • Undesired Interactions: Includes things that users should not be able to do and the OS should be able to protect/stop from happening (eg. file read/write access)
12
New cards

How is interaction management normally handled on embedded systems? (3)

  • Normally much less of a thing
  • They are small and assumed to be collaborative
  • We normally make the assumption that an embedded system will not run a malicious program or have malicious policies
13
New cards

When was C created and what was it originally used in? (3)

  • Created in 70s and used for PDP11 (24KB of RAM)
  • Early UNIX needed 12KB RAM
  • C was used for creation of early UNIX
14
New cards

What was the motivation behind C? (3)

  • To create a simple, efficient language 
  • Could be used to write code for OS
  • Could be compiled to different architectures - previously OS would have to be remade from scratch when new hardware came out
15
New cards

What properties did C have to have? (3)

  • Minimalistic: The compiler for C had to be tiny, which meant it had almost no checks. It assumes the programmer is smarter. Because it is small, it is easy to learn and implement, and among the first languages to get implemented on new architecture.
  • Pragmatic: More of a focus on solving real problems, rather than being pure (eg. some functions had variable number of arguments - printf)
  • Portable: Since it (compiler) is so close to hardware, programs can easily be ported between architecturers by just using a different compiler
16
New cards

What are some of the limitations of the core C language? (5)

  • Does not include IO
  • No dynamic memory managmeent - program does not know how much memory is needed when it starts
  • Lots of subtle pitfalls
  • C has no safetly nets at runtime
  • Very terse syntax (not many keywords) - means people can write malicious code that looks fine
17
New cards

What is dynamic memory management and why is it avoided in embedded systems? (3)

  • When you can request and use more memory as the program is running
  • As opposed to knowing how much you need explicitly at the start which is safer
  • Often avoided in embedded systems as we may run out of memory which would result in a crash that provides no return value
18
New cards

What is Rust? (4)

  • New programming language that will soon take over C
  • Provides same idea as C (simple language that allows abstraction over different architectures)
  • Much more reliable/safe than C - this means better security
  • Also includes concurrency support
19
New cards

When is C typically used? (8)

  • When there is no better alternative
  • Low-level hardware access is required
  • Runtime resources are critical
  • Realtime behaviour is required
  • Low capability systems
  • Software for new hardware
  • Small bits of code that could benefit optimisation
  • Embedded systems
20
New cards

Why is C used for systems where realtime behaviour is needed? (1)

  • Because no dynamic memory management, much easier to predict when things happen
21
New cards

Can C run on a system without RAM? (1)

  • Yes - does this by being so efficient, it can fit a few function stacks in the CPU registers alone
22
New cards

What is the difference between unspecified, undefined and unexpected behaviours? (3)

  • Unspecified behaviour: Doing something that is left up to implementation in the compiler (eg. the size of an int) so runtime results may vary
  • Undefined behaviour: Doing something that is not defined in the language/compiler so runtime result is unclear
  • Unexpected behaviour: When the program is unsure what to do - usually a result of programmer error
23
New cards

Why does C have some unspecified behaviours? (2)

  • Used so that the compiler could choose whether to compile with an emphasis on memory/limitations or speed
  • Can be checked in limits.h file
24
New cards

Why can we not assume that a new variable in C will have a value of 0? (3)

  • In order to intialise a variable and set its value to 0, that requires two instructions.
  • C skips the overhead as most of the time, the programmer does not leave the value as 0 for long anyway
  • This is part of C small optimisations
25
New cards

What are some special properties about 0 in C? (3)

  • Any other value that is not 0 is true
  • A zero byte '\0' marks the end of the string - means string variables can be as large as we want it to be
  • A pointer to the address 0 is NULL
26
New cards

Why is it good to try and write for loops in reverse? (3)

  • Checking if the result of the last execution is 0 causes a flag in C
  • Means checking for 0 is very quick 
  • If doing a for loop between 0 and 10,000, we can check if our value is at 0 instead of if it is at 10,000 which is much less efficient
27
New cards

What is a microcontroller? (3)

  • Small computer on a single chip
  • Typically a CPU, some memory and some hardware blocks for interfacing
  • Most electronic products contain many microcontrollers
28
New cards

What are hardware blocks used for? (5)

  • Intended to cover wide range of functionality
  • Includes IO pins which can be set to high or low voltage to correspond to 1/0 respectively
  • Also used for timing which is incredibly important in industrial applications
  • Serial communication
  • Analogue to digital conversion
29
New cards

What is serial communication? (1)

  • When you send the bits on a single line one after the other, rather than having parallel lines
30
New cards

What needs to be considered when a company designs a microcontroller? (2)

  • How complex it should be
  • Level of cost it can be (depends on market)
31
New cards

What are semiconductors made from and how? (2)

  • Made from silicone wafers
  • Need to decide how much silicone you want to allocate to a device and cut the wafers accordingly (cut pieces called dies)
32
New cards

What is the tradeoff when it comes to die size? (4)

  • Larger dies normally means we can have more complexity but also means there may be more errors when cutting. 
  • It also means that from a wafer, we get less dies, and the higher error rate means the yield is poor
  • Smaller dies normally mean less complexity but less errors when cutting
  • We also get more dies per wafer, so the yield is much better
33
New cards

What is RISC and how does it affect transistor usage? (3)

  • A RISC processor, is one that runs on a reduced instruction set
  • This means the leftover transistors can be used for increasing register size and adding more register pages
  • Means that if you get an interrupt, you don't need to push to a stack, and instead can just use another register page
34
New cards

Why did CISC fail and RISC take over? (3)

  • CISC is a Complex Instruction Set architecture that utilises variable length complex instructions to minimise the code ran on it
  • Compilers found it was easier to store the smaller, more commonly used instructions
  • And that it was quicker to compile the code down to RISC instead so those extra instructions were never even utilised at the hardware level.
35
New cards

What does it mean that a microcontroller has off chip memory? (4)

  • Typically we have processor, memory and graphics all stuffed into one chip
  • Means we cannot open it up and change things easily which is good for large companies, so their firmware cannot be taken
  • For microcontrollers, memory is essentially stored as another hardware block
  • Makes it easier to look at and change firmware
36
New cards

What is the difference between Harvard and Von-Neumann architecture? (4)

  • Harvard architecture (typically used by microcontrollers) splits the program memory (read-only) and data memory into two separate hardware blocks with their own communication channels
  • Von-Neumann architecture (used in industry) only has one memory used for program and data with one channel to communicate with both
  • Harvard is preferred for its speed, simultaneous access and reliability
  • Von-Neumann is preferred for its simplicity and its more flexible, efficient space usage.
37
New cards

What do we typically use for the program and data memory blocks on microcontrollers? (2)

  • Flash memory for program
  • Data memory can use static RAM (consistent in timing - reliability)
38
New cards

What is the difference between SRAM and DRAM? (2)

  • Static ram stores memory using transistors (6 to store 1 bit) - this makes it fast, does not consume a lot of power, reliable but very expensive which typically results in smaller memory capacity.
  • Dynamic ram stores memory using capacitors - this makes it slower and power hungry (need to recharge capacitors often) but cheap and so larger memory capacity
39
New cards

What is SPI? (3)

  • Serial Peripheral Interface
  • Simple to implement, high speed (simultaneous sending/receiving), efficient multi device
  • Hardware block that allows you to connect to other devices as well as other microcontrollers
40
New cards

What is PWM? (2)

  • Hardware block used for pulse width modulation
  • Technique for outputting different voltages/power (eg. changing brightness of LED)
41
New cards

What is UART? (4)

  • Universal asynchronous receiver transmitters
  • Hardware block essentially used for serial communication
  • Easy and convenient way for communication between devices as it does not require a clock wire and is very simple wiring
  • Can only communicate with one device at a time and is much slower
42
New cards

What is I2C and how does it compare to SPI? (4)

  • Inter-Integrated Circuit
  • I2C is slower as it cannot send/receive simultaneously like SPI
  • Can connect to more devices as it only requires 2 wires (clock and bi-directional data), no matter how many devices
  • Requires less pins
43
New cards

What does the watchdog hardware block do? (1)

  • Essentially just checks if the system is not working and resets it if so
44
New cards

What is the PIO hardware block used for? (3)

  • Programmable Input Output
  • Essentially allows you to program your own hardware blocks (eg. UART, SPI) or something new
  • When this code runs, it does not hog the processor as they use specialised machine code
45
New cards

What are the features of the RP2350? (6)

  • RP2350 is the chip on the Pico 2 microcontroller which runs at 3.3V
  • Has a dual core running at 150MHz
  • Technically has 4 cores (2 ARM Cortex-M33, 2 RISC-V Hazard 3) and you choose which dual core setup you want
  • 520kB SRAM
  • USB 1.1 (can use it as a device or a host) 
  • 12-bit 500ksps ADC (Analogue-to-Digital Conversion)
46
New cards

What hardware blocks are there on the Pico2W module? (5)

  • RP2350 CPU
  • 4MB of flash memory
  • 2.4GHz WiFi
  • Bluetooth 5.2
  • Buck/boost power supply (1.8-5.5V) which is used to take any voltage and convert it to 3.3V which is what the RP2350 runs on
47
New cards

What does it mean to overload a pin? (1)

  • When a pin can be used for multiple protocols, but can only do one at a time
48
New cards

What is the difference between compilation and cross-compilation? (2)

  • Compilation is when we compile to the same architecture as the one that is running the compiler
  • Cross-compilation is when we compile to an architecture different to our own
49
New cards

What are the advantages of interpreted languages over compiled languages? (2)

  • Interpreted languages execute line-by-line so if it fails, it is easy to find where the error occurred in the source code
  • Compiled languages use an executable which makes it hard to trace the error back to the source code
50
New cards

How do compilers provide good error messages? (2)

  • Common errors are written into the grammar
  • This means the compiler is able to give more helpful error messages if the program crashes
51
New cards

Where is cross-compilation needed? (2)

  • When compiling on the target is impossible (eg. some microcontrollers with no RAM)
  • When compiling on the target is impractical (eg. takes very long, is new hardware)
52
New cards

What are some advantages of Harvard over Von-Neumann architecture? (2)

  • Security - since program memory is read-only, the processor can not be tricked into running something malicious
  • Allows you to have different underlying architectures for program memory and data memory (eg. flash and SSIM)
53
New cards

Why is flash memory not used for everything? (2)

  • Flash memory wears out so you cannot write to it often
  • Very slow to write to as you have to erase whole blocks
54
New cards

What are the different stages of the compiler build process going from IDE to running on the microcontroller(eg. gcc)? (5)

  • Preprocessing (.c -> .i)
  • Compiling (.i -> .s)
  • Assembler (.s -> .o)
  • Linker (.o -> .elf)
  • Loader: objcopy (.hex), avrdude
55
New cards

How does a compiler work and how does it optimise? (3)

  • Consists of many stages split into a frontend (input) and backend (target - typically specific architectures) which link to an intermediate language 
  • We can then optimise the intermediate language
  • We can then use lexers and parsers to go from input -> intermediate language -> target
56
New cards

What is the preprocessing stage of the compiler build process? (3)

  • Processes lines beginning with a hash (eg. imports etc.)
  • Performs text substitution (eg. replacing labels with macros)
  • Can give errors if you try to include file that does not exist
57
New cards

What does the assembler do? (3)

  • Takes the assembly code outputted by the compiling stage and turns it into raw machine code (1s and 0s)
  • It then outputs this to an object file
  • Leaves placeholders for linker to work with later
58
New cards

What does the linker do? (4)

  • When compiling, we may compile 5 separate C files which get converted to 5 different object files as well as any built in standard libraries which the linker then links together
  • Performs resolution: Fills in any blank placeholder gaps left by the assembler 
  • Does layout: Calculates where exactly code instructions and variables will sit in the target device's memory
  • Outputs an executable file for the target
59
New cards

What do objcopy and avrdude do? (3)

  • Both part of the loader 
  • objcopy is responsible for stripping down the elf file (keep .text section) and keeps what is necessary and puts it in a format ready to send (outputs .hex)
  • avrdude reads the output hex file line by line and sends those bits over a wire directly to the program memory of the microcontroller
60
New cards

Why should the build process be documented? (2)

  • Build process contains many different configuration options which will each affect the program in a certain way
  • Important to document our configuration options to make reproducible code
61
New cards

What are some examples of configuration options? (4)

  • Compiling for fast speed 
  • Compiling for low power consumption
  • Compiling for limited memory
  • Compiling to use certain pins (important if certain pins should be kept free)
62
New cards

What is an elf file? (4)

"

  • Executable and Linkable Format
  • Platform independent binary file (means the way the file is structured is consistent)
  • Contains layout information and section (can already know what goes to program memory and what goes to data memory)
  • Contains important debug info: Human-readable symbol tables (e.g., ""Address 0x008C corresponds to line 24 of main.c"").
"

63
New cards

What can we do with an elf file? (3)

  • Use it to create a relocatable (.o) with memory addresses, relative to where the file is placed
  • Use it as an executable (.exe, .out) as it can copy the code part of the file and tell the CPU to start running it
  • Use it as a shared object file (.dll, .so) which can be shared by multiple executables and used as a library
64
New cards

What are some of the sections in the .elf file? (4)

  • .text: contains all the instructions and is written to the flash memory
  • .rodata: read-only data that needs to be persistent so gets written to flash memory
  • .data: contains initalised global variables which means they contain data which we want to be persistent between executions. Gets sent to flash memory and every time the program runs it copies it from flash to RAM
  • .bss: contains unitialised global variables which are kept as RAM zeroed out (only zeroed out at the start of the program)
65
New cards

How do static and global variables differ if they are both loaded into RAM from flash at runtime? (2)

  • They are both treated the exact same at the linker (.elf) level
  • Only difference is that the compiler makes sure that the static variable only has a local scope
66
New cards

What are control registers? (4)

  • A register is a set of flip flops (used in SRAM, CPU cache, control registers)
  • In the case of control registers, they are not only connected for reading and writing as are wired into other circuits and IO pins
  • The values in these flip flops can then reconfigure the underlying circuitry to choose which functionality it will have
  • Often used to determine what protocol a pin will run and what it will be used for
67
New cards

How does a CPU interact with control registers and write values to them? (2)

  • I/O instructions: Have special instruction set that includes instructions to modify the control registers
  • Memory-mapped IO: Give the control registers corresponding reserved addresses in memory which we can then modify as usual and the change is reflected
68
New cards

What are the advantages and disadvantages of memory-mapped IO for control registers? (3)

  • Easier and more intuitive for programmers as can just use same instructions as for memory
  • Means no extra instructions which keeps opcode small
  • Not really an issue anymore but before number of memory addresses were limited so could not assign one to a control register
69
New cards

Why is it good to have fewer instructions? (4)

"

  • Means smaller opcode means that you have more space available for data (operands)

  • This space can be used to access more registers, handle larger raw numbers
  • Smaller opcode also means simpler decoding and smaller instruction size which maximises CPU cache
"

70
New cards

What is an operand? (4)

  • Any data that an operation acts upon
  • Can be a CPU register
  • Can be a memory address
  • Can be a raw value (called an immediate)
71
New cards

What are the different types of PROM? (3)

  • One-time programmable: This is ROM that is initially blank and you can write your firmware to it once
  • EPROM: Erasable programmable memory that uses a special UV light to erase the whole ROM so you can rewrite to it
  • EEPROM: Electronically Erasable programmable memory that uses localized electrical voltages to clear whatever part of the ROM so you can rewrite to it
72
New cards

What is the difference between EEPROM and flash? (3)

  • They both use the same underlying idea of floating gate transistors to store data
  • In EEPROM you can clear data byte-per-byte but this means more transistors are needed
  • In flash, you clear data in large chunks instead which requires less transistors
73
New cards

How do we map address spaces across program and data memory? (3) 

  • Since they are different hardware blocks, they each have their own address spaces that start from 0
  • To the programmer it looks like one big address space
  • In the .elf file, it splits this up and essentially adds a huge fixed offset
74
New cards

Why do we split up IO registers and extended IO registers in memory? (2)

  • The normal IO registers have smaller addresses, which means we can use a different opcode to pass more operands
  • The extended IO registers use different opcodes that take fewer operands. Often times the operand is a reference to an instruction that contains the rest of the instruction which means two fetches are needed for one instruction
75
New cards

What does the data memory map look like on typical microcontrollers? (5)

"


"

76
New cards

What are the different segments of a memory map used for? (4)

  • 32 general registers: This is the CPU’s ultra-fast primary workspace. When your code performs basic operations (like a = b + c), the variables must be loaded here first.
  • 64 IO registers: These are where the control registers and status registers (stores flags eg. if last operation gave 0) are found
  • Extended IO registers: For more complex control registers (eg. ADC, PWM or anything to do with timing)
  • RAM: This is where we store values that the program needs that cannot fit into the general registers
77
New cards

What is the minimum number of configuration bits needed for a pin? (2)

  • 1 bit to say whether it is input or output (defaults to 0 which is input as we do not want to accidentally output a value to something dangerous like a bomb - klaus)
  • 1 bit to recieve or send the data on
78
New cards

What is PORTF, DDRF, PINF and how do they work? (5)

  • Each of them is an 8 bit control register mapped to a unique memory address so we can change the value in them
  • They each control a property for 8 separate physical pins where every bit corresponds to a pin. 
  • Together the 8 pins make up a single port we call port F (where the f in the register names come from)
  • DDRF (Data Direction Register) controls the IO property where 0 means that the pin is used for input and 1 means it is used for output
  • PORTF controls the output where a 1 causes the circuit to connect to the 5V powerline which sends a 1 on that pin. 0 causes the circuit to disconnect from the power line
  • PINF reads the input pin and whatever raw value was recieved from the wire is stored here.
79
New cards

What happens if we send a 1 to PORTF while DDRF lists the pin as an input? (1)

  • Activates a pull-up resistor which increases the upper bound of the pin.
80
New cards

How does a pull up resistor work in the context of a button? (5)

  • A button consists of an output, an air gap, and a wire to ground. When we push the button, we fill that air gap and cause ground (0V) to be sent along the output wire
  • The other side of the output wire is connected to the pin which picks up this value
  • Since when the button is not pressed, the output wire has no current and is basically pin on one side and air on the other, which causes electrostatic interference to try and travel along the wire giving random values.
  • To avoid this, a pull-up resistor connects the pin to the 5V power line via a resistor so that the output wire has a constant 5V passing through it at all times, which means electrostatic interference does not cause random values.
  • When we push the button, we complete the circuit and the 5V from the power supply instantly goes to ground instead (path of least resistance), which causes a 0 to be read at the pin.
81
New cards

What does _BV(x) do? (1)

  • Bitshifts 1 to the left x times
82
New cards

How and why might you need to represent state with an LED? (4)

  • Many microcontrollers do not have any interface as they are power hungry and power is often limited on a microcontroller. 
  • Occasionally we may have an LED and so it is useful to be able to determine the state of the program from the USB.
  • Can turn it on and off at different frequencies, but could also use easing animations alongside PWM to control how the brightness changes over time to represent different states
  • Can also overlay a fast serial protocol on the LED that can be captured by a camera
83
New cards

What are the two main basic ways to receive a signal from an IO? (3)

  • Programmed IO (Polling): Essentially busy waiting in a loop. Is very fast but occupies CPU
  • Interrupt Driven IO: Sends a hardware signal on receiving that can cause your program flow to jump to another part of the code. Harder to debug but also means the CPU can do other work or sleep
  • Most things use interrupt driven IO
84
New cards

Why can most programs on a microcontroller never terminate? (2)

  • Normally when running a script, when it terminates we return to the OS
  • Since most microcontrollers are not running an OS, there is nothing for it to return to, so has to keep running
85
New cards

What does the typical program flow on a microcontroller look like? (3)

  • Initialisation: Set up all the hardware blocks (via their control registers) which can take a long time because of how many options there are
  • Main loop: Enters a main loop which it can then never exit, so long as it has power
  • At any point, the program flow could switch because of an IO interrupt from an external event. We need to be able to save state, handle the interrupt and restore state after
86
New cards

What is the DMA and what does it do? (4)

  • Direct Memory Access
  • Typically the CPU is responsible for handling all IO and has to stop its normal running to do IO tasks
  • The DMA is like a mini processor which just acts as an IO controller, takes control of the control bus and allows different hardware blocks to transfer data between each other 
  • It lets the CPU know when a task is done via an interrupt
87
New cards

What needs to happen when an interrupt occurs? (2)

  • The state of the interrupted process needs to be preserved
  • Not necessary if the interrupt is intended to abort execution because irrecoverable fault
88
New cards

"What is needed for a ""precise interrupt""? (4)"

  • State of the program counter (PC) must be preserved
  • Everything before the PC has been fully executed - we wait for anything that is executing to finish first before interrupting
  • Nothing beyond the PC has been started
  • Execution state of instruction at the PC is known
89
New cards

What happens when an interrupt arrives? (10)

  • Processor does not immediately react and completes current instruction first
  • The processor acknowledges the interrupt by communicating to whatever has raised the interrupt
  • We save some state (have to include PC and process state word)
  • Processor jumps to relevant section of code for the interrupt (PC loaded with value from interrupt vector table)
  • Interrupts are temporarily disabled by the ISR
  • Saves additional state such as relevant registers onto a stack (can reenable interrupts but not recommended)
  • We then handle the interrupt with the ISR which is custom code by the programmer
  • Restore state, normally done by compiler as well as save state steps
  • Re-enable interrupts
  • Restore the PSW and PC
90
New cards

What is PSW? (2)

  • Process Status Word
  • Flag that stores if the result of the last operation was a 0 or not
91
New cards

How do we know what section of the code to jump to after an interrupt? (4)

  • We maintain an interrupt vector table in memory
  • Maps addresses to corresponding interrupts (including reset)
  • Stored in the low addresses of the program memory as it as to be persistent 
  • Can sometimes move the vector table around and maintain a reference to it, which can allow us to change the interrupt vector table on the fly - useful if interrupt behaviour is based on state
92
New cards

What is the ISR? (2)

  • Interrupt Service Routines
  • Essentially user-defined procedures that is executed when an interrupt occurs 
93
New cards

What are the two main rules for ISRs? (4)

  • Keep them fast - avoid loops, heavy/blocking instructions
  • Interrupts are essentially ignored while handling another, so we want to finish it quick so we can reenable interrupts
  • Keeping them fast means that it is safe to turn off interrupts which is desired to stop interrupts interrupting interrupts
  • Keep them simple - debugging ISRs can be hard especially when it comes to multiple interrupts, or self interrupting interrupts
94
New cards

What is latency and what affects it? (3)

  • Essentially how long it takes for CPU to start working on an interrupt (not how long it takes to resolve it)
  • Affected by complexity of ISR as more complex ones will affect/contaminate more registers, so more registers need to be saved to the stack and restored later
  • Hugely affected by if the interrupt had to wait while interrupts were disabled which can be a wait of many instruction cycles
95
New cards
What are reentrant ISRs? (2)
  • An interrupt service routine that reenables interrupts while it is still running
  • This means that the interrupt can be interrupted
96
New cards

Is the latency deterministic? (2)

  • Often times no - sometimes interrupts are based on external events, so when they trigger it is not entirely clear. They could trigger during or at the end of an instruction, which can make a huge difference in latency
  • Can also depend on whether we already in the middle of another ISR or not and if we are in the period of time where that ISR has disabled interrupts which means there is queue waiting
97
New cards

What are the issues with latency being non-deteministic? (4)

  • Means there are harder race conditions we need to account for despite the being highly unlikely
  • Deterministic latency is important in real-time systems (eg. deploying air bags)
  • Humans and control algorithms can adapt to a deterministic latency but struggle when the latency is random
  • We want to be able to give guarantees on the maximum latency and how much variability we have
98
New cards

What does maximum latency depend on? (4)

  • Hardware: How long it takes to complete current instruction, how long it takes to save state (deterministic as it saves same amount of registers)
  • Software: How long it takes software to save state (normally deterministic), maximum length of critical sections that disable interrupts
99
New cards

What is jitter and what causes it? (4)

  • What we refer to as the variability of the latency
  • Non-determinism on how long critical section of ISR is and on when in a critical region an interrupt can arrive increases variability
  • Also caused by variation in instruction execution times (dependent on what instruction was executing when the interrupt arrives)
  • Can also be caused by DMA freezing CPU
100
New cards

Can the DMA freeze the CPU? (3)

  • Yes - due to bus contention
  • The CPUs and DMA are all linked to the data bus which connects to memory, but only one can access the bus at a time
  • The DMA can take priority and essentially freeze the CPU clock meaning it doesnt run while it performs an operation on the memory bus