Changeset a35b458 in mainline for kernel/generic/src/time/clock.c
- Timestamp:
- 2018-03-02T20:10:49Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f1380b7
- Parents:
- 3061bc1
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/time/clock.c
r3061bc1 ra35b458 84 84 if (faddr == 0) 85 85 panic("Cannot allocate page for clock."); 86 86 87 87 uptime = (uptime_t *) PA2KA(faddr); 88 88 89 89 uptime->seconds1 = 0; 90 90 uptime->seconds2 = 0; 91 91 uptime->useconds = 0; 92 92 93 93 clock_parea.pbase = faddr; 94 94 clock_parea.frames = 1; … … 96 96 clock_parea.mapped = false; 97 97 ddi_parea_register(&clock_parea); 98 98 99 99 /* 100 100 * Prepare information for the userspace so that it can successfully … … 146 146 { 147 147 size_t missed_clock_ticks = CPU->missed_clock_ticks; 148 148 149 149 /* Account CPU usage */ 150 150 cpu_update_accounting(); 151 151 152 152 /* 153 153 * To avoid lock ordering problems, … … 160 160 clock_update_counters(); 161 161 cpu_update_accounting(); 162 162 163 163 irq_spinlock_lock(&CPU->timeoutlock, false); 164 164 165 165 link_t *cur; 166 166 while ((cur = list_first(&CPU->timeout_active_list)) != NULL) { 167 167 timeout_t *timeout = list_get_instance(cur, timeout_t, 168 168 link); 169 169 170 170 irq_spinlock_lock(&timeout->lock, false); 171 171 if (timeout->ticks-- != 0) { … … 173 173 break; 174 174 } 175 175 176 176 list_remove(cur); 177 177 timeout_handler_t handler = timeout->handler; 178 178 void *arg = timeout->arg; 179 179 timeout_reinitialize(timeout); 180 180 181 181 irq_spinlock_unlock(&timeout->lock, false); 182 182 irq_spinlock_unlock(&CPU->timeoutlock, false); 183 183 184 184 handler(arg); 185 185 186 186 irq_spinlock_lock(&CPU->timeoutlock, false); 187 187 } 188 188 189 189 irq_spinlock_unlock(&CPU->timeoutlock, false); 190 190 } 191 191 CPU->missed_clock_ticks = 0; 192 192 193 193 /* 194 194 * Do CPU usage accounting and find out whether to preempt THREAD. 195 195 * 196 196 */ 197 197 198 198 if (THREAD) { 199 199 uint64_t ticks; 200 200 201 201 irq_spinlock_lock(&CPU->lock, false); 202 202 CPU->needs_relink += 1 + missed_clock_ticks; 203 203 irq_spinlock_unlock(&CPU->lock, false); 204 204 205 205 irq_spinlock_lock(&THREAD->lock, false); 206 206 if ((ticks = THREAD->ticks)) { … … 211 211 } 212 212 irq_spinlock_unlock(&THREAD->lock, false); 213 213 214 214 if (ticks == 0 && PREEMPTION_ENABLED) { 215 215 scheduler();
Note:
See TracChangeset
for help on using the changeset viewer.