Skip to content
This repository was archived by the owner on Oct 3, 2021. It is now read-only.

Commit d5995c1

Browse files
solved problems with read-write-lock
1 parent 6be3cf8 commit d5995c1

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

c/pthread-atomic/read_write_lock-1.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,12 @@ void *reader(void *arg) { //reader
5555
y = l;
5656
__VERIFIER_atomic_end();
5757
__VERIFIER_atomic_begin();
58-
assert(y == x);
58+
int ly = y;
5959
__VERIFIER_atomic_end();
60+
__VERIFIER_atomic_begin();
61+
int lx = x;
62+
__VERIFIER_atomic_end();
63+
assert(ly == lx);
6064
__VERIFIER_atomic_release_read_lock();
6165
return 0;
6266
}

c/pthread-atomic/read_write_lock-2.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,13 @@ void *reader(void *arg) { //reader
5353
y = l;
5454
__VERIFIER_atomic_end();
5555
__VERIFIER_atomic_begin();
56-
assert(y == x);
56+
int ly = y;
5757
__VERIFIER_atomic_end();
5858
__VERIFIER_atomic_begin();
59+
int lx = x;
60+
__VERIFIER_atomic_end();
61+
assert(ly == lx);
62+
__VERIFIER_atomic_begin();
5963
l = r-1;
6064
__VERIFIER_atomic_end();
6165
__VERIFIER_atomic_begin();

0 commit comments

Comments
 (0)