Subversion Repositories HelenOS-historic

Compare Revisions

Ignore whitespace Rev 1 → Rev 15

/SPARTAN/trunk/test/synch/rwlock2/test.c
74,7 → 74,7
rwlock_read_lock(&rwlock);
rwlock_read_lock(&rwlock);
thrd = thread_create(writer, NULL, the->task, 0);
thrd = thread_create(writer, NULL, TASK, 0);
if (thrd)
thread_ready(thrd);
else
/SPARTAN/trunk/test/synch/rwlock3/test.c
44,16 → 44,16
 
void reader(void *arg)
{
printf("cpu%d, tid %d: trying to lock rwlock for reading....\n", the->cpu->id, the->thread->tid);
printf("cpu%d, tid %d: trying to lock rwlock for reading....\n", CPU->id, THREAD->tid);
rwlock_read_lock(&rwlock);
rwlock_read_unlock(&rwlock);
printf("cpu%d, tid %d: success\n", the->cpu->id, the->thread->tid);
printf("cpu%d, tid %d: success\n", CPU->id, THREAD->tid);
 
printf("cpu%d, tid %d: trying to lock rwlock for writing....\n", the->cpu->id, the->thread->tid);
printf("cpu%d, tid %d: trying to lock rwlock for writing....\n", CPU->id, THREAD->tid);
 
rwlock_write_lock(&rwlock);
rwlock_write_unlock(&rwlock);
printf("cpu%d, tid %d: success\n", the->cpu->id, the->thread->tid);
printf("cpu%d, tid %d: success\n", CPU->id, THREAD->tid);
printf("Test passed.\n");
 
77,7 → 77,7
rwlock_write_lock(&rwlock);
for (i=0; i<4; i++) {
thrd = thread_create(reader, NULL, the->task, 0);
thrd = thread_create(reader, NULL, TASK, 0);
if (thrd)
thread_ready(thrd);
else
/SPARTAN/trunk/test/synch/semaphore1/test.c
99,7 → 99,7
for (j=0; j<(CONSUMERS+PRODUCERS)/2; j++) {
for (k=0; k<i; k++) {
thrd = thread_create(consumer, NULL, the->task, 0);
thrd = thread_create(consumer, NULL, TASK, 0);
if (thrd)
thread_ready(thrd);
else
106,7 → 106,7
failed();
}
for (k=0; k<(4-i); k++) {
thrd = thread_create(producer, NULL, the->task, 0);
thrd = thread_create(producer, NULL, TASK, 0);
if (thrd)
thread_ready(thrd);
else
/SPARTAN/trunk/test/synch/rwlock4/test.c
73,13 → 73,13
waitq_sleep(&can_start);
 
to = random(40000);
printf("cpu%d, tid %d w+ (%d)\n", the->cpu->id, the->thread->tid, to);
printf("cpu%d, tid %d w+ (%d)\n", CPU->id, THREAD->tid, to);
rc = rwlock_write_lock_timeout(&rwlock, to);
if (SYNCH_FAILED(rc)) {
printf("cpu%d, tid %d w!\n", the->cpu->id, the->thread->tid);
printf("cpu%d, tid %d w!\n", CPU->id, THREAD->tid);
return;
};
printf("cpu%d, tid %d w=\n", the->cpu->id, the->thread->tid);
printf("cpu%d, tid %d w=\n", CPU->id, THREAD->tid);
 
if (rwlock.readers_in) panic("Oops.");
thread_usleep(random(1000000));
86,7 → 86,7
if (rwlock.readers_in) panic("Oops.");
 
rwlock_write_unlock(&rwlock);
printf("cpu%d, tid %d w-\n", the->cpu->id, the->thread->tid);
printf("cpu%d, tid %d w-\n", CPU->id, THREAD->tid);
}
 
void reader(void *arg)
95,16 → 95,16
waitq_sleep(&can_start);
to = random(2000);
printf("cpu%d, tid %d r+ (%d)\n", the->cpu->id, the->thread->tid, to);
printf("cpu%d, tid %d r+ (%d)\n", CPU->id, THREAD->tid, to);
rc = rwlock_read_lock_timeout(&rwlock, to);
if (SYNCH_FAILED(rc)) {
printf("cpu%d, tid %d r!\n", the->cpu->id, the->thread->tid);
printf("cpu%d, tid %d r!\n", CPU->id, THREAD->tid);
return;
}
printf("cpu%d, tid %d r=\n", the->cpu->id, the->thread->tid);
printf("cpu%d, tid %d r=\n", CPU->id, THREAD->tid);
thread_usleep(30000);
rwlock_read_unlock(&rwlock);
printf("cpu%d, tid %d r-\n", the->cpu->id, the->thread->tid);
printf("cpu%d, tid %d r-\n", CPU->id, THREAD->tid);
}
 
void failed(void)
134,7 → 134,7
k = random(7) + 1;
printf("Creating %d readers\n", k);
for (i=0; i<k; i++) {
thrd = thread_create(reader, NULL, the->task, 0);
thrd = thread_create(reader, NULL, TASK, 0);
if (thrd)
thread_ready(thrd);
else
144,7 → 144,7
k = random(5) + 1;
printf("Creating %d writers\n", k);
for (i=0; i<k; i++) {
thrd = thread_create(writer, NULL, the->task, 0);
thrd = thread_create(writer, NULL, TASK, 0);
if (thrd)
thread_ready(thrd);
else
/SPARTAN/trunk/test/synch/semaphore2/test.c
69,18 → 69,18
waitq_sleep(&can_start);
to = random(20000);
printf("cpu%d, tid %d down+ (%d)\n", the->cpu->id, the->thread->tid, to);
printf("cpu%d, tid %d down+ (%d)\n", CPU->id, THREAD->tid, to);
rc = semaphore_down_timeout(&sem, to);
if (SYNCH_FAILED(rc)) {
printf("cpu%d, tid %d down!\n", the->cpu->id, the->thread->tid);
printf("cpu%d, tid %d down!\n", CPU->id, THREAD->tid);
return;
}
printf("cpu%d, tid %d down=\n", the->cpu->id, the->thread->tid);
printf("cpu%d, tid %d down=\n", CPU->id, THREAD->tid);
thread_usleep(random(30000));
semaphore_up(&sem);
printf("cpu%d, tid %d up\n", the->cpu->id, the->thread->tid);
printf("cpu%d, tid %d up\n", CPU->id, THREAD->tid);
}
 
void failed(void)
107,7 → 107,7
k = random(7) + 1;
printf("Creating %d consumers\n", k);
for (i=0; i<k; i++) {
thrd = thread_create(consumer, NULL, the->task, 0);
thrd = thread_create(consumer, NULL, TASK, 0);
if (thrd)
thread_ready(thrd);
else
/SPARTAN/trunk/test/synch/rwlock5/test.c
95,7 → 95,7
for (j=0; j<(READERS+WRITERS)/2; j++) {
for (k=0; k<i; k++) {
thrd = thread_create(reader, NULL, the->task, 0);
thrd = thread_create(reader, NULL, TASK, 0);
if (thrd)
thread_ready(thrd);
else
102,7 → 102,7
failed();
}
for (k=0; k<(4-i); k++) {
thrd = thread_create(writer, NULL, the->task, 0);
thrd = thread_create(writer, NULL, TASK, 0);
if (thrd)
thread_ready(thrd);
else