- Timestamp:
- 2005-04-09T18:22:53Z (21 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8262010
- Parents:
- e6ba9a3f
- Location:
- test/synch
- Files:
-
- 6 edited
-
rwlock2/test.c (modified) (1 diff)
-
rwlock3/test.c (modified) (2 diffs)
-
rwlock4/test.c (modified) (5 diffs)
-
rwlock5/test.c (modified) (2 diffs)
-
semaphore1/test.c (modified) (2 diffs)
-
semaphore2/test.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
test/synch/rwlock2/test.c
re6ba9a3f r43114c5 75 75 rwlock_read_lock(&rwlock); 76 76 77 thrd = thread_create(writer, NULL, the->task, 0);77 thrd = thread_create(writer, NULL, TASK, 0); 78 78 if (thrd) 79 79 thread_ready(thrd); -
test/synch/rwlock3/test.c
re6ba9a3f r43114c5 45 45 void reader(void *arg) 46 46 { 47 printf("cpu%d, tid %d: trying to lock rwlock for reading....\n", the->cpu->id, the->thread->tid);47 printf("cpu%d, tid %d: trying to lock rwlock for reading....\n", CPU->id, THREAD->tid); 48 48 rwlock_read_lock(&rwlock); 49 49 rwlock_read_unlock(&rwlock); 50 printf("cpu%d, tid %d: success\n", the->cpu->id, the->thread->tid);50 printf("cpu%d, tid %d: success\n", CPU->id, THREAD->tid); 51 51 52 printf("cpu%d, tid %d: trying to lock rwlock for writing....\n", the->cpu->id, the->thread->tid);52 printf("cpu%d, tid %d: trying to lock rwlock for writing....\n", CPU->id, THREAD->tid); 53 53 54 54 rwlock_write_lock(&rwlock); 55 55 rwlock_write_unlock(&rwlock); 56 printf("cpu%d, tid %d: success\n", the->cpu->id, the->thread->tid);56 printf("cpu%d, tid %d: success\n", CPU->id, THREAD->tid); 57 57 58 58 printf("Test passed.\n"); … … 78 78 79 79 for (i=0; i<4; i++) { 80 thrd = thread_create(reader, NULL, the->task, 0);80 thrd = thread_create(reader, NULL, TASK, 0); 81 81 if (thrd) 82 82 thread_ready(thrd); -
test/synch/rwlock4/test.c
re6ba9a3f r43114c5 74 74 75 75 to = random(40000); 76 printf("cpu%d, tid %d w+ (%d)\n", the->cpu->id, the->thread->tid, to);76 printf("cpu%d, tid %d w+ (%d)\n", CPU->id, THREAD->tid, to); 77 77 rc = rwlock_write_lock_timeout(&rwlock, to); 78 78 if (SYNCH_FAILED(rc)) { 79 printf("cpu%d, tid %d w!\n", the->cpu->id, the->thread->tid);79 printf("cpu%d, tid %d w!\n", CPU->id, THREAD->tid); 80 80 return; 81 81 }; 82 printf("cpu%d, tid %d w=\n", the->cpu->id, the->thread->tid);82 printf("cpu%d, tid %d w=\n", CPU->id, THREAD->tid); 83 83 84 84 if (rwlock.readers_in) panic("Oops."); … … 87 87 88 88 rwlock_write_unlock(&rwlock); 89 printf("cpu%d, tid %d w-\n", the->cpu->id, the->thread->tid);89 printf("cpu%d, tid %d w-\n", CPU->id, THREAD->tid); 90 90 } 91 91 … … 96 96 97 97 to = random(2000); 98 printf("cpu%d, tid %d r+ (%d)\n", the->cpu->id, the->thread->tid, to);98 printf("cpu%d, tid %d r+ (%d)\n", CPU->id, THREAD->tid, to); 99 99 rc = rwlock_read_lock_timeout(&rwlock, to); 100 100 if (SYNCH_FAILED(rc)) { 101 printf("cpu%d, tid %d r!\n", the->cpu->id, the->thread->tid);101 printf("cpu%d, tid %d r!\n", CPU->id, THREAD->tid); 102 102 return; 103 103 } 104 printf("cpu%d, tid %d r=\n", the->cpu->id, the->thread->tid);104 printf("cpu%d, tid %d r=\n", CPU->id, THREAD->tid); 105 105 thread_usleep(30000); 106 106 rwlock_read_unlock(&rwlock); 107 printf("cpu%d, tid %d r-\n", the->cpu->id, the->thread->tid);107 printf("cpu%d, tid %d r-\n", CPU->id, THREAD->tid); 108 108 } 109 109 … … 135 135 printf("Creating %d readers\n", k); 136 136 for (i=0; i<k; i++) { 137 thrd = thread_create(reader, NULL, the->task, 0);137 thrd = thread_create(reader, NULL, TASK, 0); 138 138 if (thrd) 139 139 thread_ready(thrd); … … 145 145 printf("Creating %d writers\n", k); 146 146 for (i=0; i<k; i++) { 147 thrd = thread_create(writer, NULL, the->task, 0);147 thrd = thread_create(writer, NULL, TASK, 0); 148 148 if (thrd) 149 149 thread_ready(thrd); -
test/synch/rwlock5/test.c
re6ba9a3f r43114c5 96 96 for (j=0; j<(READERS+WRITERS)/2; j++) { 97 97 for (k=0; k<i; k++) { 98 thrd = thread_create(reader, NULL, the->task, 0);98 thrd = thread_create(reader, NULL, TASK, 0); 99 99 if (thrd) 100 100 thread_ready(thrd); … … 103 103 } 104 104 for (k=0; k<(4-i); k++) { 105 thrd = thread_create(writer, NULL, the->task, 0);105 thrd = thread_create(writer, NULL, TASK, 0); 106 106 if (thrd) 107 107 thread_ready(thrd); -
test/synch/semaphore1/test.c
re6ba9a3f r43114c5 100 100 for (j=0; j<(CONSUMERS+PRODUCERS)/2; j++) { 101 101 for (k=0; k<i; k++) { 102 thrd = thread_create(consumer, NULL, the->task, 0);102 thrd = thread_create(consumer, NULL, TASK, 0); 103 103 if (thrd) 104 104 thread_ready(thrd); … … 107 107 } 108 108 for (k=0; k<(4-i); k++) { 109 thrd = thread_create(producer, NULL, the->task, 0);109 thrd = thread_create(producer, NULL, TASK, 0); 110 110 if (thrd) 111 111 thread_ready(thrd); -
test/synch/semaphore2/test.c
re6ba9a3f r43114c5 70 70 71 71 to = random(20000); 72 printf("cpu%d, tid %d down+ (%d)\n", the->cpu->id, the->thread->tid, to);72 printf("cpu%d, tid %d down+ (%d)\n", CPU->id, THREAD->tid, to); 73 73 rc = semaphore_down_timeout(&sem, to); 74 74 if (SYNCH_FAILED(rc)) { 75 printf("cpu%d, tid %d down!\n", the->cpu->id, the->thread->tid);75 printf("cpu%d, tid %d down!\n", CPU->id, THREAD->tid); 76 76 return; 77 77 } 78 78 79 printf("cpu%d, tid %d down=\n", the->cpu->id, the->thread->tid);79 printf("cpu%d, tid %d down=\n", CPU->id, THREAD->tid); 80 80 thread_usleep(random(30000)); 81 81 82 82 semaphore_up(&sem); 83 printf("cpu%d, tid %d up\n", the->cpu->id, the->thread->tid);83 printf("cpu%d, tid %d up\n", CPU->id, THREAD->tid); 84 84 } 85 85 … … 108 108 printf("Creating %d consumers\n", k); 109 109 for (i=0; i<k; i++) { 110 thrd = thread_create(consumer, NULL, the->task, 0);110 thrd = thread_create(consumer, NULL, TASK, 0); 111 111 if (thrd) 112 112 thread_ready(thrd);
Note:
See TracChangeset
for help on using the changeset viewer.
