Ignore:
Timestamp:
Feb 23, 2022, 11:24:34 AM (4 years ago)
Author:
Michael Brooks <mlbrooks@…>
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.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/thread.cfa

    rf5a51db rcc7bbe6  
    1010// Created On       : Tue Jan 17 12:27:26 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jan 13 20:11:55 2022
    13 // Update Count     : 42
     12// Last Modified On : Sat Feb 12 15:24:18 2022
     13// Update Count     : 66
    1414//
    1515
     
    2525#include "invoke.h"
    2626
    27 extern uint32_t __global_random_seed;
     27extern uint32_t __global_random_seed, __global_random_prime, __global_random_mask;
    2828
    2929//-----------------------------------------------------------------------------
     
    4545        preferred = ready_queue_new_preferred();
    4646        last_proc = 0p;
    47         random_state = __global_random_seed;
     47        random_state = __global_random_mask ? __global_random_prime : __global_random_prime ^ rdtscl();
    4848        #if defined( __CFA_WITH_VERIFY__ )
    4949                canary = 0x0D15EA5E0D15EA5Ep;
     
    176176
    177177void 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;
    180183} // set_seed
    181 uint32_t prng( void ) { return GENERATOR( active_thread()->random_state ); } // [0,UINT_MAX]
     184
     185uint32_t prng( void ) {                                                                 // [0,UINT_MAX]
     186        uint32_t & state = active_thread()->random_state;
     187        return GENERATOR( state );
     188} // prng
    182189
    183190// Local Variables: //
Note: See TracChangeset for help on using the changeset viewer.