Changeset 7d18733 for libcfa/src
- Timestamp:
- Feb 15, 2022, 2:50:07 PM (4 years ago)
- Branches:
- ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
- Children:
- 6dc17a3d
- Parents:
- 1a0b600 (diff), a38bbbc (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
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/kernel/startup.cfa
r1a0b600 r7d18733 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
r1a0b600 r7d18733 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:58 202213 // Update Count : 4512 // 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 184 -
libcfa/src/concurrency/thread.hfa
r1a0b600 r7d18733 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: // -
libcfa/src/stdlib.hfa
r1a0b600 r7d18733 10 10 // Created On : Thu Jan 28 17:12:35 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 10 18:34:58202213 // Update Count : 64 112 // Last Modified On : Sat Feb 12 17:22:25 2022 13 // Update Count : 643 14 14 // 15 15 … … 412 412 void set_seed( PRNG & prng, uint32_t seed_ ); 413 413 static inline { 414 void ?{}( PRNG & prng ) { set_seed( prng, rdtscl() ); }// random seed415 void ?{}( PRNG & prng, uint32_t seed ) {set_seed( prng, seed ); } // fixed seed414 void ?{}( PRNG & prng ) with( prng ) { callcnt = 0; set_seed( prng, rdtscl() ); } // random seed 415 void ?{}( PRNG & prng, uint32_t seed ) with( prng ) { callcnt = 0; set_seed( prng, seed ); } // fixed seed 416 416 uint32_t get_seed( PRNG & prng ) __attribute__(( warn_unused_result )) with( prng ) { return seed; } // get seed 417 417 uint32_t prng( PRNG & prng ) __attribute__(( warn_unused_result )) with( prng ) { callcnt += 1; return LCG( state ); } // [0,UINT_MAX]
Note:
See TracChangeset
for help on using the changeset viewer.