Changeset cce6acf in mainline
- Timestamp:
- 2006-12-13T12:10:23Z (18 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e9db6f9e
- Parents:
- 7e13972
- Location:
- kernel
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/Makefile
r7e13972 rcce6acf 118 118 DEFS += -DCONFIG_VESA_BPP=$(CONFIG_VESA_BPP) 119 119 endif 120 endif121 122 ifeq ($(CONFIG_BENCH),y)123 DEFS += -DCONFIG_BENCH124 120 endif 125 121 -
kernel/generic/include/proc/thread.h
r7e13972 rcce6acf 146 146 147 147 uint64_t ticks; /**< Ticks before preemption. */ 148 149 uint64_t cycles; /**< Task accounting. */ 150 uint64_t last_cycle; /**< Last sampled cycle. */ 148 151 149 152 int priority; /**< Thread's priority. Implemented as index to CPU->rq */ … … 190 193 extern void thread_print_list(void); 191 194 extern void thread_destroy(thread_t *t); 195 extern void thread_update_accounting(void); 192 196 extern bool thread_exists(thread_t *t); 193 197 -
kernel/generic/src/console/cmd.c
r7e13972 rcce6acf 68 68 #ifdef CONFIG_TEST 69 69 #include <test.h> 70 #endif71 72 #ifdef CONFIG_BENCH73 #include <arch/cycle.h>74 70 #endif 75 71 … … 866 862 { 867 863 printf("%s\t\t%s\n", test->name, test->desc); 868 #ifdef CONFIG_BENCH 869 uint64_t t0 = get_cycle(); 870 #endif 864 865 /* Update and read thread accounting 866 for benchmarking */ 867 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); 872 interrupts_restore(ipl); 873 874 /* Execute the test */ 871 875 char * ret = test->entry(); 872 #ifdef CONFIG_BENCH 873 uint64_t dt = get_cycle() - t0; 876 877 /* Update and read thread accounting */ 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); 883 interrupts_restore(ipl); 884 874 885 printf("Time: %llu cycles\n", dt); 875 #endif876 886 877 887 if (ret == NULL) { -
kernel/generic/src/proc/scheduler.c
r7e13972 rcce6acf 48 48 #include <arch/asm.h> 49 49 #include <arch/faddr.h> 50 #include <arch/cycle.h> 50 51 #include <atomic.h> 51 52 #include <synch/spinlock.h> … … 309 310 if (THREAD) { 310 311 spinlock_lock(&THREAD->lock); 312 313 /* Update thread accounting */ 314 THREAD->cycles += get_cycle() - THREAD->last_cycle; 315 311 316 #ifndef CONFIG_FPU_LAZY 312 317 fpu_context_save(THREAD->saved_fpu_context); … … 316 321 * This is the place where threads leave scheduler(); 317 322 */ 323 324 /* Save current CPU cycle */ 325 THREAD->last_cycle = get_cycle(); 326 318 327 spinlock_unlock(&THREAD->lock); 319 328 interrupts_restore(THREAD->saved_context.ipl); -
kernel/generic/src/proc/thread.c
r7e13972 rcce6acf 43 43 #include <mm/page.h> 44 44 #include <arch/asm.h> 45 #include <arch/cycle.h> 45 46 #include <arch.h> 46 47 #include <synch/synch.h> … … 326 327 t->thread_arg = arg; 327 328 t->ticks = -1; 329 t->cycles = 0; 328 330 t->priority = -1; /* start in rq[0] */ 329 331 t->cpu = NULL; … … 530 532 ipl = interrupts_disable(); 531 533 spinlock_lock(&threads_lock); 534 535 printf("tid name address state task ctx code stack cycles cpu kst wq\n"); 536 printf("------ ---------- ---------- -------- ---------- --- ---------- ---------- ---------- ---- ---------- ----------\n"); 532 537 533 538 for (cur = threads_btree.leaf_head.next; cur != &threads_btree.leaf_head; cur = cur->next) { … … 540 545 541 546 t = (thread_t *) node->value[i]; 542 printf("%s: address=%#zx, tid=%zd, state=%s, task=%#zx, context=%ld, code=%#zx, stack=%#zx, cpu=", 543 t->name, t, t->tid, thread_states[t->state], t->task, t->task->context, t->thread_code, t->kstack); 547 548 uint64_t cycles; 549 char suffix; 550 551 if (t->cycles > 1000000000000000000LL) { 552 cycles = t->cycles / 1000000000000000000LL; 553 suffix = 'E'; 554 } else if (t->cycles > 1000000000000LL) { 555 cycles = t->cycles / 1000000000000LL; 556 suffix = 'T'; 557 } else if (t->cycles > 1000000LL) { 558 cycles = t->cycles / 1000000LL; 559 suffix = 'M'; 560 } else { 561 cycles = t->cycles; 562 suffix = ' '; 563 } 564 565 printf("%-6zd %-10s %#10zx %-8s %#10zx %-3ld %#10zx %#10zx %9llu%c ", t->tid, t->name, t, thread_states[t->state], t->task, t->task->context, t->thread_code, t->kstack, cycles, suffix); 566 544 567 if (t->cpu) 545 printf(" cpu%zd", t->cpu->id);568 printf("%-4zd", t->cpu->id); 546 569 else 547 570 printf("none"); 548 if (t->state == Sleeping) {549 printf(", kst=%#zx", t->kstack);550 printf(" , wq=%#zx", t->sleep_queue);551 }571 572 if (t->state == Sleeping) 573 printf(" %#10zx %#10zx", t->kstack, t->sleep_queue); 574 552 575 printf("\n"); 553 576 } … … 572 595 573 596 return btree_search(&threads_btree, (btree_key_t) ((uintptr_t) t), &leaf) != NULL; 597 } 598 599 600 /** Update accounting of current thread. 601 * 602 * Note that thread_lock on THREAD must be already held and 603 * interrupts must be already disabled. 604 * 605 * @param t Pointer to thread. 606 * 607 */ 608 void thread_update_accounting(void) 609 { 610 uint64_t time = get_cycle(); 611 THREAD->cycles += time - THREAD->last_cycle; 612 THREAD->last_cycle = time; 574 613 } 575 614 -
kernel/kernel.config
r7e13972 rcce6acf 121 121 # Compile kernel tests 122 122 ! CONFIG_TEST (y/n) 123 124 # Benchmark tests125 ! [CONFIG_TEST=y] CONFIG_BENCH (y/n)
Note:
See TracChangeset
for help on using the changeset viewer.