Subversion Repositories HelenOS

Compare Revisions

Regard whitespace Rev 2027 → Rev 2028

/trunk/kernel/test/synch/rwlock5.c
44,11 → 44,7
static atomic_t items_read;
static atomic_t items_written;
 
static void writer(void *arg);
static void reader(void *arg);
static void failed(void);
 
void writer(void *arg)
static void writer(void *arg)
{
thread_detach(THREAD);
 
59,7 → 55,7
rwlock_write_unlock(&rwlock);
}
 
void reader(void *arg)
static void reader(void *arg)
{
thread_detach(THREAD);
 
70,19 → 66,11
rwlock_read_unlock(&rwlock);
}
 
void failed(void)
char * test_rwlock5(void)
{
printf("Test failed prematurely.\n");
thread_exit();
}
 
void test_rwlock5(void)
{
int i, j, k;
count_t readers, writers;
printf("Read/write locks test #5\n");
waitq_initialize(&can_start);
rwlock_initialize(&rwlock);
103,7 → 91,7
if (thrd)
thread_ready(thrd);
else
failed();
printf("Could not create reader %d\n", k);
}
for (k=0; k<(4-i); k++) {
thrd = thread_create(writer, NULL, TASK, 0, "writer");
110,7 → 98,7
if (thrd)
thread_ready(thrd);
else
failed();
printf("Could not create writer %d\n", k);
}
}
 
119,10 → 107,11
thread_sleep(1);
waitq_wakeup(&can_start, WAKEUP_ALL);
while (items_read.count != readers || items_written.count != writers) {
while ((items_read.count != readers) || (items_written.count != writers)) {
printf("%zd readers remaining, %zd writers remaining, readers_in=%zd\n", readers - items_read.count, writers - items_written.count, rwlock.readers_in);
thread_usleep(100000);
}
}
printf("Test passed.\n");
return NULL;
}