Changeset 0313ff0 in mainline
- Timestamp:
- 2006-12-14T12:35:57Z (18 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- def5207
- Parents:
- cd896e2
- Location:
- kernel/generic
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/proc/task.h
rcd896e2 r0313ff0 83 83 mutex_t futexes_lock; 84 84 btree_t futexes; /**< B+tree of futexes referenced by this task. */ 85 86 uint64_t cycles; /**< Accumulated accounting. */ 85 87 }; 86 88 … … 94 96 extern task_t *task_find_by_id(task_id_t id); 95 97 extern int task_kill(task_id_t id); 98 extern uint64_t task_get_accounting(task_t *t); 96 99 97 100 -
kernel/generic/src/console/cmd.c
rcd896e2 r0313ff0 57 57 #include <mm/tlb.h> 58 58 #include <arch/mm/tlb.h> 59 #include <mm/as.h> 59 60 #include <mm/frame.h> 60 61 #include <main/version.h> … … 859 860 } 860 861 861 static bool run_test(const test_t * test)862 { 863 printf("%s\t\t%s\n", test->name, test->desc);862 static void test_wrapper(void *arg) 863 { 864 test_t *test = (test_t *) arg; 864 865 865 866 /* Update and read thread accounting 866 867 for benchmarking */ 867 868 ipl_t ipl = interrupts_disable(); 868 spinlock_lock(&THREAD->lock); 869 thread_update_accounting(); 870 uint64_t t0 = THREAD->cycles; 871 spinlock_unlock(&THREAD->lock); 869 spinlock_lock(&TASK->lock); 870 uint64_t t0 = task_get_accounting(TASK); 871 spinlock_unlock(&TASK->lock); 872 872 interrupts_restore(ipl); 873 873 … … 877 877 /* Update and read thread accounting */ 878 878 ipl = interrupts_disable(); 879 spinlock_lock(&THREAD->lock); 880 thread_update_accounting(); 881 uint64_t dt = THREAD->cycles - t0; 882 spinlock_unlock(&THREAD->lock); 879 spinlock_lock(&TASK->lock); 880 uint64_t dt = task_get_accounting(TASK) - t0; 881 spinlock_unlock(&TASK->lock); 883 882 interrupts_restore(ipl); 884 883 … … 887 886 if (ret == NULL) { 888 887 printf("Test passed\n"); 889 return true; 888 // return true; 889 return; 890 890 } 891 891 892 892 printf("%s\n", ret); 893 return false; 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; 894 921 } 895 922 -
kernel/generic/src/main/kinit.c
rcd896e2 r0313ff0 162 162 } 163 163 164 task_t *utask = task_run_program((void *) init.tasks[i].addr, " USPACE");164 task_t *utask = task_run_program((void *) init.tasks[i].addr, "uspace"); 165 165 if (utask) { 166 166 /* -
kernel/generic/src/main/main.c
rcd896e2 r0313ff0 260 260 * Create kernel task. 261 261 */ 262 k = task_create(AS_KERNEL, " KERNEL");262 k = task_create(AS_KERNEL, "kernel"); 263 263 if (!k) 264 264 panic("can't create kernel task\n"); -
kernel/generic/src/proc/task.c
rcd896e2 r0313ff0 120 120 ta->capabilities = 0; 121 121 ta->accept_new_threads = true; 122 ta->cycles = 0; 122 123 123 124 ipc_answerbox_init(&ta->answerbox); … … 267 268 } 268 269 270 /** Get accounting data of given task. 271 * 272 * Note that task_lock on @t must be already held and 273 * interrupts must be already disabled. 274 * 275 * @param t Pointer to thread. 276 * 277 */ 278 uint64_t task_get_accounting(task_t *t) 279 { 280 /* Accumulated value of task */ 281 uint64_t ret = t->cycles; 282 283 /* Current values of threads */ 284 link_t *cur; 285 for (cur = t->th_head.next; cur != &t->th_head; cur = cur->next) { 286 thread_t *thr = list_get_instance(cur, thread_t, th_link); 287 288 spinlock_lock(&thr->lock); 289 290 if (thr == THREAD) /* Update accounting of current thread */ 291 thread_update_accounting(); 292 ret += thr->cycles; 293 294 spinlock_unlock(&thr->lock); 295 } 296 297 return ret; 298 } 299 269 300 /** Kill task. 270 301 * … … 345 376 spinlock_lock(&tasks_lock); 346 377 347 printf("taskid name ctx address as active callscallee\n");348 printf("------ ---------- --- ---------- ---------- ---------- -- ------>\n");378 printf("taskid name ctx address as cycles threads calls callee\n"); 379 printf("------ ---------- --- ---------- ---------- ---------- ------- ------ ------>\n"); 349 380 350 381 for (cur = tasks_btree.leaf_head.next; cur != &tasks_btree.leaf_head; cur = cur->next) { … … 360 391 361 392 spinlock_lock(&t->lock); 362 printf("%-6lld %-10s %-3ld %#10zx %#10zx %12zd", t->taskid, t->name, t->context, t, t->as, atomic_get(&t->active_calls)); 393 394 uint64_t cycles = task_get_accounting(t); 395 char suffix; 396 397 if (cycles > 1000000000000000000LL) { 398 cycles = cycles / 1000000000000000000LL; 399 suffix = 'E'; 400 } else if (cycles > 1000000000000LL) { 401 cycles = cycles / 1000000000000LL; 402 suffix = 'T'; 403 } else if (cycles > 1000000LL) { 404 cycles = cycles / 1000000LL; 405 suffix = 'M'; 406 } else 407 suffix = ' '; 408 409 printf("%-6lld %-10s %-3ld %#10zx %#10zx %9llu%c %7zd %6zd", t->taskid, t->name, t->context, t, t->as, cycles, suffix, t->refcount, atomic_get(&t->active_calls)); 363 410 for (j = 0; j < IPC_MAX_PHONES; j++) { 364 411 if (t->phones[j].callee) … … 366 413 } 367 414 printf("\n"); 415 368 416 spinlock_unlock(&t->lock); 369 417 } -
kernel/generic/src/proc/thread.c
rcd896e2 r0313ff0 114 114 THREAD->last_cycle = get_cycle(); 115 115 116 /* this is where each thread wakes up after its creation */116 /* This is where each thread wakes up after its creation */ 117 117 spinlock_unlock(&THREAD->lock); 118 118 interrupts_enable(); 119 119 120 120 f(arg); 121 122 /* Accumulate accounting to the task */ 123 ipl_t ipl = interrupts_disable(); 124 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); 134 135 interrupts_restore(ipl); 136 121 137 thread_exit(); 122 138 /* not reached */ … … 534 550 spinlock_lock(&threads_lock); 535 551 536 printf("tid name address state task ctx code stack cycles cpu kst wq\n");552 printf("tid name address state task ctx code stack cycles cpu kstack waitqueue\n"); 537 553 printf("------ ---------- ---------- -------- ---------- --- ---------- ---------- ---------- ---- ---------- ----------\n"); 538 554 … … 604 620 * interrupts must be already disabled. 605 621 * 606 * @param t Pointer to thread.607 *608 622 */ 609 623 void thread_update_accounting(void)
Note:
See TracChangeset
for help on using the changeset viewer.