Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2029 → Rev 2028

/trunk/kernel/test/synch/rwlock4.c
34,6 → 34,7
#include <arch/types.h>
#include <arch/context.h>
#include <context.h>
#include <panic.h>
 
#include <synch/waitq.h>
#include <synch/rwlock.h>
44,7 → 45,6
#define WRITERS 50
 
static rwlock_t rwlock;
static atomic_t threads_fault;
 
SPINLOCK_INITIALIZE(rw_lock);
 
78,17 → 78,9
}
printf("cpu%d, tid %d w=\n", CPU->id, THREAD->tid);
 
if (rwlock.readers_in) {
printf("Oops.");
atomic_inc(&threads_fault);
return;
}
if (rwlock.readers_in) panic("Oops.");
thread_usleep(random(1000000));
if (rwlock.readers_in) {
printf("Oops.");
atomic_inc(&threads_fault);
return;
}
if (rwlock.readers_in) panic("Oops.");
 
rwlock_write_unlock(&rwlock);
printf("cpu%d, tid %d w-\n", CPU->id, THREAD->tid);
120,7 → 112,6
waitq_initialize(&can_start);
rwlock_initialize(&rwlock);
atomic_set(&threads_fault, 0);
thread_t *thrd;
139,7 → 130,7
 
k = random(5) + 1;
printf("Creating %d writers\n", k);
for (i = 0; i < k; i++) {
for (i=0; i<k; i++) {
thrd = thread_create(writer, NULL, TASK, 0, "writer");
if (thrd)
thread_ready(thrd);
150,8 → 141,5
thread_usleep(20000);
waitq_wakeup(&can_start, WAKEUP_ALL);
if (atomic_get(&threads_fault) == 0)
return NULL;
return "Test failed";
return NULL;
}