Ignore:
Timestamp:
Jan 18, 2022, 1:16:23 PM (2 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
Children:
1e8b4b49, adfd125
Parents:
21a5bfb7 (diff), 91a72ef (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

    r21a5bfb7 r175f9f4  
    1010// Created On       : Tue Jan 17 12:27:26 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Dec  4 09:17:49 2019
    13 // Update Count     : 9
     12// Last Modified On : Thu Jan 13 20:11:55 2022
     13// Update Count     : 42
    1414//
    1515
     
    2525#include "invoke.h"
    2626
    27 uint64_t thread_rand();
     27extern uint32_t __global_random_seed;
    2828
    2929//-----------------------------------------------------------------------------
    3030// Thread ctors and dtors
    31 void ?{}(thread$ & this, const char * const name, cluster & cl, void * storage, size_t storageSize ) with( this ) {
     31void ?{}( thread$ & this, const char * const name, cluster & cl, void * storage, size_t storageSize ) with( this ) {
    3232        context{ 0p, 0p };
    3333        self_cor{ name, storage, storageSize };
     
    4545        preferred = ready_queue_new_preferred();
    4646        last_proc = 0p;
     47        random_state = __global_random_seed;
    4748        #if defined( __CFA_WITH_VERIFY__ )
    4849                canary = 0x0D15EA5E0D15EA5Ep;
     
    171172}
    172173
    173 uint64_t thread_rand() {
    174         disable_interrupts();
    175         uint64_t ret = __tls_rand();
    176         enable_interrupts();
    177         return ret;
    178 }
     174//-----------------------------------------------------------------------------
     175#define GENERATOR LCG
     176
     177void set_seed( uint32_t seed ) {
     178        active_thread()->random_state = __global_random_seed = seed;
     179        GENERATOR( active_thread()->random_state );
     180} // set_seed
     181uint32_t prng( void ) { return GENERATOR( active_thread()->random_state ); } // [0,UINT_MAX]
    179182
    180183// Local Variables: //
Note: See TracChangeset for help on using the changeset viewer.