Changeset 011c79a in mainline
- Timestamp:
- 2023-02-04T16:19:33Z (19 months ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e86f568
- Parents:
- aae2869
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2022-08-16 11:19:14)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2023-02-04 16:19:33)
- Location:
- kernel/generic
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/cpu.h
raae2869 r011c79a 60 60 atomic_size_t nrdy; 61 61 runq_t rq[RQ_COUNT]; 62 volatile size_t needs_relink;63 62 64 63 IRQ_SPINLOCK_DECLARE(timeoutlock); … … 74 73 size_t missed_clock_ticks; 75 74 76 /** Can only be accessed when interrupts are disabled. */75 /** Can only be accessed by the CPU represented by this structure when interrupts are disabled. */ 77 76 uint64_t current_clock_tick; 78 77 uint64_t preempt_deadline; /* < when should the currently running thread be preempted */ 78 uint64_t relink_deadline; 79 79 80 80 /** -
kernel/generic/src/proc/scheduler.c
raae2869 r011c79a 270 270 static void relink_rq(int start) 271 271 { 272 if (CPU->current_clock_tick < CPU->relink_deadline) 273 return; 274 275 CPU->relink_deadline = CPU->current_clock_tick + NEEDS_RELINK_MAX; 276 272 277 list_t list; 273 274 278 list_initialize(&list); 279 275 280 irq_spinlock_lock(&CPU->lock, false); 276 281 277 if (CPU->needs_relink > NEEDS_RELINK_MAX) { 278 int i; 279 for (i = start; i < RQ_COUNT - 1; i++) { 280 /* Remember and empty rq[i + 1] */ 281 282 irq_spinlock_lock(&CPU->rq[i + 1].lock, false); 283 list_concat(&list, &CPU->rq[i + 1].rq); 284 size_t n = CPU->rq[i + 1].n; 285 CPU->rq[i + 1].n = 0; 286 irq_spinlock_unlock(&CPU->rq[i + 1].lock, false); 287 288 /* Append rq[i + 1] to rq[i] */ 289 290 irq_spinlock_lock(&CPU->rq[i].lock, false); 291 list_concat(&CPU->rq[i].rq, &list); 292 CPU->rq[i].n += n; 293 irq_spinlock_unlock(&CPU->rq[i].lock, false); 294 } 295 296 CPU->needs_relink = 0; 282 for (int i = start; i < RQ_COUNT - 1; i++) { 283 /* Remember and empty rq[i + 1] */ 284 285 irq_spinlock_lock(&CPU->rq[i + 1].lock, false); 286 list_concat(&list, &CPU->rq[i + 1].rq); 287 size_t n = CPU->rq[i + 1].n; 288 CPU->rq[i + 1].n = 0; 289 irq_spinlock_unlock(&CPU->rq[i + 1].lock, false); 290 291 /* Append rq[i + 1] to rq[i] */ 292 293 irq_spinlock_lock(&CPU->rq[i].lock, false); 294 list_concat(&CPU->rq[i].rq, &list); 295 CPU->rq[i].n += n; 296 irq_spinlock_unlock(&CPU->rq[i].lock, false); 297 297 } 298 298 … … 726 726 irq_spinlock_lock(&cpus[cpu].lock, true); 727 727 728 printf("cpu%u: address=%p, nrdy=%zu, needs_relink=%zu\n", 728 /* Technically a data race, but we don't really care in this case. */ 729 int needs_relink = cpus[cpu].relink_deadline - cpus[cpu].current_clock_tick; 730 731 printf("cpu%u: address=%p, nrdy=%zu, needs_relink=%d\n", 729 732 cpus[cpu].id, &cpus[cpu], atomic_load(&cpus[cpu].nrdy), 730 cpus[cpu].needs_relink);733 needs_relink); 731 734 732 735 unsigned int i; -
kernel/generic/src/time/clock.c
raae2869 r011c79a 184 184 185 185 if (THREAD) { 186 irq_spinlock_lock(&CPU->lock, false);187 CPU->needs_relink += 1 + missed_clock_ticks;188 irq_spinlock_unlock(&CPU->lock, false);189 190 186 if (current_clock_tick >= CPU->preempt_deadline && PREEMPTION_ENABLED) { 191 187 scheduler();
Note:
See TracChangeset
for help on using the changeset viewer.