Ignore:
Timestamp:
Nov 26, 2019, 3:19:20 PM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
30763fd
Parents:
21184e3
Message:

First step at adding the new ready queue to Cforall

File:
1 edited

Legend:

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

    r21184e3 r7768b8d  
    106106        // Cluster from which to get threads
    107107        struct cluster * cltr;
     108        unsigned int id;
    108109
    109110        // Name of the processor
     
    157158}
    158159
     160
     161//-----------------------------------------------------------------------------
     162// Cluster Tools
     163struct __processor_id;
     164
     165// Reader-Writer lock protecting the ready-queue
     166struct __clusterRWLock_t {
     167        // total cachelines allocated
     168        unsigned int max;
     169
     170        // cachelines currently in use
     171        volatile unsigned int alloc;
     172
     173        // cachelines ready to itereate over
     174        // (!= to alloc when thread is in second half of doregister)
     175        volatile unsigned int ready;
     176
     177        // writer lock
     178        volatile bool lock;
     179
     180        // data pointer
     181        __processor_id * data;
     182};
     183
     184void  ?{}(__clusterRWLock_t & this);
     185void ^?{}(__clusterRWLock_t & this);
     186
     187// Underlying sub quues of the ready queue
     188struct __attribute__((aligned(128))) __intrusive_ready_queue_t {
     189        // spin lock protecting the queue
     190        volatile bool lock;
     191
     192        // anchor for the head and the tail of the queue
     193        struct __sentinel_t {
     194                struct thread_desc * next;
     195                struct thread_desc * prev;
     196                unsigned long long ts;
     197        } before, after;
     198
     199        // Optional statistic counters
     200        #ifndef __CFA_NO_SCHED_STATS__
     201                struct __attribute__((aligned(64))) {
     202                        // difference between number of push and pops
     203                        ssize_t diff;
     204
     205                        // total number of pushes and pops
     206                        size_t  push;
     207                        size_t  pop ;
     208                } stat;
     209        #endif
     210};
     211
     212void  ?{}(__intrusive_ready_queue_t & this);
     213void ^?{}(__intrusive_ready_queue_t & this);
     214
    159215//-----------------------------------------------------------------------------
    160216// Cluster
    161217struct cluster {
    162218        // Ready queue locks
    163         __spinlock_t ready_queue_lock;
     219        __clusterRWLock_t ready_lock;
    164220
    165221        // Ready queue for threads
    166         __queue_t(thread_desc) ready_queue;
     222        __intrusive_ready_queue_t ready_queue;
    167223
    168224        // Name of the cluster
     
    174230        // List of processors
    175231        __spinlock_t proc_list_lock;
    176         __dllist_t(struct processor) procs;
    177232        __dllist_t(struct processor) idles;
    178         unsigned int nprocessors;
    179233
    180234        // List of threads
Note: See TracChangeset for help on using the changeset viewer.