Ignore:
Timestamp:
Dec 18, 2022, 12:24:50 PM (18 months ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, master
Children:
cbd1ba8
Parents:
fd6e3a4
Message:

Changed bounded buffer tests to use prng, which has better defined multi-threaded behavior

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/concurrent/pthread/bounded_buffer.cfa

    rfd6e3a4 rc63f470  
    6363
    6464void *producer( void *arg ) {
    65         Buffer(int) &buf = *(Buffer(int)*)arg;
    66         const int NoOfItems = rand() % 40;
     65    Buffer(int) &buf = *(Buffer(int)*)arg;
     66        const int NoOfItems = prng(*active_thread(), 40);
    6767        int item;
    6868        for ( int i = 1; i <= NoOfItems; i += 1 ) {                     // produce a bunch of items
    69                 item = rand() % 100 + 1;                                                // produce a random number
     69                item = prng(*active_thread(), 1, 101);                  // produce a random number
    7070                //sout | "Producer:" | pthread_self() | " value:" | item;
    7171                insert( buf,item );                                                             // insert element into queue
     
    101101    pthread_mutex_init(&consumer_cnt_lock, NULL);
    102102        // parallelism
    103     srandom( 1003 );
     103    set_seed( 1003 );
    104104
    105105        processor p[5];
Note: See TracChangeset for help on using the changeset viewer.