Changeset 320ec6fc
- Timestamp:
- Jul 24, 2020, 1:11:39 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 39fc03e
- Parents:
- f4ec4a90
- Location:
- libcfa/src/concurrency
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/kernel.cfa
rf4ec4a90 r320ec6fc 242 242 #endif 243 243 244 __atomic_fetch_add( &cltr->nprocessors, 1u, __ATOMIC_SEQ_CST );244 int target = __atomic_add_fetch( &cltr->nprocessors, 1u, __ATOMIC_SEQ_CST ); 245 245 246 246 id = doregister((__processor_id_t*)&this); … … 250 250 251 251 // Adjust the ready queue size 252 ready_queue_grow( cltr );252 ready_queue_grow( cltr, target ); 253 253 254 254 // Unlock the RWlock … … 260 260 // Not a ctor, it just preps the destruction but should not destroy members 261 261 void deinit(processor & this) { 262 263 int target = __atomic_sub_fetch( &this.cltr->nprocessors, 1u, __ATOMIC_SEQ_CST ); 264 262 265 // Lock the RWlock so no-one pushes/pops while we are changing the queue 263 266 uint_fast32_t last_size = ready_mutate_lock(); 264 267 265 268 // Adjust the ready queue size 266 ready_queue_shrink( this.cltr );269 ready_queue_shrink( this.cltr, target ); 267 270 268 271 // Make sure we aren't on the idle queue … … 305 308 306 309 deinit( this ); 307 308 __atomic_fetch_sub( &cltr->nprocessors, 1u, __ATOMIC_SEQ_CST );309 310 } 310 311 … … 936 937 937 938 /* paranoid */ verify( this.do_terminate == true ); 938 __atomic_fetch_sub( &cltr->nprocessors, 1u, __ATOMIC_SEQ_CST );939 939 __cfaabi_dbg_print_safe("Kernel : destroyed main processor context %p\n", &runner); 940 940 } -
libcfa/src/concurrency/kernel_private.hfa
rf4ec4a90 r320ec6fc 274 274 //----------------------------------------------------------------------- 275 275 // Increase the width of the ready queue (number of lanes) by 4 276 void ready_queue_grow (struct cluster * cltr );276 void ready_queue_grow (struct cluster * cltr, int target); 277 277 278 278 //----------------------------------------------------------------------- 279 279 // Decrease the width of the ready queue (number of lanes) by 4 280 void ready_queue_shrink(struct cluster * cltr );280 void ready_queue_shrink(struct cluster * cltr, int target); 281 281 282 282 //----------------------------------------------------------------------- -
libcfa/src/concurrency/ready_queue.cfa
rf4ec4a90 r320ec6fc 37 37 #endif 38 38 39 #define BIAS 6439 #define BIAS 16 40 40 41 41 // returns the maximum number of processors the RWLock support … … 500 500 501 501 // Grow the ready queue 502 void ready_queue_grow (struct cluster * cltr ) {502 void ready_queue_grow (struct cluster * cltr, int target) { 503 503 /* paranoid */ verify( ready_mutate_islocked() ); 504 504 __cfadbg_print_safe(ready_queue, "Kernel : Growing ready queue\n"); … … 515 515 // increase count 516 516 ncount += 4; 517 /* paranoid */ verify( ncount == target * 4 || target < 2 ); 517 518 518 519 // Allocate new array (uses realloc and memcpies the data) … … 550 551 551 552 // Shrink the ready queue 552 void ready_queue_shrink(struct cluster * cltr ) {553 void ready_queue_shrink(struct cluster * cltr, int target) { 553 554 /* paranoid */ verify( ready_mutate_islocked() ); 554 555 __cfadbg_print_safe(ready_queue, "Kernel : Shrinking ready queue\n"); … … 566 567 // reduce the actual count so push doesn't use the old queues 567 568 lanes.count -= 4; 568 verify(ocount > lanes.count); 569 /* paranoid */ verify( ocount > lanes.count ); 570 /* paranoid */ verify( lanes.count == target * 4 || target < 2 ); 569 571 570 572 // for printing count the number of displaced threads -
libcfa/src/concurrency/snzi.hfa
rf4ec4a90 r320ec6fc 148 148 149 149 static inline void arrive( __snzi_t & this, int idx) { 150 idx >>= 2; 150 151 idx &= this.mask; 151 152 arrive( this.nodes[idx] ); … … 153 154 154 155 static inline void depart( __snzi_t & this, int idx) { 156 idx >>= 2; 155 157 idx &= this.mask; 156 158 depart( this.nodes[idx] );
Note: See TracChangeset
for help on using the changeset viewer.