- Timestamp:
- Feb 12, 2022, 1:53:14 PM (3 years ago)
- Branches:
- ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
- Children:
- 470618c0
- Parents:
- aac37fa
- Location:
- libcfa/src/concurrency
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/kernel/startup.cfa
raac37fa rc655650 18 18 19 19 // C Includes 20 #include <errno.h> 20 #include <errno.h> // errno 21 21 #include <signal.h> 22 #include <string.h> 23 #include <unistd.h> 22 #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> 28 #include <sys/eventfd.h> 29 #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" 35 #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; -
libcfa/src/concurrency/thread.cfa
raac37fa rc655650 10 10 // Created On : Tue Jan 17 12:27:26 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jan 15 14:34:58202213 // Update Count : 4512 // Last Modified On : Sat Feb 12 08:45:33 2022 13 // Update Count : 65 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; … … 178 178 active_thread()->random_state = __global_random_seed = seed; 179 179 GENERATOR( active_thread()->random_state ); 180 __global_random_prime = active_thread()->random_state; 181 __global_random_mask = true; 180 182 } // set_seed 181 183 -
libcfa/src/concurrency/thread.hfa
raac37fa rc655650 10 10 // Created On : Tue Jan 17 12:27:26 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Feb 9 22:10:14202213 // Update Count : 1412 // Last Modified On : Fri Feb 11 16:34:07 2022 13 // Update Count : 20 14 14 // 15 15 … … 131 131 132 132 //---------- 133 // prng 133 134 static inline { 134 135 uint32_t prng( thread$ & th ) __attribute__(( warn_unused_result )) { return LCG( th.random_state ); } // [0,UINT_MAX] 135 136 uint32_t prng( thread$ & th, uint32_t u ) __attribute__(( warn_unused_result )) { return prng( th ) % u; } // [0,u) 136 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] 137 } // prng 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 138 144 139 145 // Local Variables: //
Note: See TracChangeset
for help on using the changeset viewer.