Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/cpu.h

    r31e15be rd23712e  
    4444#include <arch.h>
    4545
    46 #define CPU                  CURRENT->cpu
     46#define CPU                  (CURRENT->cpu)
     47#define CPU_LOCAL            (&CPU->local)
     48
     49/**
     50 * Contents of CPU_LOCAL. These are variables that are only ever accessed by
     51 * the CPU they belong to, so they don't need any synchronization,
     52 * just locally disabled interrupts.
     53 */
     54typedef struct cpu_local {
     55        /**
     56         * When system clock loses a tick, it is
     57         * recorded here so that clock() can react.
     58         */
     59        size_t missed_clock_ticks;
     60
     61        uint64_t current_clock_tick;
     62        uint64_t preempt_deadline;  /* < when should the currently running thread be preempted */
     63        uint64_t relink_deadline;
     64
     65        /**
     66         * Stack used by scheduler when there is no running thread.
     67         * This field is unchanged after initialization.
     68         */
     69        uint8_t *stack;
     70
     71        /**
     72         * Processor cycle accounting.
     73         */
     74        bool idle;
     75        uint64_t last_cycle;
     76
     77        context_t scheduler_context;
     78
     79        struct thread *prev_thread;
     80} cpu_local_t;
    4781
    4882/** CPU structure.
     
    5185 */
    5286typedef struct cpu {
    53         IRQ_SPINLOCK_DECLARE(lock);
     87        IRQ_SPINLOCK_DECLARE(tlb_lock);
    5488
    5589        tlb_shootdown_msg_t tlb_messages[TLB_MESSAGE_QUEUE_LEN];
    5690        size_t tlb_messages_count;
    5791
    58         context_t saved_context;
    59 
    6092        atomic_size_t nrdy;
    6193        runq_t rq[RQ_COUNT];
    62         volatile size_t needs_relink;
    6394
    6495        IRQ_SPINLOCK_DECLARE(timeoutlock);
     
    6697
    6798        /**
    68          * When system clock loses a tick, it is
    69          * recorded here so that clock() can react.
    70          * This variable is CPU-local and can be
    71          * only accessed when interrupts are
    72          * disabled.
    73          */
    74         size_t missed_clock_ticks;
    75 
    76         /**
    7799         * Processor cycle accounting.
    78100         */
    79         bool idle;
    80         uint64_t last_cycle;
    81         uint64_t idle_cycles;
    82         uint64_t busy_cycles;
     101        atomic_time_stat_t idle_cycles;
     102        atomic_time_stat_t busy_cycles;
    83103
    84104        /**
     
    95115        cpu_arch_t arch;
    96116
    97         struct thread *fpu_owner;
     117#ifdef CONFIG_FPU_LAZY
     118        /* For synchronization between FPU trap and thread destructor. */
     119        IRQ_SPINLOCK_DECLARE(fpu_lock);
     120#endif
     121        _Atomic(struct thread *) fpu_owner;
    98122
    99         /**
    100          * Stack used by scheduler when there is no running thread.
    101          */
    102         uint8_t *stack;
     123        cpu_local_t local;
    103124} cpu_t;
    104125
Note: See TracChangeset for help on using the changeset viewer.