Changeset 62b6d17 in mainline
- Timestamp:
- 2006-12-14T16:47:36Z (18 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- aeaebcc
- Parents:
- 55cc9bc
- Location:
- kernel
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/proc/thread.h
r55cc9bc r62b6d17 149 149 uint64_t cycles; /**< Thread accounting. */ 150 150 uint64_t last_cycle; /**< Last sampled cycle. */ 151 bool uncounted; /**< Thread doesn't affect accumulated accounting. */ 151 152 152 153 int priority; /**< Thread's priority. Implemented as index to CPU->rq */ … … 169 170 170 171 extern void thread_init(void); 171 extern thread_t *thread_create(void (* func)(void *), void *arg, task_t *task, int flags, char *name );172 extern thread_t *thread_create(void (* func)(void *), void *arg, task_t *task, int flags, char *name, bool uncounted); 172 173 extern void thread_ready(thread_t *t); 173 174 extern void thread_exit(void) __attribute__((noreturn)); -
kernel/generic/src/console/cmd.c
r55cc9bc r62b6d17 57 57 #include <mm/tlb.h> 58 58 #include <arch/mm/tlb.h> 59 #include <mm/as.h>60 59 #include <mm/frame.h> 61 60 #include <main/version.h> … … 860 859 } 861 860 862 static void test_wrapper(void *arg)863 { 864 test_t *test = (test_t *) arg;861 static bool run_test(const test_t *test) 862 { 863 printf("%s\t\t%s\n", test->name, test->desc); 865 864 866 865 /* Update and read thread accounting … … 886 885 if (ret == NULL) { 887 886 printf("Test passed\n"); 888 // return true; 889 return; 887 return true; 890 888 } 891 889 892 890 printf("%s\n", ret); 893 // return false; 894 } 895 896 static bool run_test(const test_t *test) 897 { 898 printf("%s\t\t%s\n", test->name, test->desc); 899 900 /* Create separate task and thread 901 for the test */ 902 task_t *ta = task_create(AS_KERNEL, "test"); 903 if (ta == NULL) { 904 printf("Unable to create test task\n"); 905 return false; 906 } 907 908 thread_t *t = thread_create(test_wrapper, (void *) test, ta, 0, "test_main"); 909 if (t == NULL) { 910 printf("Unable to create test main thread\n"); 911 task_destroy(ta); 912 return false; 913 } 914 915 /* Run the test */ 916 thread_ready(t); 917 thread_join(t); 918 thread_detach(t); 919 920 return true; 891 return false; 921 892 } 922 893 -
kernel/generic/src/main/kinit.c
r55cc9bc r62b6d17 99 99 * Just a beautification. 100 100 */ 101 if ((t = thread_create(kmp, NULL, TASK, THREAD_FLAG_WIRED, "kmp" ))) {101 if ((t = thread_create(kmp, NULL, TASK, THREAD_FLAG_WIRED, "kmp", true))) { 102 102 spinlock_lock(&t->lock); 103 103 t->cpu = &cpus[0]; … … 124 124 for (i = 0; i < config.cpu_count; i++) { 125 125 126 if ((t = thread_create(kcpulb, NULL, TASK, THREAD_FLAG_WIRED, "kcpulb" ))) {126 if ((t = thread_create(kcpulb, NULL, TASK, THREAD_FLAG_WIRED, "kcpulb", true))) { 127 127 spinlock_lock(&t->lock); 128 128 t->cpu = &cpus[i]; … … 144 144 * Create kernel console. 145 145 */ 146 if ((t = thread_create(kconsole, "kconsole", TASK, 0, "kconsole" )))146 if ((t = thread_create(kconsole, "kconsole", TASK, 0, "kconsole", false))) 147 147 thread_ready(t); 148 148 else -
kernel/generic/src/main/main.c
r55cc9bc r62b6d17 267 267 * Create the first thread. 268 268 */ 269 t = thread_create(kinit, NULL, k, 0, "kinit" );269 t = thread_create(kinit, NULL, k, 0, "kinit", true); 270 270 if (!t) 271 271 panic("can't create kinit thread\n"); -
kernel/generic/src/proc/task.c
r55cc9bc r62b6d17 221 221 * Create the main thread. 222 222 */ 223 t1 = thread_create(uinit, kernel_uarg, task, THREAD_FLAG_USPACE, "uinit" );223 t1 = thread_create(uinit, kernel_uarg, task, THREAD_FLAG_USPACE, "uinit", false); 224 224 ASSERT(t1); 225 225 … … 227 227 * Create killer thread for the new task. 228 228 */ 229 t2 = thread_create(ktaskgc, t1, task, 0, "ktaskgc" );229 t2 = thread_create(ktaskgc, t1, task, 0, "ktaskgc", true); 230 230 ASSERT(t2); 231 231 thread_ready(t2); … … 286 286 287 287 spinlock_lock(&thr->lock); 288 289 if (thr == THREAD) /* Update accounting of current thread */ 290 thread_update_accounting(); 291 ret += thr->cycles; 292 288 /* Process only counted threads */ 289 if (!thr->uncounted) { 290 if (thr == THREAD) /* Update accounting of current thread */ 291 thread_update_accounting(); 292 ret += thr->cycles; 293 } 293 294 spinlock_unlock(&thr->lock); 294 295 } … … 329 330 spinlock_unlock(&tasks_lock); 330 331 331 t = thread_create(ktaskclnp, NULL, ta, 0, "ktaskclnp" );332 t = thread_create(ktaskclnp, NULL, ta, 0, "ktaskclnp", true); 332 333 333 334 spinlock_lock(&ta->lock); -
kernel/generic/src/proc/thread.c
r55cc9bc r62b6d17 124 124 125 125 spinlock_lock(&THREAD->lock); 126 thread_update_accounting(); 127 uint64_t cycles = THREAD->cycles; 128 THREAD->cycles = 0; 129 spinlock_unlock(&THREAD->lock); 130 131 spinlock_lock(&TASK->lock); 132 TASK->cycles += cycles; 133 spinlock_unlock(&TASK->lock); 126 if (!THREAD->uncounted) { 127 thread_update_accounting(); 128 uint64_t cycles = THREAD->cycles; 129 THREAD->cycles = 0; 130 spinlock_unlock(&THREAD->lock); 131 132 spinlock_lock(&TASK->lock); 133 TASK->cycles += cycles; 134 spinlock_unlock(&TASK->lock); 135 } else 136 spinlock_unlock(&THREAD->lock); 134 137 135 138 interrupts_restore(ipl); … … 303 306 * Create a new thread. 304 307 * 305 * @param func Thread's implementing function. 306 * @param arg Thread's implementing function argument. 307 * @param task Task to which the thread belongs. 308 * @param flags Thread flags. 309 * @param name Symbolic name. 308 * @param func Thread's implementing function. 309 * @param arg Thread's implementing function argument. 310 * @param task Task to which the thread belongs. 311 * @param flags Thread flags. 312 * @param name Symbolic name. 313 * @param uncounted Thread's accounting doesn't affect accumulated task accounting. 310 314 * 311 315 * @return New thread's structure on success, NULL on failure. 312 316 * 313 317 */ 314 thread_t *thread_create(void (* func)(void *), void *arg, task_t *task, int flags, char *name )318 thread_t *thread_create(void (* func)(void *), void *arg, task_t *task, int flags, char *name, bool uncounted) 315 319 { 316 320 thread_t *t; … … 345 349 t->ticks = -1; 346 350 t->cycles = 0; 351 t->uncounted = uncounted; 347 352 t->priority = -1; /* start in rq[0] */ 348 353 t->cpu = NULL; … … 650 655 } 651 656 652 if ((t = thread_create(uinit, kernel_uarg, TASK, THREAD_FLAG_USPACE, namebuf ))) {657 if ((t = thread_create(uinit, kernel_uarg, TASK, THREAD_FLAG_USPACE, namebuf, false))) { 653 658 tid = t->tid; 654 659 thread_ready(t); -
kernel/test/fpu/fpu1.c
r55cc9bc r62b6d17 186 186 thread_t *t; 187 187 188 if (!(t = thread_create(e, NULL, TASK, 0, "e" ))) {188 if (!(t = thread_create(e, NULL, TASK, 0, "e", false))) { 189 189 printf("could not create thread %d\n", 2 * i); 190 190 break; … … 193 193 total++; 194 194 195 if (!(t = thread_create(pi, NULL, TASK, 0, "pi" ))) {195 if (!(t = thread_create(pi, NULL, TASK, 0, "pi", false))) { 196 196 printf("could not create thread %d\n", 2 * i + 1); 197 197 break; -
kernel/test/fpu/mips2.c
r55cc9bc r62b6d17 123 123 thread_t *t; 124 124 125 if (!(t = thread_create(testit1, (void *) ((unative_t) 2 * i), TASK, 0, "testit1" ))) {125 if (!(t = thread_create(testit1, (void *) ((unative_t) 2 * i), TASK, 0, "testit1", false))) { 126 126 printf("could not create thread %d\n", 2 * i); 127 127 break; … … 130 130 total++; 131 131 132 if (!(t = thread_create(testit2, (void *) ((unative_t) 2 * i + 1), TASK, 0, "testit2" ))) {132 if (!(t = thread_create(testit2, (void *) ((unative_t) 2 * i + 1), TASK, 0, "testit2", false))) { 133 133 printf("could not create thread %d\n", 2 * i + 1); 134 134 break; -
kernel/test/fpu/sse1.c
r55cc9bc r62b6d17 122 122 thread_t *t; 123 123 124 if (!(t = thread_create(testit1, (void *) ((unative_t) 2 * i), TASK, 0, "testit1" ))) {124 if (!(t = thread_create(testit1, (void *) ((unative_t) 2 * i), TASK, 0, "testit1", false))) { 125 125 printf("could not create thread %d\n", 2 * i); 126 126 break; … … 129 129 total++; 130 130 131 if (!(t = thread_create(testit2, (void *) ((unative_t) 2 * i + 1), TASK, 0, "testit2" ))) {131 if (!(t = thread_create(testit2, (void *) ((unative_t) 2 * i + 1), TASK, 0, "testit2", false))) { 132 132 printf("could not create thread %d\n", 2 * i + 1); 133 133 break; -
kernel/test/mm/falloc2.c
r55cc9bc r62b6d17 108 108 109 109 for (i = 0; i < THREADS; i++) { 110 thread_t * thrd = thread_create(falloc, NULL, TASK, 0, "falloc" );110 thread_t * thrd = thread_create(falloc, NULL, TASK, 0, "falloc", false); 111 111 if (!thrd) { 112 112 printf("Could not create thread %d\n", i); -
kernel/test/mm/slab1.c
r55cc9bc r62b6d17 139 139 semaphore_initialize(&thr_sem, 0); 140 140 for (i = 0; i < THREADS; i++) { 141 if (!(t = thread_create(slabtest, (void *) (unative_t) i, TASK, 0, "slabtest" )))141 if (!(t = thread_create(slabtest, (void *) (unative_t) i, TASK, 0, "slabtest", false))) 142 142 printf("Could not create thread %d\n", i); 143 143 else -
kernel/test/mm/slab2.c
r55cc9bc r62b6d17 191 191 semaphore_initialize(&thr_sem,0); 192 192 for (i = 0; i < THREADS; i++) { 193 if (!(t = thread_create(slabtest, NULL, TASK, 0, "slabtest" )))193 if (!(t = thread_create(slabtest, NULL, TASK, 0, "slabtest", false))) 194 194 printf("Could not create thread %d\n", i); 195 195 else -
kernel/test/synch/rwlock2.c
r55cc9bc r62b6d17 67 67 rwlock_read_lock(&rwlock); 68 68 69 thrd = thread_create(writer, NULL, TASK, 0, "writer" );69 thrd = thread_create(writer, NULL, TASK, 0, "writer", false); 70 70 if (thrd) 71 71 thread_ready(thrd); -
kernel/test/synch/rwlock3.c
r55cc9bc r62b6d17 65 65 66 66 for (i = 0; i < 4; i++) { 67 thrd = thread_create(reader, NULL, TASK, 0, "reader" );67 thrd = thread_create(reader, NULL, TASK, 0, "reader", false); 68 68 if (thrd) 69 69 thread_ready(thrd); -
kernel/test/synch/rwlock4.c
r55cc9bc r62b6d17 131 131 printf("Creating %d readers\n", k); 132 132 for (i = 0; i < k; i++) { 133 thrd = thread_create(reader, NULL, TASK, 0, "reader" );133 thrd = thread_create(reader, NULL, TASK, 0, "reader", false); 134 134 if (thrd) 135 135 thread_ready(thrd); … … 141 141 printf("Creating %d writers\n", k); 142 142 for (i = 0; i < k; i++) { 143 thrd = thread_create(writer, NULL, TASK, 0, "writer" );143 thrd = thread_create(writer, NULL, TASK, 0, "writer", false); 144 144 if (thrd) 145 145 thread_ready(thrd); -
kernel/test/synch/rwlock5.c
r55cc9bc r62b6d17 88 88 for (j = 0; j < (READERS + WRITERS) / 2; j++) { 89 89 for (k = 0; k < i; k++) { 90 thrd = thread_create(reader, NULL, TASK, 0, "reader" );90 thrd = thread_create(reader, NULL, TASK, 0, "reader", false); 91 91 if (thrd) 92 92 thread_ready(thrd); … … 95 95 } 96 96 for (k = 0; k < (4 - i); k++) { 97 thrd = thread_create(writer, NULL, TASK, 0, "writer" );97 thrd = thread_create(writer, NULL, TASK, 0, "writer", false); 98 98 if (thrd) 99 99 thread_ready(thrd); -
kernel/test/synch/semaphore1.c
r55cc9bc r62b6d17 91 91 for (j = 0; j < (CONSUMERS + PRODUCERS) / 2; j++) { 92 92 for (k = 0; k < i; k++) { 93 thrd = thread_create(consumer, NULL, TASK, 0, "consumer" );93 thrd = thread_create(consumer, NULL, TASK, 0, "consumer", false); 94 94 if (thrd) 95 95 thread_ready(thrd); … … 98 98 } 99 99 for (k = 0; k < (4 - i); k++) { 100 thrd = thread_create(producer, NULL, TASK, 0, "producer" );100 thrd = thread_create(producer, NULL, TASK, 0, "producer", false); 101 101 if (thrd) 102 102 thread_ready(thrd); -
kernel/test/synch/semaphore2.c
r55cc9bc r62b6d17 94 94 printf("Creating %d consumers\n", k); 95 95 for (i = 0; i < k; i++) { 96 thrd = thread_create(consumer, NULL, TASK, 0, "consumer" );96 thrd = thread_create(consumer, NULL, TASK, 0, "consumer", false); 97 97 if (thrd) 98 98 thread_ready(thrd); -
kernel/test/thread/thread1.c
r55cc9bc r62b6d17 62 62 for (i = 0; i < THREADS; i++) { 63 63 thread_t *t; 64 if (!(t = thread_create(threadtest, NULL, TASK, 0, "threadtest" ))) {64 if (!(t = thread_create(threadtest, NULL, TASK, 0, "threadtest", false))) { 65 65 printf("Could not create thread %d\n", i); 66 66 break;
Note:
See TracChangeset
for help on using the changeset viewer.