Expand description
timers.c: software timers and the daemon task that runs them.
A software timer is not an interrupt and not a thread. It is an entry on
one of two sorted lists, and a task — the daemon, Tmr Svc — that
blocks on a queue until either a command arrives or the head of the list
is due. Everything a caller does to a timer is a message: start, stop,
reset, change period, delete. Nothing touches the lists but the daemon.
That indirection is the whole design, and it is why the trace has a
TIMER_COMMAND_SEND line for every call and a TIMER_EXPIRED line only
when the daemon gets round to it.
Two things this kernel spells differently from the C, both because it has no pointers:
- the command queue carries an index into a ring of commands rather than a struct, so the queue keeps the length, the blocking and the full behaviour the trace depends on while the payload lives beside it;
- a callback is a small number the application’s hook switches on,
rather than a function pointer.
pvTimerIDrides along with it.
Structs§
- Message
- One
DaemonTaskMessage_t, kept beside the queue rather than in it. - Timer
- One software timer: a
Timer_twithout the pointers.
Enums§
- Command
- The command ids, exactly as
timers.hnumbers them — the numbering is load-bearing, becausexTimerGenericCommandFromTaskrefuses anything at or aboveCommand::FIRST_FROM_ISRand the from-ISR half refuses anything below it.
Constants§
- MAX_
TIMER_ COMMANDS - How many
DaemonTaskMessage_ts the ring beside the timer queue holds.