Make timeout->cpu immutable
commitad58fd2c61f108df5c75951d8f2ba2d015952c9e
authorJiří Zárevúcky <zarevucky.jiri@gmail.com>
Mon, 15 Aug 2022 16:26:16 +0000 (15 18:26 +0200)
committerJiří Zárevúcky <zarevucky.jiri@gmail.com>
Mon, 15 Aug 2022 16:31:58 +0000 (15 18:31 +0200)
tree839b949dc4f9f3edbb2ec2aa55e89c113ffea49a
parent742f95ecf654c520834dbc577753c18d66995c14
Make timeout->cpu immutable

We ensure timeout->cpu is only changed in timeout_register(),
which by its nature is externally synchronized with timeout_unregister(),
and internally synchronized with clock(). Thus in both those contexts,
timeout->cpu is always a valid constant pointing to the CPU of last
call to timeout_register().

Doing so removes the need for synchronization using timeout->lock.
Instead, timeout->link is synchronized by timeout->cpu->timeoutlock,
and all other fields of timeout_t are also immutable outside
timeout_register(), which means they are safely synchronized by
a combination of timeout->cpu->timoutlock and external sychronization
of timeout_register/unregister.
kernel/generic/include/time/timeout.h
kernel/generic/src/time/clock.c
kernel/generic/src/time/timeout.c