Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/concurrency/kernel

    rde94a60 r14a61b5  
    4040
    4141//-----------------------------------------------------------------------------
     42// Cluster
     43struct cluster {
     44        // Ready queue locks
     45        __spinlock_t ready_queue_lock;
     46
     47        // Ready queue for threads
     48        __queue_t(thread_desc) ready_queue;
     49
     50        // Name of the cluster
     51        const char * name;
     52
     53        // Preemption rate on this cluster
     54        Duration preemption_rate;
     55
     56        // List of idle processors
     57        // __dllist_t(struct processor) idles;
     58};
     59
     60extern struct cluster * mainCluster;
     61extern Duration default_preemption();
     62
     63void ?{} (cluster & this, const char * name, Duration preemption_rate);
     64void ^?{}(cluster & this);
     65
     66static inline void ?{} (cluster & this)                           { this{"Anonymous Cluster", default_preemption()}; }
     67static inline void ?{} (cluster & this, Duration preemption_rate) { this{"Anonymous Cluster", preemption_rate}; }
     68static inline void ?{} (cluster & this, const char * name)        { this{name, default_preemption()}; }
     69
     70//-----------------------------------------------------------------------------
    4271// Processor
    43 extern struct cluster * mainCluster;
    44 
    4572enum FinishOpCode { No_Action, Release, Schedule, Release_Schedule, Release_Multi, Release_Multi_Schedule };
    4673
     
    74101
    75102        // Cluster from which to get threads
    76         struct cluster * cltr;
     103        cluster * cltr;
    77104
    78105        // Name of the processor
     
    100127        bool pending_preemption;
    101128
    102         // Idle lock
    103 
    104         // Link lists fields
    105129        struct {
    106                 struct processor * next;
    107                 struct processor * prev;
    108         } node;
     130                pthread_mutex_t lock;
     131                pthread_cond_t  cond;
     132        } idle;
    109133
    110134#ifdef __CFA_DEBUG__
     
    114138};
    115139
    116 void  ?{}(processor & this, const char * name, struct cluster & cltr);
     140void  ?{}(processor & this, const char * name, cluster & cltr);
    117141void ^?{}(processor & this);
    118142
    119143static inline void  ?{}(processor & this)                    { this{ "Anonymous Processor", *mainCluster}; }
    120 static inline void  ?{}(processor & this, struct cluster & cltr)    { this{ "Anonymous Processor", cltr}; }
     144static inline void  ?{}(processor & this, cluster & cltr)    { this{ "Anonymous Processor", cltr}; }
    121145static inline void  ?{}(processor & this, const char * name) { this{name, *mainCluster }; }
    122 
    123 static inline [processor *&, processor *& ] __get( processor & this ) {
    124         return this.node.[next, prev];
    125 }
    126 
    127 //-----------------------------------------------------------------------------
    128 // Cluster
    129 struct cluster {
    130         // Ready queue locks
    131         __spinlock_t ready_queue_lock;
    132 
    133         // Ready queue for threads
    134         __queue_t(thread_desc) ready_queue;
    135 
    136         // Name of the cluster
    137         const char * name;
    138 
    139         // Preemption rate on this cluster
    140         Duration preemption_rate;
    141 
    142         // List of processors
    143         __spinlock_t proc_list_lock;
    144         __dllist_t(struct processor) procs;
    145         __dllist_t(struct processor) idles;
    146 
    147         // Link lists fields
    148         struct {
    149                 cluster * next;
    150                 cluster * prev;
    151         } node;
    152 };
    153 extern Duration default_preemption();
    154 
    155 void ?{} (cluster & this, const char * name, Duration preemption_rate);
    156 void ^?{}(cluster & this);
    157 
    158 static inline void ?{} (cluster & this)                           { this{"Anonymous Cluster", default_preemption()}; }
    159 static inline void ?{} (cluster & this, Duration preemption_rate) { this{"Anonymous Cluster", preemption_rate}; }
    160 static inline void ?{} (cluster & this, const char * name)        { this{name, default_preemption()}; }
    161 
    162 static inline [cluster *&, cluster *& ] __get( cluster & this ) {
    163         return this.node.[next, prev];
    164 }
    165146
    166147// Local Variables: //
Note: See TracChangeset for help on using the changeset viewer.