CS 452/652 Fall 2022 - Lecture 10
Oct 18, 2022
prev
next
Interrupt Handling
user task executing
[interrupt]
handler saves task state and switches to kernel
kernel makes task ready
kernel determines interrupt number
kernel processes interrupt
kernel switches to next ready task
Interrupt Processing
multiple interrupts pending: loop over IAR or one-shot processing
cause for interrupt (at device):
event, such as timer underflow → edge trigger
device will not trigger interrupt again unless previous one confirmed
status, such as buffer empty → level trigger
after completion of interrupt handler, interrupt would trigger again!
→ force status change or disable/mask interrupt
example: confirm timer interrupt by writing to EOIR.
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
Timer Interrupt
timer compare register (CN reg vs. interrupt #)
rearm timer - new value (cf. real-time loop)
overflow? no problem...
confirm interrupt before/during/after processing
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
)