Changeset cc7bbe6 for libcfa/src/concurrency
- Timestamp:
- Feb 23, 2022, 11:24:34 AM (4 years ago)
- Branches:
- ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
- Children:
- 08ed947
- Parents:
- f5a51db (diff), 3a038fa (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- libcfa/src/concurrency
- Files:
-
- 6 edited
-
io/setup.cfa (modified) (1 diff)
-
kernel.hfa (modified) (1 diff)
-
kernel/startup.cfa (modified) (4 diffs)
-
preemption.cfa (modified) (2 diffs)
-
thread.cfa (modified) (4 diffs)
-
thread.hfa (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/io/setup.cfa
rf5a51db rcc7bbe6 32 32 33 33 void __cfa_io_start( processor * proc ) {} 34 bool __cfa_io_flush( processor * proc, int ) { }34 bool __cfa_io_flush( processor * proc, int ) { return false; } 35 35 void __cfa_io_stop ( processor * proc ) {} 36 36 -
libcfa/src/concurrency/kernel.hfa
rf5a51db rcc7bbe6 173 173 174 174 static inline void ?{}(__timestamp_t & this) { this.tv = 0; this.ma = 0; } 175 static inline void ^?{}(__timestamp_t & this) {}175 static inline void ^?{}(__timestamp_t &) {} 176 176 177 177 struct __attribute__((aligned(128))) __ready_queue_caches_t; -
libcfa/src/concurrency/kernel/startup.cfa
rf5a51db rcc7bbe6 18 18 19 19 // C Includes 20 #include <errno.h> // errno20 #include <errno.h> // errno 21 21 #include <signal.h> 22 #include <string.h> // strerror23 #include <unistd.h> // sysconf22 #include <string.h> // strerror 23 #include <unistd.h> // sysconf 24 24 25 25 extern "C" { 26 #include <limits.h>// PTHREAD_STACK_MIN27 #include <unistd.h> // syscall28 #include <sys/eventfd.h> // eventfd29 #include <sys/mman.h>// mprotect30 #include <sys/resource.h>// getrlimit26 #include <limits.h> // PTHREAD_STACK_MIN 27 #include <unistd.h> // syscall 28 #include <sys/eventfd.h> // eventfd 29 #include <sys/mman.h> // mprotect 30 #include <sys/resource.h> // getrlimit 31 31 } 32 32 33 33 // CFA Includes 34 34 #include "kernel_private.hfa" 35 #include "startup.hfa" // STARTUP_PRIORITY_XXX35 #include "startup.hfa" // STARTUP_PRIORITY_XXX 36 36 #include "limits.hfa" 37 37 #include "math.hfa" … … 102 102 extern void __wake_proc(processor *); 103 103 extern int cfa_main_returned; // from interpose.cfa 104 extern uint32_t __global_random_seed;104 uint32_t __global_random_prime = 4_294_967_291u, __global_random_mask = false; 105 105 106 106 //----------------------------------------------------------------------------- … … 490 490 preferred = ready_queue_new_preferred(); 491 491 last_proc = 0p; 492 random_state = __global_random_ seed;492 random_state = __global_random_mask ? __global_random_prime : __global_random_prime ^ rdtscl(); 493 493 #if defined( __CFA_WITH_VERIFY__ ) 494 494 canary = 0x0D15EA5E0D15EA5Ep; … … 736 736 check( pthread_attr_init( &attr ), "pthread_attr_init" ); // initialize attribute 737 737 738 size_t stacksize = DEFAULT_STACK_SIZE;738 size_t stacksize = max( PTHREAD_STACK_MIN, DEFAULT_STACK_SIZE ); 739 739 740 740 void * stack; -
libcfa/src/concurrency/preemption.cfa
rf5a51db rcc7bbe6 10 10 // Created On : Mon Jun 5 14:20:42 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Nov 6 07:42:13 202013 // Update Count : 5 412 // Last Modified On : Thu Feb 17 11:18:57 2022 13 // Update Count : 59 14 14 // 15 15 … … 243 243 //---------- 244 244 // special case for preemption since used often 245 bool __preemption_enabled() {245 __attribute__((optimize("no-reorder-blocks"))) bool __preemption_enabled() { 246 246 // create a assembler label before 247 247 // marked as clobber all to avoid movement -
libcfa/src/concurrency/thread.cfa
rf5a51db rcc7bbe6 10 10 // Created On : Tue Jan 17 12:27:26 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jan 13 20:11:55202213 // Update Count : 4212 // Last Modified On : Sat Feb 12 15:24:18 2022 13 // Update Count : 66 14 14 // 15 15 … … 25 25 #include "invoke.h" 26 26 27 extern uint32_t __global_random_seed ;27 extern uint32_t __global_random_seed, __global_random_prime, __global_random_mask; 28 28 29 29 //----------------------------------------------------------------------------- … … 45 45 preferred = ready_queue_new_preferred(); 46 46 last_proc = 0p; 47 random_state = __global_random_ seed;47 random_state = __global_random_mask ? __global_random_prime : __global_random_prime ^ rdtscl(); 48 48 #if defined( __CFA_WITH_VERIFY__ ) 49 49 canary = 0x0D15EA5E0D15EA5Ep; … … 176 176 177 177 void set_seed( uint32_t seed ) { 178 active_thread()->random_state = __global_random_seed = seed; 179 GENERATOR( active_thread()->random_state ); 178 uint32_t & state = active_thread()->random_state; 179 state = __global_random_seed = seed; 180 GENERATOR( state ); 181 __global_random_prime = state; 182 __global_random_mask = true; 180 183 } // set_seed 181 uint32_t prng( void ) { return GENERATOR( active_thread()->random_state ); } // [0,UINT_MAX] 184 185 uint32_t prng( void ) { // [0,UINT_MAX] 186 uint32_t & state = active_thread()->random_state; 187 return GENERATOR( state ); 188 } // prng 182 189 183 190 // Local Variables: // -
libcfa/src/concurrency/thread.hfa
rf5a51db rcc7bbe6 10 10 // Created On : Tue Jan 17 12:27:26 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jan 6 16:40:16202213 // Update Count : 712 // Last Modified On : Fri Feb 11 16:34:07 2022 13 // Update Count : 20 14 14 // 15 15 … … 130 130 T & join( T & this ); 131 131 132 //---------- 133 // prng 134 static inline { 135 uint32_t prng( thread$ & th ) __attribute__(( warn_unused_result )) { return LCG( th.random_state ); } // [0,UINT_MAX] 136 uint32_t prng( thread$ & th, uint32_t u ) __attribute__(( warn_unused_result )) { return prng( th ) % u; } // [0,u) 137 uint32_t prng( thread$ & th, uint32_t l, uint32_t u ) __attribute__(( warn_unused_result )) { return prng( th, u - l + 1 ) + l; } // [l,u] 138 forall( T & | is_thread(T) ) { 139 uint32_t prng( T & th ) __attribute__(( warn_unused_result )) { return prng( (thread &)th ); } // [0,UINT_MAX] 140 uint32_t prng( T & th, uint32_t u ) __attribute__(( warn_unused_result )) { return prng( th ) % u; } // [0,u) 141 uint32_t prng( T & th, uint32_t l, uint32_t u ) __attribute__(( warn_unused_result )) { return prng( th, u - l + 1 ) + l; } // [l,u] 142 } // distribution 143 } // distribution 144 132 145 // Local Variables: // 133 146 // mode: c //
Note:
See TracChangeset
for help on using the changeset viewer.