summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/tests/test_interprocess.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/source/tests/test_interprocess.c b/source/tests/test_interprocess.c
index ee25324..7655192 100644
--- a/source/tests/test_interprocess.c
+++ b/source/tests/test_interprocess.c
@@ -34,6 +34,8 @@ int run_writer() {
p->state = STATE_INIT;
unique_unlock(&p->m);
+ thrd_yield();
+
unique_lock(&p->m);
for (int i = 0; i < DATA_SIZE; i++) p->bytes[i] = i;
p->state = STATE_READY;
@@ -97,6 +99,15 @@ int run_reader() {
shared_lock(&p->m);
while (p->state != STATE_READY) {
shared_unlock(&p->m);
+
+ struct timespec t1;
+ timespec_get(&t1, TIME_UTC);
+
+ if (t1.tv_sec - t0.tv_sec > TIMEOUT) {
+ printf("%s: timeout.\n", __FUNCTION__);
+ return 1;
+ }
+
thrd_yield();
shared_lock(&p->m);
}