Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/kernel.hfa

    refa28d5 ra892e61  
    4848extern struct cluster * mainCluster;
    4949
    50 // Coroutine used py processors for the 2-step context switch
     50// Processor id, required for scheduling threads
     51
     52
    5153coroutine processorCtx_t {
    5254        struct processor * proc;
    5355};
    5456
    55 struct io_future_t;
    56 
    57 // Information needed for idle sleep
     57
    5858struct __fd_waitctx {
    59         // semaphore/future like object
    60         // values can be 0, 1 or some file descriptor.
    61         // 0 - is the default state
    62         // 1 - means the proc should wake-up immediately
    63         // FD - means the proc is going asleep and should be woken by writing to the FD.
    64         volatile int sem;
    65 
    66         // The event FD that corresponds to this processor
    67         int evfd;
    68 
    69         // buffer into which the proc will read from evfd
    70         // unused if not using io_uring for idle sleep
    71         void * rdbuf;
    72 
    73         // future use to track the read of the eventfd
    74         // unused if not using io_uring for idle sleep
    75         io_future_t * ftr;
    76 
    77         volatile unsigned long long wake__time;
    78         volatile unsigned long long sleep_time;
    79         volatile unsigned long long drain_time;
     59        volatile int fd;
    8060};
    8161
     
    11292        struct {
    11393                $io_context * ctx;
    114                 unsigned target;
    115                 volatile bool pending;
    116                 volatile bool dirty;
     94                bool pending;
     95                bool dirty;
    11796        } io;
    11897
     
    124103        bool pending_preemption;
    125104
    126         // context for idle sleep
     105        // Idle lock (kernel semaphore)
     106        int idle_fd;
     107
     108        // Idle waitctx
    127109        struct __fd_waitctx idle_wctx;
    128110
     
    173155void ^?{}(__intrusive_lane_t & this);
    174156
    175 // Aligned timestamps which are used by the ready queue and io subsystem
     157// Aligned timestamps which are used by the relaxed ready queue
    176158struct __attribute__((aligned(128))) __timestamp_t {
    177159        volatile unsigned long long tv;
     
    179161};
    180162
     163struct __attribute__((aligned(16))) __cache_id_t {
     164        volatile unsigned id;
     165};
     166
     167// Aligned timestamps which are used by the relaxed ready queue
     168struct __attribute__((aligned(128))) __help_cnts_t {
     169        volatile unsigned long long src;
     170        volatile unsigned long long dst;
     171        volatile unsigned long long tri;
     172};
     173
    181174static inline void  ?{}(__timestamp_t & this) { this.tv = 0; this.ma = 0; }
    182175static inline void ^?{}(__timestamp_t &) {}
    183176
    184 
    185 struct __attribute__((aligned(16))) __cache_id_t {
    186         volatile unsigned id;
    187 };
     177struct __attribute__((aligned(128))) __ready_queue_caches_t;
     178void  ?{}(__ready_queue_caches_t & this);
     179void ^?{}(__ready_queue_caches_t & this);
     180
     181//TODO adjust cache size to ARCHITECTURE
     182// Structure holding the ready queue
     183struct __ready_queue_t {
     184        // Data tracking the actual lanes
     185        // On a seperate cacheline from the used struct since
     186        // used can change on each push/pop but this data
     187        // only changes on shrink/grow
     188        struct {
     189                // Arary of lanes
     190                __intrusive_lane_t * volatile data;
     191
     192                // Array of times
     193                __timestamp_t * volatile tscs;
     194
     195                __cache_id_t * volatile caches;
     196
     197                // Array of stats
     198                __help_cnts_t * volatile help;
     199
     200                // Number of lanes (empty or not)
     201                volatile size_t count;
     202        } lanes;
     203};
     204
     205void  ?{}(__ready_queue_t & this);
     206void ^?{}(__ready_queue_t & this);
     207#if !defined(__CFA_NO_STATISTICS__)
     208        unsigned cnt(const __ready_queue_t & this, unsigned idx);
     209#endif
    188210
    189211// Idle Sleep
     
    211233// Cluster
    212234struct __attribute__((aligned(128))) cluster {
    213         struct {
    214                 struct {
    215                         // Arary of subqueues
    216                         __intrusive_lane_t * data;
    217 
    218                         // Time since subqueues were processed
    219                         __timestamp_t * tscs;
    220 
    221                         // Number of subqueue / timestamps
    222                         size_t count;
    223                 } readyQ;
    224 
    225                 struct {
    226                         // Array of $io_
    227                         $io_context ** data;
    228 
    229                         // Time since subqueues were processed
    230                         __timestamp_t * tscs;
    231 
    232                         // Number of I/O subqueues
    233                         size_t count;
    234                 } io;
    235 
    236                 // Cache each kernel thread belongs to
    237                 __cache_id_t * caches;
    238         } sched;
    239 
    240         // // Ready queue for threads
    241         // __ready_queue_t ready_queue;
     235        // Ready queue for threads
     236        __ready_queue_t ready_queue;
    242237
    243238        // Name of the cluster
Note: See TracChangeset for help on using the changeset viewer.