diff options
| author | rpj <rpj> | 2001-02-08 16:31:20 +0000 | 
|---|---|---|
| committer | rpj <rpj> | 2001-02-08 16:31:20 +0000 | 
| commit | 2b3eede0b834a82c7dce5ec328f3929c0effc536 (patch) | |
| tree | 24414750f16e0c7bc7d231139d7f20a76b512ae4 /tests/rwlock6.c | |
| parent | 3c0fbfafe563b7b312d60c42c0d58a3a1f4d5930 (diff) | |
Fixes to new mutex routines and various tests.exp-2001-02-09-passed
Diffstat (limited to 'tests/rwlock6.c')
| -rw-r--r-- | tests/rwlock6.c | 18 | 
1 files changed, 13 insertions, 5 deletions
diff --git a/tests/rwlock6.c b/tests/rwlock6.c index 97742b1..091c3a0 100644 --- a/tests/rwlock6.c +++ b/tests/rwlock6.c @@ -11,14 +11,17 @@  #include "test.h" +#define PRTDEBUG(M, F, L) {FILE * fp; fp = fopen("debug.log", "a"); fprintf(fp, "%s: %s: %d\n", M, F, L); fclose(fp);} +  static pthread_rwlock_t rwlock1 = PTHREAD_RWLOCK_INITIALIZER; -static int bankAccount; +static int bankAccount = 0;  void * wrfunc(void * arg)  {    assert(pthread_rwlock_wrlock(&rwlock1) == 0); -  Sleep(1000); +//PRTDEBUG("wr", __FILE__, __LINE__); +  Sleep(2000);    bankAccount += 10;    assert(pthread_rwlock_unlock(&rwlock1) == 0); @@ -30,6 +33,7 @@ void * rdfunc(void * arg)    int ba = 0;    assert(pthread_rwlock_rdlock(&rwlock1) == 0); +//PRTDEBUG("rd", __FILE__, __LINE__);    ba = bankAccount;    assert(pthread_rwlock_unlock(&rwlock1) == 0); @@ -47,10 +51,12 @@ main()    int wr2Result = 0;    int rdResult = 0; +  bankAccount = 0; +    assert(pthread_create(&wrt1, NULL, wrfunc, NULL) == 0); -  Sleep(200); +  Sleep(500);    assert(pthread_create(&rdt, NULL, rdfunc, NULL) == 0); -  Sleep(200); +  Sleep(500);    assert(pthread_create(&wrt2, NULL, wrfunc, NULL) == 0);    assert(pthread_join(wrt1, (void **) &wr1Result) == 0); @@ -59,7 +65,9 @@ main()    assert(wr1Result == 10);    assert(wr2Result == 20); -  assert(rdResult == 20); +printf("rdResult = %d\n", rdResult); +fflush(stdout); +  assert(rdResult == 30);    return 0;  }  | 
