CS 452/652 Winter 2023 - Lecture 9
Feb 7, 2023
prev
next
Timer Interrupt
timer compare register (CN reg vs. interrupt #)
rearm timer - new value (cf. real-time loop)
overflow? no problem...
C0, C2 comparators used by VC? use C1 or C3
edge vs. level: rearm timer by writing bit to CS
also confirm timer interrupt to GIC via IAR
AwaitEvent
matchmaking: task ↔ event
task(s) waiting for interrupt to occur: store one or queue? → design decision
interrupt without waiting task: buffer one or several? or failure?
excessive buffering is not helpful in any producer/consumer scenario
multiple same interrupts without waiting task indicate performance problem!
use task prioritity to make sure that hardware interrupts are handled promptly
AwaitEvent()
argument and return code → design decision
Interrupt Handling
user task executing
[interrupt]
handler saves task state and switches to kernel
kernel makes task ready
kernel determines interrupt number
multiple interrupts pending: loop over IAR or one-shot processing
kernel processes interrupt
after completion of interrupt handler, interrupt would trigger again!
→ force status change or disable/mask interrupt
kernel switches to next ready task
Clock Server
main loop of receiving and processing requests
server never blocks ⇒ cannot call
AwaitEvent()
task blocking delegated to clock notifier
server & notifier → general design pattern
Server Processing
TIME: reply to client with current clock value
DELAY: park client task (using tick & tid) in timer list
two variations: absolute vs. relative tick
TICK: advance clock value and check parked tasks in timer list
reply to clients whose waiting times have completed
timer list should probably be a sorted data structure
Clock Notifier
main loop (at high priority)
loop: AwaitEvent() Send() tick to clock server
Idle/Halt
what to do when processor has not other work?
SETI? cryptomining? → often not appropriate!
maintenance, e.g., garbage collection → not relevant for CS 452 kernel
diagnosis, such as computation of idle fraction
save energy → low-power halt! (cf. "race-to-idle/sleep")
implement as dedicated
idle
task at lowest priority
for (;;) { while (maintenance()) yield(); park(); }
ARMv8 instructions
wfi
(or
wfe
)