Changeset 8b74fa7 for libcfa/src
- Timestamp:
- Oct 27, 2022, 11:20:19 AM (2 years ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- a167c70c
- Parents:
- 878cfcc
- Location:
- libcfa/src/concurrency
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/kernel.hfa
r878cfcc r8b74fa7 160 160 // P9_EMBEDDED( processor, dlink(processor) ) 161 161 static inline tytagref( dlink(processor), dlink(processor) ) ?`inner( processor & this ) { 162 163 164 162 dlink(processor) & b = this.link; 163 tytagref( dlink(processor), dlink(processor) ) result = { b }; 164 return result; 165 165 } 166 166 … … 269 269 io_context_params params; 270 270 } io; 271 272 struct { 273 struct processor ** procs; 274 unsigned cnt; 275 } managed; 271 276 272 277 #if !defined(__CFA_NO_STATISTICS__) … … 298 303 static inline struct cluster * active_cluster () { return publicTLS_get( this_processor )->cltr; } 299 304 305 // set the number of internal processors 306 // these processors are in addition to any explicitly declared processors 307 unsigned set_concurrency( cluster & this, unsigned new_count ); 308 300 309 #if !defined(__CFA_NO_STATISTICS__) 301 310 void print_stats_now( cluster & this, int flags ); -
libcfa/src/concurrency/kernel/startup.cfa
r878cfcc r8b74fa7 16 16 #define __cforall_thread__ 17 17 #define _GNU_SOURCE 18 19 // #define __CFA_DEBUG_PRINT_RUNTIME_CORE__ 18 20 19 21 // C Includes … … 336 338 337 339 /* paranoid */ verify( this.do_terminate == true ); 338 __cfa abi_dbg_print_safe("Kernel : destroyed main processor context %p\n", &runner);340 __cfadbg_print_safe(runtime_core, "Kernel : destroyed main processor context %p\n", &runner); 339 341 } 340 342 … … 397 399 (proc->runner){ proc, &info }; 398 400 399 __cfa abi_dbg_print_safe("Coroutine : created stack %p\n", get_coroutine(proc->runner)->stack.storage);401 __cfadbg_print_safe(runtime_core, "Coroutine : created stack %p\n", get_coroutine(proc->runner)->stack.storage); 400 402 401 403 //Set global state … … 662 664 io.params = io_params; 663 665 666 managed.procs = 0p; 667 managed.cnt = 0; 668 664 669 doregister(this); 665 670 … … 677 682 678 683 void ^?{}(cluster & this) libcfa_public { 684 set_concurrency( this, 0 ); 685 679 686 destroy(this.io.arbiter); 680 687 … … 848 855 } 849 856 857 unsigned set_concurrency( cluster & this, unsigned new ) libcfa_public { 858 unsigned old = this.managed.cnt; 859 860 __cfadbg_print_safe(runtime_core, "Kernel : resizing cluster from %u to %u\n", old, (unsigned)new); 861 862 // Delete all the old unneeded procs 863 if(old > new) for(i; (unsigned)new ~ old) { 864 __cfadbg_print_safe(runtime_core, "Kernel : destroying %u\n", i); 865 delete( this.managed.procs[i] ); 866 } 867 868 // Allocate new array (uses realloc and memcpies the data) 869 this.managed.procs = alloc( new, this.managed.procs`realloc ); 870 this.managed.cnt = new; 871 872 // Create the desired new procs 873 if(old < new) for(i; old ~ new) { 874 __cfadbg_print_safe(runtime_core, "Kernel : constructing %u\n", i); 875 (*(this.managed.procs[i] = alloc())){ this }; 876 } 877 878 // return the old count 879 return old; 880 } 881 850 882 #if defined(__CFA_WITH_VERIFY__) 851 883 static bool verify_fwd_bck_rng(void) {
Note: See TracChangeset
for help on using the changeset viewer.