Changeset 2210cfc for libcfa/src/concurrency
- Timestamp:
- Jan 10, 2022, 5:43:42 PM (3 years ago)
- Branches:
- ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
- Children:
- c52f033
- Parents:
- 4177592f
- Location:
- libcfa/src/concurrency
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/invoke.h
r4177592f r2210cfc 10 10 // Created On : Tue Jan 17 12:27:26 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jan 6 16:37:40202213 // Update Count : 4 712 // Last Modified On : Sun Jan 9 19:06:45 2022 13 // Update Count : 48 14 14 // 15 15 … … 211 211 struct processor * last_proc; 212 212 213 uint32_t random_state; // fast random numbers 214 213 215 #if defined( __CFA_WITH_VERIFY__ ) 214 216 void * canary; -
libcfa/src/concurrency/thread.cfa
r4177592f r2210cfc 10 10 // Created On : Tue Jan 17 12:27:26 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Dec 4 09:17:49 201913 // Update Count : 912 // Last Modified On : Mon Jan 10 17:05:35 2022 13 // Update Count : 28 14 14 // 15 15 … … 27 27 uint64_t thread_rand(); 28 28 29 extern uint32_t __thread_seed; // global thread seed 30 29 31 //----------------------------------------------------------------------------- 30 32 // Thread ctors and dtors 31 void ?{}( thread$ & this, const char * const name, cluster & cl, void * storage, size_t storageSize ) with( this ) {33 void ?{}( thread$ & this, const char * const name, cluster & cl, void * storage, size_t storageSize ) with( this ) { 32 34 context{ 0p, 0p }; 33 35 self_cor{ name, storage, storageSize }; … … 39 41 self_mon.owner = &this; 40 42 self_mon.recursion = 1; 43 random_state = __thread_seed; 41 44 self_mon_p = &self_mon; 42 45 curr_cluster = &cl; … … 178 181 } 179 182 183 #define GENERATOR LCG 184 185 inline uint32_t MarsagliaXor( uint32_t & state ) { 186 state ^= state << 6; 187 state ^= state >> 21; 188 state ^= state << 7; 189 return state; 190 } // MarsagliaXor 191 192 inline uint32_t LCG( uint32_t & state ) { // linear congruential generator 193 return state = 36969 * (state & 65535) + (state >> 16); // 36969 is NOT prime! 194 } // LCG 195 196 void set_seed( uint32_t seed ) { active_thread()->random_state = seed; __thread_seed = seed; } 197 uint32_t prng( void ) { return GENERATOR( active_thread()->random_state ); } // [0,UINT_MAX] 198 180 199 // Local Variables: // 181 200 // mode: c //
Note: See TracChangeset
for help on using the changeset viewer.