Changeset 470618c0


Ignore:
Timestamp:
Feb 12, 2022, 1:55:07 PM (3 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
Children:
4708eaa
Parents:
c655650
Message:

add mutex statement for concurrent printing

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/PRNG.cfa

    rc655650 r470618c0  
    88// Created On       : Wed Dec 29 09:38:12 2021
    99// Last Modified By : Peter A. Buhr
    10 // Last Modified On : Fri Feb 11 08:16:43 2022
    11 // Update Count     : 328
     10// Last Modified On : Sat Feb 12 12:23:57 2022
     11// Update Count     : 342
    1212//
    1313
     
    2020#include <malloc.h>                                                                             // malloc_stats
    2121#include <locale.h>                                                                             // setlocale
     22#include <mutex_stmt.hfa>
    2223
    2324// FIX ME: spurious characters appear in output
     
    5051        } // for
    5152        double std = sqrt( sum / BUCKETS );
    52         sout | "trials"  | TRIALS | "buckets" | BUCKETS
    53                  | "min" | min | "max" | max
    54                  | "avg" | wd(0,1, avg) | "std" | wd(0,1, std) | "rstd" | wd(0,1, (avg == 0 ? 0.0 : std / avg * 100)) | "%";
     53        mutex( sout ) sout | "trials"  | TRIALS | "buckets" | BUCKETS
     54                | "min" | min | "max" | max
     55                | "avg" | wd(0,1, avg) | "std" | wd(0,1, std) | "rstd" | wd(0,1, (avg == 0 ? 0.0 : std / avg * 100)) | "%";
    5556} // avgstd
    5657
     58
    5759uint32_t seed = 1009;
    58 
    5960
    6061thread T1 {};
     
    9495        unsigned int * buckets = calloc( BUCKETS );                     // too big for task stack
    9596        for ( TRIALS ) {
    96                 buckets[prng( (thread$ &)th ) % BUCKETS] += 1;  // concurrent
     97                buckets[prng( th ) % BUCKETS] += 1;     // concurrent
    9798        } // for
    9899        avgstd( buckets );
Note: See TracChangeset for help on using the changeset viewer.