Changeset e0b8ccd5


Ignore:
Timestamp:
May 5, 2017, 10:56:12 AM (7 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
bd951f7
Parents:
8cb6fcd
Message:

Monitor benchmarks now compare 1 and 2 monitors

Location:
src/benchmark
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/benchmark/Monitor.c

    r8cb6fcd re0b8ccd5  
    99mon_t mon1, mon2;
    1010
     11void dummy( mon_t * mutex a ) {}
    1112void dummy( mon_t * mutex a, mon_t * mutex b ) {}
    12 
    13 
    1413
    1514int main() {
    1615        long long int StartTime, EndTime;
     16
     17        StartTime = Time();
     18        for( int i = 0; i < N; i++ ) {
     19                dummy( &mon1 );
     20        }
     21        EndTime = Time();
     22
     23        sout | ( EndTime - StartTime ) / N;
    1724
    1825        StartTime = Time();
  • src/benchmark/SchedInt.c

    r8cb6fcd re0b8ccd5  
    77condition condA;
    88condition condB;
     9condition condC;
     10condition condD;
    911
    1012monitor mon_t {};
     
    1416thread thrdA {};
    1517thread thrdB {};
     18thread thrdC {};
     19thread thrdD {};
    1620
    17 void sideA( mon_t * mutex a, mon_t * mutex b ) {
     21//-------------------------------------------------------------------
     22// 1 monitor signal cycle
     23void sideA( mon_t * mutex a ) {
    1824        long long int StartTime, EndTime;
    1925
     
    2632        EndTime = Time();
    2733
    28         sout | ( EndTime - StartTime ) / N | endl;
     34        sout | ( EndTime - StartTime ) / N;
    2935}
    3036
    31 void sideB( mon_t * mutex a, mon_t * mutex b ) {
     37void sideB( mon_t * mutex a ) {
    3238        for( int i = 0;; i++ ) {
    3339                signal(&condB);
     
    3743}
    3844
    39 void main( thrdA * this ) { sideA( &mon1, &mon2 ); }
    40 void main( thrdB * this ) { sideB( &mon1, &mon2 ); }
     45//-------------------------------------------------------------------
     46// 2 monitor signal cycle
     47void sideC( mon_t * mutex a, mon_t * mutex b ) {
     48        long long int StartTime, EndTime;
     49
     50        StartTime = Time();
     51        for( int i = 0;; i++ ) {
     52                signal(&condC);
     53                if( i > N ) break;
     54                wait(&condD);
     55        }
     56        EndTime = Time();
     57
     58        sout | ( EndTime - StartTime ) / N | endl;
     59}
     60
     61void sideD( mon_t * mutex a, mon_t * mutex b ) {
     62        for( int i = 0;; i++ ) {
     63                signal(&condD);
     64                if( i > N ) break;
     65                wait(&condC);
     66        }
     67}
     68
     69void main( thrdA * this ) { sideA( &mon1 ); }
     70void main( thrdB * this ) { sideB( &mon1 ); }
     71void main( thrdC * this ) { sideC( &mon1, &mon2 ); }
     72void main( thrdD * this ) { sideD( &mon1, &mon2 ); }
    4173
    4274int main() {
    43         thrdA a;
    44         thrdB b;
     75        {
     76                thrdA a;
     77                thrdB b;
     78        }
     79        {
     80                thrdC c;
     81                thrdD d;
     82        }
    4583}
Note: See TracChangeset for help on using the changeset viewer.