Ignore:
Timestamp:
Jun 23, 2022, 1:41:29 PM (2 years ago)
Author:
caparsons <caparson@…>
Branches:
ADT, ast-experimental, master, pthread-emulation, qualifiedEnum
Children:
d28524a
Parents:
1dbbef6
Message:

fixed timeout cond var bug and updated pthread_locks test with timeout lock test

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/unified_locking/pthread_locks.cfa

    r1dbbef6 r4e83bb7  
    33#include <stdlib.hfa>
    44#include <thread.hfa>
     5#include <time.h>
     6#include <stdlib.hfa>
    57
    6 const unsigned int num_times = 50000;
     8const unsigned int num_times = 50;
    79
    810simple_owner_lock l;
    911pthread_cond_var( simple_owner_lock ) c;
     12
     13owner_lock l2;
     14condition_variable( owner_lock ) c2;
    1015
    1116volatile int counter = 0;
     
    5964}
    6065
     66thread Wait_Time_Signal_1 {};
     67
     68void main( Wait_Time_Signal_1 & this ) {
     69        for (unsigned int i = 0; i < num_times; i++) {
     70                lock(l);
     71                if(empty(c) || random(10) >= 9 ) {
     72                        timespec t;
     73                        clock_gettime(CLOCK_REALTIME, &t);
     74                        timespec waitTime{0,1};
     75                        bool woken = wait(c,l, t + waitTime);
     76                }else{
     77                        notify_one(c);
     78                }
     79                unlock(l);
     80        }
     81}
     82
    6183int main() {
    62         processor p[3];
     84        processor p[1];
    6385        printf("Start Test 1: lock and condition variable single wait/notify\n");
    6486        {
     
    78100        }
    79101        printf("Done Test 3\n");
     102
     103        printf("Start Test 4: lock and condition variable single timed wait/notify\n");
     104        {
     105                Wait_Time_Signal_1 t1[2];
     106        }
     107        printf("Done Test 4\n");
    80108}
Note: See TracChangeset for help on using the changeset viewer.