[75f3522] | 1 | // |
---|
| 2 | // Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo |
---|
| 3 | // |
---|
| 4 | // The contents of this file are covered under the licence agreement in the |
---|
| 5 | // file "LICENCE" distributed with Cforall. |
---|
| 6 | // |
---|
[708ae38] | 7 | // kernel/private.hfa -- |
---|
[75f3522] | 8 | // |
---|
| 9 | // Author : Thierry Delisle |
---|
| 10 | // Created On : Mon Feb 13 12:27:26 2017 |
---|
[6b0b624] | 11 | // Last Modified By : Peter A. Buhr |
---|
[fd9b524] | 12 | // Last Modified On : Wed Aug 12 08:21:33 2020 |
---|
| 13 | // Update Count : 9 |
---|
[75f3522] | 14 | // |
---|
| 15 | |
---|
[6b0b624] | 16 | #pragma once |
---|
[75f3522] | 17 | |
---|
[3489ea6] | 18 | #if !defined(__cforall_thread__) |
---|
[708ae38] | 19 | #error kernel/private.hfa should only be included in libcfathread source |
---|
[3489ea6] | 20 | #endif |
---|
| 21 | |
---|
[9cd5bd2] | 22 | #include <signal.h> |
---|
| 23 | |
---|
[58b6d1b] | 24 | #include "kernel.hfa" |
---|
| 25 | #include "thread.hfa" |
---|
[75f3522] | 26 | |
---|
[73abe95] | 27 | #include "alarm.hfa" |
---|
[8834751] | 28 | #include "stats.hfa" |
---|
[fa21ac9] | 29 | |
---|
[3489ea6] | 30 | extern "C" { |
---|
| 31 | #if defined(CFA_HAVE_LINUX_LIBRSEQ) |
---|
| 32 | #include <rseq/rseq.h> |
---|
| 33 | #elif defined(CFA_HAVE_LINUX_RSEQ_H) |
---|
[f558b5f] | 34 | #include <linux/rseq.h> |
---|
[3489ea6] | 35 | #else |
---|
| 36 | #ifndef _GNU_SOURCE |
---|
[708ae38] | 37 | #error kernel/private requires gnu_source |
---|
[3489ea6] | 38 | #endif |
---|
| 39 | #include <sched.h> |
---|
| 40 | #endif |
---|
| 41 | } |
---|
| 42 | |
---|
[31c967b] | 43 | // #define READYQ_USE_LINEAR_AVG |
---|
| 44 | #define READYQ_USE_LOGDBL_AVG |
---|
| 45 | // #define READYQ_USE_LOGINT_AVG |
---|
| 46 | |
---|
| 47 | #if defined(READYQ_USE_LINEAR_AVG) |
---|
| 48 | typedef unsigned long long __readyQ_avg_t; |
---|
| 49 | #elif defined(READYQ_USE_LOGDBL_AVG) |
---|
| 50 | typedef double __readyQ_avg_t; |
---|
| 51 | #elif defined(READYQ_USE_LOGDBL_AVG) |
---|
| 52 | typedef unsigned long long __readyQ_avg_t; |
---|
| 53 | #else |
---|
| 54 | #error must pick a scheme for averaging |
---|
| 55 | #endif |
---|
[059ad16] | 56 | |
---|
[95dab9e] | 57 | extern "C" { |
---|
| 58 | __attribute__((visibility("protected"))) int __cfaabi_pthread_create(pthread_t *_thread, const pthread_attr_t *attr, void *(*start_routine) (void *), void *arg); |
---|
| 59 | __attribute__((visibility("protected"))) int __cfaabi_pthread_join(pthread_t _thread, void **retval); |
---|
| 60 | __attribute__((visibility("protected"))) pthread_t __cfaabi_pthread_self(void); |
---|
| 61 | __attribute__((visibility("protected"))) int __cfaabi_pthread_attr_init(pthread_attr_t *attr); |
---|
| 62 | __attribute__((visibility("protected"))) int __cfaabi_pthread_attr_destroy(pthread_attr_t *attr); |
---|
| 63 | __attribute__((visibility("protected"))) int __cfaabi_pthread_attr_setstack( pthread_attr_t *attr, void *stackaddr, size_t stacksize ); |
---|
| 64 | __attribute__((visibility("protected"))) int __cfaabi_pthread_attr_getstacksize( const pthread_attr_t *attr, size_t *stacksize ); |
---|
| 65 | __attribute__((visibility("protected"))) int __cfaabi_pthread_sigqueue(pthread_t _thread, int sig, const union sigval value); |
---|
| 66 | __attribute__((visibility("protected"))) int __cfaabi_pthread_sigmask( int how, const sigset_t *set, sigset_t *oset); |
---|
| 67 | } |
---|
| 68 | |
---|
[75f3522] | 69 | //----------------------------------------------------------------------------- |
---|
| 70 | // Scheduler |
---|
[31c967b] | 71 | union __attribute__((aligned(64))) __timestamp_t { |
---|
| 72 | struct { |
---|
| 73 | volatile unsigned long long tv; |
---|
| 74 | volatile __readyQ_avg_t ma; |
---|
| 75 | } t; |
---|
| 76 | char __padding[192]; |
---|
| 77 | }; |
---|
| 78 | |
---|
[1c273d0] | 79 | extern "C" { |
---|
[2026bb6] | 80 | void disable_interrupts() OPTIONAL_THREAD; |
---|
[a3821fa] | 81 | void enable_interrupts( bool poll = true ); |
---|
[1c273d0] | 82 | } |
---|
| 83 | |
---|
[24e321c] | 84 | void schedule_thread$( thread$ *, unpark_hint hint ) __attribute__((nonnull (1))); |
---|
[75f3522] | 85 | |
---|
[8fc652e0] | 86 | extern bool __preemption_enabled(); |
---|
| 87 | |
---|
[13fdf86] | 88 | enum { |
---|
| 89 | PREEMPT_NORMAL = 0, |
---|
| 90 | PREEMPT_TERMINATE = 1, |
---|
| 91 | PREEMPT_IO = 2, |
---|
| 92 | }; |
---|
| 93 | |
---|
[7d0ebd0] | 94 | static inline void __disable_interrupts_checked() { |
---|
| 95 | /* paranoid */ verify( __preemption_enabled() ); |
---|
| 96 | disable_interrupts(); |
---|
| 97 | /* paranoid */ verify( ! __preemption_enabled() ); |
---|
| 98 | } |
---|
| 99 | |
---|
| 100 | static inline void __enable_interrupts_checked( bool poll = true ) { |
---|
| 101 | /* paranoid */ verify( ! __preemption_enabled() ); |
---|
| 102 | enable_interrupts( poll ); |
---|
| 103 | /* paranoid */ verify( __preemption_enabled() ); |
---|
| 104 | } |
---|
| 105 | |
---|
[5afb49a] | 106 | //release/wake-up the following resources |
---|
[e84ab3d] | 107 | void __thread_finish( thread$ * thrd ); |
---|
[db6f06a] | 108 | |
---|
[3489ea6] | 109 | //----------------------------------------------------------------------------- |
---|
| 110 | // Hardware |
---|
| 111 | |
---|
| 112 | #if defined(CFA_HAVE_LINUX_LIBRSEQ) |
---|
| 113 | // No data needed |
---|
| 114 | #elif defined(CFA_HAVE_LINUX_RSEQ_H) |
---|
| 115 | extern "Cforall" { |
---|
[1bcbf02] | 116 | extern __attribute__((aligned(64))) __thread volatile struct rseq __cfaabi_rseq; |
---|
[3489ea6] | 117 | } |
---|
| 118 | #else |
---|
| 119 | // No data needed |
---|
| 120 | #endif |
---|
| 121 | |
---|
| 122 | static inline int __kernel_getcpu() { |
---|
| 123 | /* paranoid */ verify( ! __preemption_enabled() ); |
---|
| 124 | #if defined(CFA_HAVE_LINUX_LIBRSEQ) |
---|
[f558b5f] | 125 | return rseq_current_cpu(); |
---|
[3489ea6] | 126 | #elif defined(CFA_HAVE_LINUX_RSEQ_H) |
---|
[f558b5f] | 127 | int r = __cfaabi_rseq.cpu_id; |
---|
| 128 | /* paranoid */ verify( r >= 0 ); |
---|
| 129 | return r; |
---|
[3489ea6] | 130 | #else |
---|
| 131 | return sched_getcpu(); |
---|
| 132 | #endif |
---|
| 133 | } |
---|
| 134 | |
---|
[75f3522] | 135 | //----------------------------------------------------------------------------- |
---|
| 136 | // Processor |
---|
[c18bf9e] | 137 | void main(processorCtx_t &); |
---|
| 138 | static inline coroutine$* get_coroutine(processorCtx_t & this) { return &this.self; } |
---|
[85b1deb] | 139 | |
---|
[8c50aed] | 140 | void * __create_pthread( pthread_t *, void * (*)(void *), void * ); |
---|
[bfcf6b9] | 141 | void __destroy_pthread( pthread_t pthread, void * stack, void ** retval ); |
---|
[1805b1b] | 142 | |
---|
[6502a2b] | 143 | extern cluster * mainCluster; |
---|
| 144 | |
---|
[75f3522] | 145 | //----------------------------------------------------------------------------- |
---|
| 146 | // Threads |
---|
| 147 | extern "C" { |
---|
[c7a900a] | 148 | void __cfactx_invoke_thread(void (*main)(void *), void * this); |
---|
[75f3522] | 149 | } |
---|
| 150 | |
---|
[f7d6bb0] | 151 | __cfaabi_dbg_debug_do( |
---|
[e84ab3d] | 152 | extern void __cfaabi_dbg_thread_register ( thread$ * thrd ); |
---|
| 153 | extern void __cfaabi_dbg_thread_unregister( thread$ * thrd ); |
---|
[f7d6bb0] | 154 | ) |
---|
| 155 | |
---|
[6a77224] | 156 | #define TICKET_BLOCKED (-1) // thread is blocked |
---|
| 157 | #define TICKET_RUNNING ( 0) // thread is running |
---|
| 158 | #define TICKET_UNBLOCK ( 1) // thread should ignore next block |
---|
[28372f7] | 159 | #define TICKET_DEAD (0xDEAD) // thread should never be unparked |
---|
[6a77224] | 160 | |
---|
[969b3fe] | 161 | //----------------------------------------------------------------------------- |
---|
| 162 | // Utils |
---|
[e84ab3d] | 163 | void doregister( struct cluster * cltr, struct thread$ & thrd ); |
---|
| 164 | void unregister( struct cluster * cltr, struct thread$ & thrd ); |
---|
[de94a60] | 165 | |
---|
[f00b26d4] | 166 | //----------------------------------------------------------------------------- |
---|
| 167 | // I/O |
---|
[8bee858] | 168 | io_arbiter$ * create(void); |
---|
| 169 | void destroy(io_arbiter$ *); |
---|
[f00b26d4] | 170 | |
---|
[7768b8d] | 171 | //======================================================================= |
---|
| 172 | // Cluster lock API |
---|
| 173 | //======================================================================= |
---|
| 174 | // Lock-Free registering/unregistering of threads |
---|
| 175 | // Register a processor to a given cluster and get its unique id in return |
---|
[c993b15] | 176 | unsigned register_proc_id( void ); |
---|
[7768b8d] | 177 | |
---|
| 178 | // Unregister a processor from a given cluster using its id, getting back the original pointer |
---|
[c993b15] | 179 | void unregister_proc_id( unsigned ); |
---|
[7768b8d] | 180 | |
---|
| 181 | //======================================================================= |
---|
| 182 | // Reader-writer lock implementation |
---|
| 183 | // Concurrent with doregister/unregister, |
---|
| 184 | // i.e., threads can be added at any point during or between the entry/exit |
---|
[dca5802] | 185 | |
---|
| 186 | //----------------------------------------------------------------------- |
---|
| 187 | // simple spinlock underlying the RWLock |
---|
| 188 | // Blocking acquire |
---|
[7768b8d] | 189 | static inline void __atomic_acquire(volatile bool * ll) { |
---|
[2284d20] | 190 | /* paranoid */ verify( ! __preemption_enabled() ); |
---|
| 191 | /* paranoid */ verify(ll); |
---|
| 192 | |
---|
[7768b8d] | 193 | while( __builtin_expect(__atomic_exchange_n(ll, (bool)true, __ATOMIC_SEQ_CST), false) ) { |
---|
| 194 | while(__atomic_load_n(ll, (int)__ATOMIC_RELAXED)) |
---|
[fd9b524] | 195 | Pause(); |
---|
[7768b8d] | 196 | } |
---|
| 197 | /* paranoid */ verify(*ll); |
---|
[2284d20] | 198 | /* paranoid */ verify( ! __preemption_enabled() ); |
---|
[7768b8d] | 199 | } |
---|
| 200 | |
---|
[dca5802] | 201 | // Non-Blocking acquire |
---|
[7768b8d] | 202 | static inline bool __atomic_try_acquire(volatile bool * ll) { |
---|
[2284d20] | 203 | /* paranoid */ verify( ! __preemption_enabled() ); |
---|
| 204 | /* paranoid */ verify(ll); |
---|
| 205 | |
---|
[b798713] | 206 | return !__atomic_exchange_n(ll, (bool)true, __ATOMIC_SEQ_CST); |
---|
[7768b8d] | 207 | } |
---|
| 208 | |
---|
[dca5802] | 209 | // Release |
---|
[7768b8d] | 210 | static inline void __atomic_unlock(volatile bool * ll) { |
---|
[2284d20] | 211 | /* paranoid */ verify( ! __preemption_enabled() ); |
---|
| 212 | /* paranoid */ verify(ll); |
---|
[7768b8d] | 213 | /* paranoid */ verify(*ll); |
---|
| 214 | __atomic_store_n(ll, (bool)false, __ATOMIC_RELEASE); |
---|
| 215 | } |
---|
| 216 | |
---|
[b388ee81] | 217 | //----------------------------------------------------------------------- |
---|
| 218 | // Reader-Writer lock protecting the ready-queues |
---|
| 219 | // while this lock is mostly generic some aspects |
---|
| 220 | // have been hard-coded to for the ready-queue for |
---|
| 221 | // simplicity and performance |
---|
[741e22c] | 222 | union __attribute__((aligned(64))) __scheduler_RWLock_t { |
---|
| 223 | struct { |
---|
[cd3fc46] | 224 | __attribute__((aligned(64))) char padding; |
---|
| 225 | |
---|
[741e22c] | 226 | // total cachelines allocated |
---|
[cd3fc46] | 227 | __attribute__((aligned(64))) unsigned int max; |
---|
[b388ee81] | 228 | |
---|
[741e22c] | 229 | // cachelines currently in use |
---|
| 230 | volatile unsigned int alloc; |
---|
[b388ee81] | 231 | |
---|
[741e22c] | 232 | // cachelines ready to itereate over |
---|
| 233 | // (!= to alloc when thread is in second half of doregister) |
---|
| 234 | volatile unsigned int ready; |
---|
[b388ee81] | 235 | |
---|
[741e22c] | 236 | // writer lock |
---|
| 237 | volatile bool write_lock; |
---|
[b388ee81] | 238 | |
---|
[741e22c] | 239 | // data pointer |
---|
| 240 | volatile bool * volatile * data; |
---|
| 241 | } lock; |
---|
| 242 | char pad[192]; |
---|
[b388ee81] | 243 | }; |
---|
| 244 | |
---|
| 245 | void ?{}(__scheduler_RWLock_t & this); |
---|
| 246 | void ^?{}(__scheduler_RWLock_t & this); |
---|
| 247 | |
---|
[cd3fc46] | 248 | extern __scheduler_RWLock_t __scheduler_lock; |
---|
[b388ee81] | 249 | |
---|
[7768b8d] | 250 | //----------------------------------------------------------------------- |
---|
| 251 | // Reader side : acquire when using the ready queue to schedule but not |
---|
| 252 | // creating/destroying queues |
---|
[cd3fc46] | 253 | static inline void ready_schedule_lock(void) with(__scheduler_lock.lock) { |
---|
[8fc652e0] | 254 | /* paranoid */ verify( ! __preemption_enabled() ); |
---|
[c993b15] | 255 | /* paranoid */ verify( ! kernelTLS().in_sched_lock ); |
---|
| 256 | /* paranoid */ verify( data[kernelTLS().sched_id] == &kernelTLS().sched_lock ); |
---|
| 257 | /* paranoid */ verify( !kernelTLS().this_processor || kernelTLS().this_processor->unique_id == kernelTLS().sched_id ); |
---|
[7768b8d] | 258 | |
---|
| 259 | // Step 1 : make sure no writer are in the middle of the critical section |
---|
[c993b15] | 260 | while(__atomic_load_n(&write_lock, (int)__ATOMIC_RELAXED)) |
---|
[fd9b524] | 261 | Pause(); |
---|
[7768b8d] | 262 | |
---|
| 263 | // Fence needed because we don't want to start trying to acquire the lock |
---|
| 264 | // before we read a false. |
---|
| 265 | // Not needed on x86 |
---|
| 266 | // std::atomic_thread_fence(std::memory_order_seq_cst); |
---|
| 267 | |
---|
| 268 | // Step 2 : acquire our local lock |
---|
[c993b15] | 269 | __atomic_acquire( &kernelTLS().sched_lock ); |
---|
| 270 | /*paranoid*/ verify(kernelTLS().sched_lock); |
---|
[64a7146] | 271 | |
---|
| 272 | #ifdef __CFA_WITH_VERIFY__ |
---|
| 273 | // Debug, check if this is owned for reading |
---|
[c993b15] | 274 | kernelTLS().in_sched_lock = true; |
---|
[64a7146] | 275 | #endif |
---|
[7768b8d] | 276 | } |
---|
| 277 | |
---|
[cd3fc46] | 278 | static inline void ready_schedule_unlock(void) with(__scheduler_lock.lock) { |
---|
[8fc652e0] | 279 | /* paranoid */ verify( ! __preemption_enabled() ); |
---|
[c993b15] | 280 | /* paranoid */ verify( data[kernelTLS().sched_id] == &kernelTLS().sched_lock ); |
---|
| 281 | /* paranoid */ verify( !kernelTLS().this_processor || kernelTLS().this_processor->unique_id == kernelTLS().sched_id ); |
---|
| 282 | /* paranoid */ verify( kernelTLS().sched_lock ); |
---|
| 283 | /* paranoid */ verify( kernelTLS().in_sched_lock ); |
---|
[64a7146] | 284 | #ifdef __CFA_WITH_VERIFY__ |
---|
| 285 | // Debug, check if this is owned for reading |
---|
[c993b15] | 286 | kernelTLS().in_sched_lock = false; |
---|
[64a7146] | 287 | #endif |
---|
[c993b15] | 288 | __atomic_unlock(&kernelTLS().sched_lock); |
---|
[7768b8d] | 289 | } |
---|
| 290 | |
---|
[64a7146] | 291 | #ifdef __CFA_WITH_VERIFY__ |
---|
[e873838] | 292 | static inline bool ready_schedule_islocked(void) { |
---|
[8fc652e0] | 293 | /* paranoid */ verify( ! __preemption_enabled() ); |
---|
[c993b15] | 294 | /* paranoid */ verify( (!kernelTLS().in_sched_lock) || kernelTLS().sched_lock ); |
---|
| 295 | return kernelTLS().sched_lock; |
---|
[64a7146] | 296 | } |
---|
| 297 | |
---|
| 298 | static inline bool ready_mutate_islocked() { |
---|
[cd3fc46] | 299 | return __scheduler_lock.lock.write_lock; |
---|
[64a7146] | 300 | } |
---|
| 301 | #endif |
---|
| 302 | |
---|
[7768b8d] | 303 | //----------------------------------------------------------------------- |
---|
| 304 | // Writer side : acquire when changing the ready queue, e.g. adding more |
---|
| 305 | // queues or removing them. |
---|
[b388ee81] | 306 | uint_fast32_t ready_mutate_lock( void ); |
---|
[7768b8d] | 307 | |
---|
[b388ee81] | 308 | void ready_mutate_unlock( uint_fast32_t /* value returned by lock */ ); |
---|
[7768b8d] | 309 | |
---|
[a33c113] | 310 | //----------------------------------------------------------------------- |
---|
| 311 | // Lock-Free registering/unregistering of threads |
---|
| 312 | // Register a processor to a given cluster and get its unique id in return |
---|
| 313 | // For convenience, also acquires the lock |
---|
[c993b15] | 314 | static inline [unsigned, uint_fast32_t] ready_mutate_register() { |
---|
| 315 | unsigned id = register_proc_id(); |
---|
| 316 | uint_fast32_t last = ready_mutate_lock(); |
---|
| 317 | return [id, last]; |
---|
[a33c113] | 318 | } |
---|
| 319 | |
---|
| 320 | // Unregister a processor from a given cluster using its id, getting back the original pointer |
---|
| 321 | // assumes the lock is acquired |
---|
[c993b15] | 322 | static inline void ready_mutate_unregister( unsigned id, uint_fast32_t last_s ) { |
---|
[a33c113] | 323 | ready_mutate_unlock( last_s ); |
---|
[c993b15] | 324 | unregister_proc_id( id ); |
---|
[a33c113] | 325 | } |
---|
| 326 | |
---|
[a7504db] | 327 | //----------------------------------------------------------------------- |
---|
| 328 | // Cluster idle lock/unlock |
---|
[6a9b12b] | 329 | static inline void lock(__cluster_proc_list & this) { |
---|
[a7504db] | 330 | /* paranoid */ verify( ! __preemption_enabled() ); |
---|
| 331 | |
---|
| 332 | // Start by locking the global RWlock so that we know no-one is |
---|
| 333 | // adding/removing processors while we mess with the idle lock |
---|
| 334 | ready_schedule_lock(); |
---|
| 335 | |
---|
[a633f6f] | 336 | lock( this.lock __cfaabi_dbg_ctx2 ); |
---|
[a7504db] | 337 | |
---|
| 338 | /* paranoid */ verify( ! __preemption_enabled() ); |
---|
| 339 | } |
---|
| 340 | |
---|
[5f5a729] | 341 | static inline bool try_lock(__cluster_proc_list & this) { |
---|
| 342 | /* paranoid */ verify( ! __preemption_enabled() ); |
---|
| 343 | |
---|
| 344 | // Start by locking the global RWlock so that we know no-one is |
---|
| 345 | // adding/removing processors while we mess with the idle lock |
---|
| 346 | ready_schedule_lock(); |
---|
| 347 | |
---|
[a633f6f] | 348 | if(try_lock( this.lock __cfaabi_dbg_ctx2 )) { |
---|
[5f5a729] | 349 | // success |
---|
| 350 | /* paranoid */ verify( ! __preemption_enabled() ); |
---|
| 351 | return true; |
---|
| 352 | } |
---|
| 353 | |
---|
| 354 | // failed to lock |
---|
| 355 | ready_schedule_unlock(); |
---|
| 356 | |
---|
| 357 | /* paranoid */ verify( ! __preemption_enabled() ); |
---|
| 358 | return false; |
---|
| 359 | } |
---|
| 360 | |
---|
[6a9b12b] | 361 | static inline void unlock(__cluster_proc_list & this) { |
---|
[a7504db] | 362 | /* paranoid */ verify( ! __preemption_enabled() ); |
---|
| 363 | |
---|
[a633f6f] | 364 | unlock(this.lock); |
---|
[a7504db] | 365 | |
---|
| 366 | // Release the global lock, which we acquired when locking |
---|
| 367 | ready_schedule_unlock(); |
---|
| 368 | |
---|
| 369 | /* paranoid */ verify( ! __preemption_enabled() ); |
---|
| 370 | } |
---|
| 371 | |
---|
[b798713] | 372 | //======================================================================= |
---|
| 373 | // Ready-Queue API |
---|
[dca5802] | 374 | //----------------------------------------------------------------------- |
---|
| 375 | // push thread onto a ready queue for a cluster |
---|
| 376 | // returns true if the list was previously empty, false otherwise |
---|
[24e321c] | 377 | __attribute__((hot)) void push(struct cluster * cltr, struct thread$ * thrd, unpark_hint hint); |
---|
[dca5802] | 378 | |
---|
| 379 | //----------------------------------------------------------------------- |
---|
[fc59df78] | 380 | // pop thread from the local queues of a cluster |
---|
[dca5802] | 381 | // returns 0p if empty |
---|
[1eb239e4] | 382 | // May return 0p spuriously |
---|
[e84ab3d] | 383 | __attribute__((hot)) struct thread$ * pop_fast(struct cluster * cltr); |
---|
[dca5802] | 384 | |
---|
[1eb239e4] | 385 | //----------------------------------------------------------------------- |
---|
[fc59df78] | 386 | // pop thread from any ready queue of a cluster |
---|
[1eb239e4] | 387 | // returns 0p if empty |
---|
[fc59df78] | 388 | // May return 0p spuriously |
---|
[e84ab3d] | 389 | __attribute__((hot)) struct thread$ * pop_slow(struct cluster * cltr); |
---|
[1eb239e4] | 390 | |
---|
[fc59df78] | 391 | //----------------------------------------------------------------------- |
---|
| 392 | // search all ready queues of a cluster for any thread |
---|
| 393 | // returns 0p if empty |
---|
| 394 | // guaranteed to find any threads added before this call |
---|
[e84ab3d] | 395 | __attribute__((hot)) struct thread$ * pop_search(struct cluster * cltr); |
---|
[fc59df78] | 396 | |
---|
[24e321c] | 397 | //----------------------------------------------------------------------- |
---|
| 398 | // get preferred ready for new thread |
---|
| 399 | unsigned ready_queue_new_preferred(); |
---|
| 400 | |
---|
[dca5802] | 401 | //----------------------------------------------------------------------- |
---|
| 402 | // Increase the width of the ready queue (number of lanes) by 4 |
---|
[a017ee7] | 403 | void ready_queue_grow (struct cluster * cltr); |
---|
[dca5802] | 404 | |
---|
| 405 | //----------------------------------------------------------------------- |
---|
| 406 | // Decrease the width of the ready queue (number of lanes) by 4 |
---|
[a017ee7] | 407 | void ready_queue_shrink(struct cluster * cltr); |
---|
[b798713] | 408 | |
---|
[884f3f67] | 409 | //----------------------------------------------------------------------- |
---|
| 410 | // Decrease the width of the ready queue (number of lanes) by 4 |
---|
| 411 | void ready_queue_close(struct cluster * cltr); |
---|
| 412 | |
---|
[75f3522] | 413 | // Local Variables: // |
---|
| 414 | // mode: c // |
---|
| 415 | // tab-width: 4 // |
---|
[4aa2fb2] | 416 | // End: // |
---|