Ignore:
Timestamp:
Jan 13, 2023, 12:49:52 PM (16 months ago)
Author:
caparsons <caparson@…>
Branches:
ADT, ast-experimental, master
Children:
b3d794fc, d61d034
Parents:
862658a
Message:

fixed termination synchronization in the channel benchmark to get rid of deadlock case

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/concurrent/channels/parallel_harness.hfa

    r862658a r42b739d7  
    3838
    3939volatile bool cons_done = false, prod_done = false;
     40volatile int cons_done_count = 0;
    4041size_t cons_check = 0, prod_check = 0;
    4142
     
    6465    lock(o);
    6566    total_operations += runs;
     67    cons_done_count++;
    6668    cons_check = cons_check ^ my_check;
    6769    // sout | "C: " | runs;
     
    128130    }
    129131
    130     sleep(10`s);
     132    sleep(1`s);
    131133    prod_done = true;
    132134
     
    137139    sout | "prods";
    138140    cons_done = true;
    139     for ( i; Channels ) {
    140         // sout | get_count( channels[i] );
    141         if ( get_count( channels[i] ) < Consumers ){
    142             #ifdef BIG
    143             bigObject b{0};
    144             #endif
    145             for ( j; Consumers ) {
     141    while( cons_done_count != Consumers * Channels ) {
     142        for ( i; Channels ) {
     143            if ( has_waiting_consumers( channels[i] ) ){
    146144                #ifdef BIG
     145                bigObject b{0};
    147146                insert( channels[i], b );
    148147                #else
     
    151150            }
    152151        }
    153     }
     152       
     153    }
     154    // for ( i; Channels ) {
     155    //     // sout | get_count( channels[i] );
     156    //     if ( get_count( channels[i] ) < Consumers ){
     157    //         #ifdef BIG
     158    //         bigObject b{0};
     159    //         #endif
     160    //         for ( j; Consumers ) {
     161    //             #ifdef BIG
     162    //             insert( channels[i], b );
     163    //             #else
     164    //             insert( channels[i], 0 );
     165    //             #endif
     166    //         }
     167    //     }
     168    // }
    154169    sout | "cons";
    155170    for ( i; Consumers * Channels ) {
Note: See TracChangeset for help on using the changeset viewer.