Changeset 4760793 in mainline for kernel/generic/src/time/clock.c


Ignore:
Timestamp:
2024-01-14T18:23:40Z (4 months ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
master
Children:
5663872, c7ceacf
Parents:
3b68542
Message:

Add CPU_LOCAL alongside CPU and segregate fields that are only used locally

This makes it more clear which fields can be used without synchronization
and which need more care.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/time/clock.c

    r3b68542 r4760793  
    124124{
    125125        uint64_t now = get_cycle();
    126         atomic_time_increment(&CPU->busy_cycles, now - CPU->last_cycle);
    127         CPU->last_cycle = now;
     126        atomic_time_increment(&CPU->busy_cycles, now - CPU_LOCAL->last_cycle);
     127        CPU_LOCAL->last_cycle = now;
    128128}
    129129
     
    137137void clock(void)
    138138{
    139         size_t missed_clock_ticks = CPU->missed_clock_ticks;
    140         CPU->missed_clock_ticks = 0;
    141 
    142         CPU->current_clock_tick += missed_clock_ticks + 1;
    143         uint64_t current_clock_tick = CPU->current_clock_tick;
     139        size_t missed_clock_ticks = CPU_LOCAL->missed_clock_ticks;
     140        CPU_LOCAL->missed_clock_ticks = 0;
     141
     142        CPU_LOCAL->current_clock_tick += missed_clock_ticks + 1;
     143        uint64_t current_clock_tick = CPU_LOCAL->current_clock_tick;
    144144        clock_update_counters(current_clock_tick);
    145145
     
    186186
    187187        if (THREAD) {
    188                 if (current_clock_tick >= CPU->preempt_deadline && PREEMPTION_ENABLED) {
     188                if (current_clock_tick >= CPU_LOCAL->preempt_deadline && PREEMPTION_ENABLED) {
    189189                        scheduler();
    190190#ifdef CONFIG_UDEBUG
Note: See TracChangeset for help on using the changeset viewer.