Changeset ba25c4b in mainline
- Timestamp:
- 2023-02-09T15:31:39Z (2 years ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 83789ea2
- Parents:
- 78acbc72
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2023-02-09 15:28:13)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2023-02-09 15:31:39)
- Location:
- kernel/generic
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/time/timeout.h
r78acbc72 rba25c4b 53 53 /** On which processor is this timeout registered. */ 54 54 cpu_t *cpu; 55 /** Used to synchronize with the handler callback. */ 56 atomic_bool finished; 55 57 } timeout_t; 56 58 -
kernel/generic/src/time/clock.c
r78acbc72 rba25c4b 168 168 timeout_handler_t handler = timeout->handler; 169 169 void *arg = timeout->arg; 170 atomic_bool *finished = &timeout->finished; 170 171 171 172 irq_spinlock_unlock(&CPU->timeoutlock, false); 172 173 173 174 handler(arg); 175 176 /* Signal that the handler is finished. */ 177 atomic_store_explicit(finished, true, memory_order_release); 174 178 175 179 irq_spinlock_lock(&CPU->timeoutlock, false); -
kernel/generic/src/time/timeout.c
r78acbc72 rba25c4b 90 90 assert(!link_in_use(&timeout->link)); 91 91 92 timeout->cpu = CPU; 93 timeout->deadline = CPU->current_clock_tick + us2ticks(time); 94 timeout->handler = handler; 95 timeout->arg = arg; 92 *timeout = (timeout_t) { 93 .cpu = CPU, 94 .deadline = CPU->current_clock_tick + us2ticks(time), 95 .handler = handler, 96 .arg = arg, 97 .finished = ATOMIC_VAR_INIT(false), 98 }; 96 99 97 100 /* Insert timeout into the active timeouts list according to timeout->deadline. */ … … 135 138 136 139 irq_spinlock_unlock(&timeout->cpu->timeoutlock, true); 140 141 if (!success) { 142 /* Timeout was fired, we need to wait for the callback to finish. */ 143 while (!atomic_load_explicit(&timeout->finished, memory_order_acquire)) 144 cpu_spin_hint(); 145 } 146 137 147 return success; 138 148 }
Note:
See TracChangeset
for help on using the changeset viewer.