- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/kernel.hfa
r13c5e19 rdd4e2d7 22 22 #include "time_t.hfa" 23 23 #include "coroutine.hfa" 24 25 #include "containers/stackLockFree.hfa"26 24 27 25 extern "C" { … … 49 47 extern struct cluster * mainCluster; 50 48 51 // Processor id, required for scheduling threads 52 struct __processor_id_t { 53 unsigned id; 54 55 #if !defined(__CFA_NO_STATISTICS__) 56 struct __stats_t * stats; 57 #endif 58 }; 59 49 // Processor 60 50 coroutine processorCtx_t { 61 51 struct processor * proc; … … 63 53 64 54 // Wrapper around kernel threads 65 struct __attribute__((aligned(128)))processor {55 struct processor { 66 56 // Main state 67 inline __processor_id_t; 57 // Coroutine ctx who does keeps the state of the processor 58 struct processorCtx_t runner; 68 59 69 60 // Cluster from which to get threads 70 61 struct cluster * cltr; 71 72 // Set to true to notify the processor should terminate73 volatile bool do_terminate;74 75 // Coroutine ctx who does keeps the state of the processor76 struct processorCtx_t runner;77 62 78 63 // Name of the processor … … 96 81 __bin_sem_t idle; 97 82 83 // Termination 84 // Set to true to notify the processor should terminate 85 volatile bool do_terminate; 86 98 87 // Termination synchronisation (user semaphore) 99 88 semaphore terminated; … … 103 92 104 93 // Link lists fields 105 Link(processor) link; 94 struct __dbg_node_proc { 95 struct processor * next; 96 struct processor * prev; 97 } node; 106 98 107 99 #ifdef __CFA_DEBUG__ … … 118 110 static inline void ?{}(processor & this, const char name[]) { this{name, *mainCluster }; } 119 111 120 static inline Link(processor) * ?`next( processor * this ) { return &this->link; }112 static inline [processor *&, processor *& ] __get( processor & this ) __attribute__((const)) { return this.node.[next, prev]; } 121 113 122 114 //----------------------------------------------------------------------------- … … 129 121 #define CFA_CLUSTER_IO_BUFFLEN_OFFSET 16 130 122 131 132 //-----------------------------------------------------------------------------133 // Cluster Tools134 135 // Intrusives lanes which are used by the relaxed ready queue136 struct __attribute__((aligned(128))) __intrusive_lane_t;137 void ?{}(__intrusive_lane_t & this);138 void ^?{}(__intrusive_lane_t & this);139 140 // Counter used for wether or not the lanes are all empty141 struct __attribute__((aligned(128))) __snzi_node_t;142 struct __snzi_t {143 unsigned mask;144 int root;145 __snzi_node_t * nodes;146 };147 148 void ?{}( __snzi_t & this, unsigned depth );149 void ^?{}( __snzi_t & this );150 151 //TODO adjust cache size to ARCHITECTURE152 // Structure holding the relaxed ready queue153 struct __ready_queue_t {154 // Data tracking how many/which lanes are used155 // Aligned to 128 for cache locality156 __snzi_t snzi;157 158 // Data tracking the actual lanes159 // On a seperate cacheline from the used struct since160 // used can change on each push/pop but this data161 // only changes on shrink/grow162 struct {163 // Arary of lanes164 __intrusive_lane_t * volatile data;165 166 // Number of lanes (empty or not)167 volatile size_t count;168 } lanes;169 };170 171 void ?{}(__ready_queue_t & this);172 void ^?{}(__ready_queue_t & this);173 174 123 //----------------------------------------------------------------------------- 175 124 // Cluster 176 struct __attribute__((aligned(128))) cluster { 125 struct cluster { 126 // Ready queue locks 127 __spinlock_t ready_queue_lock; 128 177 129 // Ready queue for threads 178 __ ready_queue_tready_queue;130 __queue_t($thread) ready_queue; 179 131 180 132 // Name of the cluster … … 184 136 Duration preemption_rate; 185 137 186 // List of idle processors 187 StackLF(processor) idles; 188 volatile unsigned int nprocessors; 138 // List of processors 139 __spinlock_t idle_lock; 140 __dllist_t(struct processor) procs; 141 __dllist_t(struct processor) idles; 142 unsigned int nprocessors; 189 143 190 144 // List of threads … … 203 157 #if !defined(__CFA_NO_STATISTICS__) 204 158 bool print_stats; 205 struct __stats_t * stats;206 159 #endif 207 160 };
Note:
See TracChangeset
for help on using the changeset viewer.