52,12 → 52,6 |
|
static uint32_t seed = 0xdeadbeef; |
|
static uint32_t random(uint32_t max); |
|
static void writer(void *arg); |
static void reader(void *arg); |
static void failed(void); |
|
static uint32_t random(uint32_t max) |
{ |
uint32_t rc; |
69,7 → 63,6 |
return rc; |
} |
|
|
static void writer(void *arg) |
{ |
int rc, to; |
82,7 → 75,7 |
if (SYNCH_FAILED(rc)) { |
printf("cpu%d, tid %d w!\n", CPU->id, THREAD->tid); |
return; |
}; |
} |
printf("cpu%d, tid %d w=\n", CPU->id, THREAD->tid); |
|
if (rwlock.readers_in) panic("Oops."); |
112,23 → 105,14 |
printf("cpu%d, tid %d r-\n", CPU->id, THREAD->tid); |
} |
|
static void failed(void) |
char * test_rwlock4(void) |
{ |
printf("Test failed prematurely.\n"); |
thread_exit(); |
} |
|
void test_rwlock4(void) |
{ |
context_t ctx; |
uint32_t i, k; |
|
printf("Read/write locks test #4\n"); |
|
waitq_initialize(&can_start); |
rwlock_initialize(&rwlock); |
|
for (;;) { |
thread_t *thrd; |
|
context_save(&ctx); |
141,7 → 125,7 |
if (thrd) |
thread_ready(thrd); |
else |
failed(); |
printf("Could not create reader %d\n", i); |
} |
|
k = random(5) + 1; |
151,11 → 135,11 |
if (thrd) |
thread_ready(thrd); |
else |
failed(); |
printf("Could not create writer %d\n", i); |
} |
|
thread_usleep(20000); |
waitq_wakeup(&can_start, WAKEUP_ALL); |
} |
|
return NULL; |
} |