- File:
-
- 1 edited
-
libcfa/src/concurrency/kernel.hfa (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/kernel.hfa
r504a7dc r71c8b7e 60 60 // Cluster from which to get threads 61 61 struct cluster * cltr; 62 unsigned int id;63 62 64 63 // Name of the processor … … 93 92 94 93 // Link lists fields 95 struct __dbg_node_ cltr{96 processor * next;97 processor * prev;94 struct __dbg_node_proc { 95 struct processor * next; 96 struct processor * prev; 98 97 } node; 99 98 … … 120 119 // #define CFA_CLUSTER_IO_POLLER_KERNEL_SIDE 1 << 1 121 120 122 123 //-----------------------------------------------------------------------------124 // Cluster Tools125 126 // Cells use by the reader writer lock127 // while not generic it only relies on a opaque pointer128 struct __processor_id;129 130 // Reader-Writer lock protecting the ready-queue131 // while this lock is mostly generic some aspects132 // have been hard-coded to for the ready-queue for133 // simplicity and performance134 struct __clusterRWLock_t {135 // total cachelines allocated136 unsigned int max;137 138 // cachelines currently in use139 volatile unsigned int alloc;140 141 // cachelines ready to itereate over142 // (!= to alloc when thread is in second half of doregister)143 volatile unsigned int ready;144 145 // writer lock146 volatile bool lock;147 148 // data pointer149 __processor_id * data;150 };151 152 void ?{}(__clusterRWLock_t & this);153 void ^?{}(__clusterRWLock_t & this);154 155 // Intrusives lanes which are used by the relaxed ready queue156 struct __attribute__((aligned(128))) __intrusive_lane_t {157 // spin lock protecting the queue158 volatile bool lock;159 160 // anchor for the head and the tail of the queue161 struct __sentinel_t {162 // Link lists fields163 // instrusive link field for threads164 // must be exactly as in $thread165 __thread_desc_link link;166 } before, after;167 168 #if defined(__CFA_WITH_VERIFY__)169 // id of last processor to acquire the lock170 // needed only to check for mutual exclusion violations171 unsigned int last_id;172 173 // number of items on this list174 // needed only to check for deadlocks175 unsigned int count;176 #endif177 178 // Optional statistic counters179 #if !defined(__CFA_NO_SCHED_STATS__)180 struct __attribute__((aligned(64))) {181 // difference between number of push and pops182 ssize_t diff;183 184 // total number of pushes and pops185 size_t push;186 size_t pop ;187 } stat;188 #endif189 };190 191 void ?{}(__intrusive_lane_t & this);192 void ^?{}(__intrusive_lane_t & this);193 194 typedef unsigned long long __cfa_readyQ_mask_t;195 196 // enum {197 // __cfa_ready_queue_mask_size = (64 - sizeof(size_t)) / sizeof(size_t),198 // __cfa_max_ready_queues = __cfa_ready_queue_mask_size * 8 * sizeof(size_t)199 // };200 201 #define __cfa_lane_mask_size ((64 - sizeof(size_t)) / sizeof(__cfa_readyQ_mask_t))202 #define __cfa_max_lanes (__cfa_lane_mask_size * 8 * sizeof(__cfa_readyQ_mask_t))203 204 //TODO adjust cache size to ARCHITECTURE205 // Structure holding the relaxed ready queue206 struct __attribute__((aligned(128))) __ready_queue_t {207 // Data tracking how many/which lanes are used208 // Aligned to 128 for cache locality209 struct {210 // number of non-empty lanes211 volatile size_t count;212 213 // bit mask, set bits indentify which lanes are non-empty214 volatile __cfa_readyQ_mask_t mask[ __cfa_lane_mask_size ];215 } used;216 217 // Data tracking the actual lanes218 // On a seperate cacheline from the used struct since219 // used can change on each push/pop but this data220 // only changes on shrink/grow221 struct __attribute__((aligned(64))) {222 // Arary of lanes223 __intrusive_lane_t * volatile data;224 225 // Number of lanes (empty or not)226 volatile size_t count;227 } lanes;228 229 // Statistics230 #if !defined(__CFA_NO_STATISTICS__)231 __attribute__((aligned(64))) struct {232 struct {233 // Push statistic234 struct {235 // number of attemps at pushing something236 volatile size_t attempt;237 238 // number of successes at pushing239 volatile size_t success;240 } push;241 242 // Pop statistic243 struct {244 // number of reads of the mask245 // picking an empty __cfa_readyQ_mask_t counts here246 // but not as an attempt247 volatile size_t maskrds;248 249 // number of attemps at poping something250 volatile size_t attempt;251 252 // number of successes at poping253 volatile size_t success;254 } pop;255 } pick;256 257 // stats on the "used" struct of the queue258 // tracks average number of queues that are not empty259 // when pushing / poping260 struct {261 volatile size_t value;262 volatile size_t count;263 } used;264 } global_stats;265 266 #endif267 };268 269 void ?{}(__ready_queue_t & this);270 void ^?{}(__ready_queue_t & this);271 272 121 //----------------------------------------------------------------------------- 273 122 // Cluster 274 123 struct cluster { 275 124 // Ready queue locks 276 __ clusterRWLock_t ready_lock;125 __spinlock_t ready_queue_lock; 277 126 278 127 // Ready queue for threads 279 __ ready_queue_tready_queue;128 __queue_t($thread) ready_queue; 280 129 281 130 // Name of the cluster
Note:
See TracChangeset
for help on using the changeset viewer.