From e7a585a298a12fc70e698f5def946e17630165e2 Mon Sep 17 00:00:00 2001 From: Geoffrey Challen Date: Thu, 31 Dec 2015 11:44:46 -0500 Subject: [PATCH] Synchronization testing changes. Tests now know when they succeed or fail and are ready for automation. --- kern/test/synchtest.c | 166 +++++++++++++++++++++++++++--------------- 1 file changed, 108 insertions(+), 58 deletions(-) diff --git a/kern/test/synchtest.c b/kern/test/synchtest.c index e586a64..cc401c3 100644 --- a/kern/test/synchtest.c +++ b/kern/test/synchtest.c @@ -37,7 +37,8 @@ #include #include #include -#include +#include +#include #define SUCCESS 0 #define FAIL 1 @@ -50,12 +51,16 @@ static volatile unsigned long testval1; static volatile unsigned long testval2; static volatile unsigned long testval3; +static volatile int32_t testval4; + static struct semaphore *testsem; static struct lock *testlock; static struct cv *testcv; static struct semaphore *donesem; -static bool semtest_status; +struct spinlock status_lock; +static bool test_status; + static unsigned long semtest_current; static @@ -86,6 +91,17 @@ inititems(void) panic("synchtest: sem_create failed\n"); } } + spinlock_init(&status_lock); +} + +static +void +success(bool status, const char *msg) { + if (status == SUCCESS) { + skprintf("%s: SUCCESS\n", msg); + } else { + skprintf("%s: FAIL\n", msg); + } } static @@ -101,15 +117,19 @@ semtestthread(void *junk, unsigned long num) random_yielder(4); P(testsem); semtest_current = num; - kprintf("Thread %2lu: ", num); + tkprintf("Thread %2lu: ", num); + for (i=0; i