Changeset b984d54


Ignore:
Timestamp:
May 25, 2021, 4:13:37 PM (5 months ago)
Author:
caparsons <caparson@…>
Branches:
arm-eh, jacob/cs343-translation, master, new-ast-unique-expr
Children:
c65b930
Parents:
7404cdc
Message:

removed semaphore usage and used a lock when checking if empty

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/unified_locking/timeout_lock.cfa

    r7404cdc rb984d54  
    66#include "kernel.cfa"
    77
    8 multiple_acquisition_lock m;
    9 condition_variable( multiple_acquisition_lock ) c_m;
    10 
    11 semaphore s; // used for barrier like behaviour
     8multiple_acquisition_lock m, n;
     9condition_variable( multiple_acquisition_lock ) c_m, c_n;
    1210
    1311const unsigned int NoOfTimes = 20;
    1412
    15 void block() {
    16         if (s.count == 0) {
    17                 P(s);
     13void block() { // used for barrier like behaviour
     14        lock(n);
     15        if (empty( c_n )) {
     16                wait( c_n, n );
    1817        } else {
    19                 V(s);
     18                notify_one( c_n );
    2019        }
     20        unlock(n);
    2121}
    2222
     
    8080
    8181        printf("Start Test 2: testing timeout vs signalling with varying timeout durations\n");
    82         s{ 0 };
    8382        {
    8483                T1 t1;
Note: See TracChangeset for help on using the changeset viewer.