projects
/
model-checker.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
cleanup style
[model-checker.git]
/
test
/
linuxrwlocks.c
diff --git
a/test/linuxrwlocks.c
b/test/linuxrwlocks.c
index dcf323caed1383d0c973a2801b52e00517b0d21b..3862ed491474ec452b5fba5cdc410ee9a02c5176 100644
(file)
--- a/
test/linuxrwlocks.c
+++ b/
test/linuxrwlocks.c
@@
-4,14
+4,12
@@
#include "librace.h"
#include "stdatomic.h"
#include "librace.h"
#include "stdatomic.h"
-
#define RW_LOCK_BIAS 0x00100000
#define WRITE_LOCK_CMP RW_LOCK_BIAS
/** Example implementation of linux rw lock along with 2 thread test
* driver... */
#define RW_LOCK_BIAS 0x00100000
#define WRITE_LOCK_CMP RW_LOCK_BIAS
/** Example implementation of linux rw lock along with 2 thread test
* driver... */
-
typedef union {
atomic_int lock;
} rwlock_t;
typedef union {
atomic_int lock;
} rwlock_t;
@@
-55,7
+53,7
@@
static inline int read_trylock(rwlock_t *rw)
int priorvalue=atomic_fetch_sub_explicit(&rw->lock, 1, memory_order_acquire);
if (priorvalue>0)
return 1;
int priorvalue=atomic_fetch_sub_explicit(&rw->lock, 1, memory_order_acquire);
if (priorvalue>0)
return 1;
-
+
atomic_fetch_add_explicit(&rw->lock, 1, memory_order_relaxed);
return 0;
}
atomic_fetch_add_explicit(&rw->lock, 1, memory_order_relaxed);
return 0;
}
@@
-65,7
+63,7
@@
static inline int write_trylock(rwlock_t *rw)
int priorvalue=atomic_fetch_sub_explicit(&rw->lock, RW_LOCK_BIAS, memory_order_acquire);
if (priorvalue==RW_LOCK_BIAS)
return 1;
int priorvalue=atomic_fetch_sub_explicit(&rw->lock, RW_LOCK_BIAS, memory_order_acquire);
if (priorvalue==RW_LOCK_BIAS)
return 1;
-
+
atomic_fetch_add_explicit(&rw->lock, RW_LOCK_BIAS, memory_order_relaxed);
return 0;
}
atomic_fetch_add_explicit(&rw->lock, RW_LOCK_BIAS, memory_order_relaxed);
return 0;
}
@@
-106,7
+104,7
@@
void user_main()
thrd_create(&t1, (thrd_start_t)&a, NULL);
thrd_create(&t2, (thrd_start_t)&a, NULL);
thrd_create(&t1, (thrd_start_t)&a, NULL);
thrd_create(&t2, (thrd_start_t)&a, NULL);
-
+
thrd_join(t1);
thrd_join(t2);
}
thrd_join(t1);
thrd_join(t2);
}