Changeset 742f95ec in mainline for kernel/generic/src/time/timeout.c
- Timestamp:
- 2022-08-15T14:20:53Z (3 years ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ad58fd2
- Parents:
- d9dda26
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2022-08-15 14:08:44)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2022-08-15 14:20:53)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/time/timeout.c
rd9dda26 r742f95ec 67 67 { 68 68 timeout->cpu = NULL; 69 timeout-> ticks= 0;69 timeout->deadline = 0; 70 70 timeout->handler = NULL; 71 71 timeout->arg = NULL; … … 108 108 109 109 timeout->cpu = CPU; 110 timeout->ticks = us2ticks(time); 111 110 timeout->deadline = CPU->current_clock_tick + us2ticks(time); 112 111 timeout->handler = handler; 113 112 timeout->arg = arg; 114 113 115 114 /* 116 * Insert timeout into the active timeouts list according to timeout-> ticks.115 * Insert timeout into the active timeouts list according to timeout->deadline. 117 116 */ 118 uint64_t sum = 0;119 117 timeout_t *target = NULL; 120 118 link_t *cur, *prev; … … 125 123 irq_spinlock_lock(&target->lock, false); 126 124 127 if (timeout-> ticks < sum + target->ticks) {125 if (timeout->deadline < target->deadline) { 128 126 irq_spinlock_unlock(&target->lock, false); 129 127 break; 130 128 } 131 129 132 sum += target->ticks;133 130 irq_spinlock_unlock(&target->lock, false); 134 131 prev = cur; … … 139 136 else 140 137 list_insert_after(&timeout->link, prev); 141 142 /*143 * Adjust timeout->ticks according to ticks144 * accumulated in target's predecessors.145 */146 timeout->ticks -= sum;147 148 /*149 * Decrease ticks of timeout's immediate succesor by timeout->ticks.150 */151 if (cur != NULL) {152 irq_spinlock_lock(&target->lock, false);153 target->ticks -= timeout->ticks;154 irq_spinlock_unlock(&target->lock, false);155 }156 138 157 139 irq_spinlock_unlock(&timeout->lock, false); … … 195 177 timeout_t *tmp = list_get_instance(cur, timeout_t, link); 196 178 irq_spinlock_lock(&tmp->lock, false); 197 tmp->ticks += timeout->ticks;198 179 irq_spinlock_unlock(&tmp->lock, false); 199 180 }
Note:
See TracChangeset
for help on using the changeset viewer.