Changeset ad58fd2 in mainline
- Timestamp:
- 2022-08-15T16:31:58Z (2 years ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 46b305a
- Parents:
- 742f95ec
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2022-08-15 16:26:16)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2022-08-15 16:31:58)
- Location:
- kernel/generic
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/time/timeout.h
r742f95ec rad58fd2 45 45 IRQ_SPINLOCK_DECLARE(lock); 46 46 47 /** Link to the list of active timeouts on CURRENT->cpu */47 /** Link to the list of active timeouts on timeout->cpu */ 48 48 link_t link; 49 49 /** Timeout will be activated when current clock tick reaches this value. */ … … 61 61 extern void timeout_init(void); 62 62 extern void timeout_initialize(timeout_t *); 63 extern void timeout_reinitialize(timeout_t *);64 63 extern void timeout_register(timeout_t *, uint64_t, timeout_handler_t, void *); 65 64 extern bool timeout_unregister(timeout_t *); -
kernel/generic/src/time/clock.c
r742f95ec rad58fd2 172 172 timeout_handler_t handler = timeout->handler; 173 173 void *arg = timeout->arg; 174 timeout_reinitialize(timeout);175 174 176 175 irq_spinlock_unlock(&timeout->lock, false); -
kernel/generic/src/time/timeout.c
r742f95ec rad58fd2 57 57 } 58 58 59 /** Reinitialize timeout60 *61 * Initialize all members except the lock.62 *63 * @param timeout Timeout to be initialized.64 *65 */66 void timeout_reinitialize(timeout_t *timeout)67 {68 timeout->cpu = NULL;69 timeout->deadline = 0;70 timeout->handler = NULL;71 timeout->arg = NULL;72 link_initialize(&timeout->link);73 }74 75 59 /** Initialize timeout 76 60 * … … 83 67 { 84 68 irq_spinlock_initialize(&timeout->lock, "timeout_t_lock"); 85 timeout_reinitialize(timeout); 69 link_initialize(&timeout->link); 70 timeout->cpu = NULL; 86 71 } 87 72 … … 103 88 irq_spinlock_lock(&CPU->timeoutlock, true); 104 89 irq_spinlock_lock(&timeout->lock, false); 105 106 if (timeout->cpu)107 panic("Unexpected: timeout->cpu != 0.");108 90 109 91 timeout->cpu = CPU; … … 152 134 bool timeout_unregister(timeout_t *timeout) 153 135 { 154 DEADLOCK_PROBE_INIT(p_tolock);136 assert(timeout->cpu); 155 137 156 grab_locks: 157 irq_spinlock_lock(&timeout->lock, true); 158 if (!timeout->cpu) {159 irq_spinlock_unlock(&timeout->lock, true);160 return false;138 irq_spinlock_lock(&timeout->cpu->timeoutlock, true); 139 140 bool success = link_in_use(&timeout->link); 141 if (success) { 142 list_remove(&timeout->link); 161 143 } 162 144 163 if (!irq_spinlock_trylock(&timeout->cpu->timeoutlock)) { 164 irq_spinlock_unlock(&timeout->lock, true); 165 DEADLOCK_PROBE(p_tolock, DEADLOCK_THRESHOLD); 166 goto grab_locks; 167 } 168 169 /* 170 * Now we know for sure that timeout hasn't been activated yet 171 * and is lurking in timeout->cpu->timeout_active_list. 172 */ 173 174 link_t *cur = list_next(&timeout->link, 175 &timeout->cpu->timeout_active_list); 176 if (cur != NULL) { 177 timeout_t *tmp = list_get_instance(cur, timeout_t, link); 178 irq_spinlock_lock(&tmp->lock, false); 179 irq_spinlock_unlock(&tmp->lock, false); 180 } 181 182 list_remove(&timeout->link); 183 irq_spinlock_unlock(&timeout->cpu->timeoutlock, false); 184 185 timeout_reinitialize(timeout); 186 irq_spinlock_unlock(&timeout->lock, true); 187 188 return true; 145 irq_spinlock_unlock(&timeout->cpu->timeoutlock, true); 146 return success; 189 147 } 190 148
Note:
See TracChangeset
for help on using the changeset viewer.