Changeset 1ba37fa in mainline
- Timestamp:
- 2010-04-06T11:53:32Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 516adce
- Parents:
- f0dcdc5
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/proc/task.h
rf0dcdc5 r1ba37fa 122 122 123 123 /** Accumulated accounting. */ 124 uint64_t cycles;125 124 uint64_t ucycles; 126 125 uint64_t kcycles; … … 136 135 extern task_t *task_find_by_id(task_id_t id); 137 136 extern int task_kill(task_id_t id); 138 extern uint64_ttask_get_accounting(task_t *t, uint64_t *ucycles, uint64_t *kcycles);137 extern void task_get_accounting(task_t *t, uint64_t *ucycles, uint64_t *kcycles); 139 138 extern void task_print_list(void); 140 139 -
kernel/generic/include/proc/thread.h
rf0dcdc5 r1ba37fa 174 174 175 175 /** Thread accounting. */ 176 uint64_t cycles;177 176 uint64_t ucycles; 178 177 uint64_t kcycles; -
kernel/generic/include/ps/taskinfo.h
rf0dcdc5 r1ba37fa 50 50 size_t pages; 51 51 int thread_count; 52 uint64_t cycles;53 52 uint64_t ucycles; 54 53 uint64_t kcycles; -
kernel/generic/src/console/cmd.c
rf0dcdc5 r1ba37fa 1027 1027 ipl_t ipl = interrupts_disable(); 1028 1028 spinlock_lock(&TASK->lock); 1029 uint64_t ucycles , kcycles;1030 uint64_t t0 = task_get_accounting(TASK, &ucycles, &kcycles);1029 uint64_t ucycles0, kcycles0; 1030 task_get_accounting(TASK, &ucycles0, &kcycles0); 1031 1031 spinlock_unlock(&TASK->lock); 1032 1032 interrupts_restore(ipl); … … 1037 1037 1038 1038 /* Update and read thread accounting */ 1039 uint64_t ucycles1, kcycles1; 1039 1040 ipl = interrupts_disable(); 1040 1041 spinlock_lock(&TASK->lock); 1041 uint64_t dt = task_get_accounting(TASK, &ucycles, &kcycles) - t0;1042 task_get_accounting(TASK, &ucycles1, &kcycles1); 1042 1043 spinlock_unlock(&TASK->lock); 1043 1044 interrupts_restore(ipl); 1044 1045 1045 uint64_t cycles; 1046 char suffix; 1047 order(dt, &cycles, &suffix); 1048 1049 printf("Time: %" PRIu64 "%c cycles\n", cycles, suffix); 1046 uint64_t ucycles, kcycles; 1047 char usuffix, ksuffix; 1048 order(ucycles1 - ucycles0, &ucycles, &usuffix); 1049 order(kcycles1 - kcycles0, &kcycles, &ksuffix); 1050 1051 printf("Time: %" PRIu64 "%c user cycles, %" PRIu64 "%c kernel cycles\n", 1052 ucycles, usuffix, kcycles, ksuffix); 1050 1053 1051 1054 if (ret == NULL) { … … 1062 1065 uint32_t i; 1063 1066 bool ret = true; 1064 uint64_t cycles;1065 char suffix;1067 uint64_t ucycles, kcycles; 1068 char usuffix, ksuffix; 1066 1069 1067 1070 if (cnt < 1) … … 1081 1084 ipl_t ipl = interrupts_disable(); 1082 1085 spinlock_lock(&TASK->lock); 1083 uint64_t ucycles , kcycles;1084 uint64_t t0 = task_get_accounting(TASK, &ucycles, &kcycles);1086 uint64_t ucycles0, kcycles0; 1087 task_get_accounting(TASK, &ucycles0, &kcycles0); 1085 1088 spinlock_unlock(&TASK->lock); 1086 1089 interrupts_restore(ipl); … … 1093 1096 ipl = interrupts_disable(); 1094 1097 spinlock_lock(&TASK->lock); 1095 uint64_t dt = task_get_accounting(TASK, &ucycles, &kcycles) - t0; 1098 uint64_t ucycles1, kcycles1; 1099 task_get_accounting(TASK, &ucycles1, &kcycles1); 1096 1100 spinlock_unlock(&TASK->lock); 1097 1101 interrupts_restore(ipl); 1098 1102 1099 1103 if (ret != NULL) { 1100 1104 printf("%s\n", ret); … … 1103 1107 } 1104 1108 1105 data[i] = dt; 1106 order(dt, &cycles, &suffix); 1107 printf("OK (%" PRIu64 "%c cycles)\n", cycles, suffix); 1109 data[i] = ucycles1 - ucycles0 + kcycles1 - kcycles0; 1110 order(ucycles1 - ucycles0, &ucycles, &usuffix); 1111 order(kcycles1 - kcycles0, &kcycles, &ksuffix); 1112 printf("OK (%" PRIu64 "%c user cycles, %" PRIu64 "%c kernel cycles)\n", 1113 ucycles, usuffix, kcycles, ksuffix); 1108 1114 } 1109 1115 … … 1117 1123 } 1118 1124 1119 order(sum / (uint64_t) cnt, & cycles, &suffix);1120 printf("Average\t\t%" PRIu64 "%c\n", cycles,suffix);1125 order(sum / (uint64_t) cnt, &ucycles, &usuffix); 1126 printf("Average\t\t%" PRIu64 "%c\n", ucycles, usuffix); 1121 1127 } 1122 1128 -
kernel/generic/src/proc/scheduler.c
rf0dcdc5 r1ba37fa 316 316 spinlock_lock(&THREAD->lock); 317 317 318 /* Update thread accounting */ 319 THREAD->cycles += get_cycle() - THREAD->last_cycle; 318 /* Update thread kernel accounting */ 320 319 THREAD->kcycles += get_cycle() - THREAD->last_cycle; 321 320 -
kernel/generic/src/proc/task.c
rf0dcdc5 r1ba37fa 184 184 ta->context = CONTEXT; 185 185 ta->capabilities = 0; 186 ta->cycles = 0;187 186 ta->ucycles = 0; 188 187 ta->kcycles = 0; … … 322 321 * @param kcycles Out pointer to sum of all kernel cycles. 323 322 */ 324 uint64_ttask_get_accounting(task_t *t, uint64_t *ucycles, uint64_t *kcycles)323 void task_get_accounting(task_t *t, uint64_t *ucycles, uint64_t *kcycles) 325 324 { 326 325 /* Accumulated values of task */ 327 uint64_t ret = t->cycles;328 326 uint64_t uret = t->ucycles; 329 327 uint64_t kret = t->kcycles; … … 343 341 uret += thr->ucycles; 344 342 kret += thr->kcycles; 345 ret += thr->cycles;346 343 } 347 344 spinlock_unlock(&thr->lock); … … 350 347 *ucycles = uret; 351 348 *kcycles = kret; 352 353 return ret;354 349 } 355 350 … … 417 412 spinlock_lock(&t->lock); 418 413 419 uint64_t cycles;420 414 uint64_t ucycles; 421 415 uint64_t kcycles; 422 char suffix, usuffix, ksuffix; 423 cycles = task_get_accounting(t, &ucycles, &kcycles); 424 order(cycles, &cycles, &suffix); 416 char usuffix, ksuffix; 417 task_get_accounting(t, &ucycles, &kcycles); 425 418 order(ucycles, &ucycles, &usuffix); 426 419 order(kcycles, &kcycles, &ksuffix); -
kernel/generic/src/proc/thread.c
rf0dcdc5 r1ba37fa 133 133 if (!THREAD->uncounted) { 134 134 thread_update_accounting(true); 135 uint64_t cycles = THREAD->cycles;136 THREAD->cycles = 0;137 135 uint64_t ucycles = THREAD->ucycles; 138 136 THREAD->ucycles = 0; … … 143 141 144 142 spinlock_lock(&TASK->lock); 145 TASK->cycles += cycles;146 143 TASK->ucycles += ucycles; 147 144 TASK->kcycles += kcycles; … … 330 327 t->thread_arg = arg; 331 328 t->ticks = -1; 332 t->cycles = 0;333 329 t->ucycles = 0; 334 330 t->kcycles = 0; … … 623 619 thread_t *t = avltree_get_instance(node, thread_t, threads_tree_node); 624 620 625 uint64_t cycles, ucycles, kcycles; 626 char suffix, usuffix, ksuffix; 627 order(t->cycles, &cycles, &suffix); 621 uint64_t ucycles, kcycles; 622 char usuffix, ksuffix; 628 623 order(t->ucycles, &ucycles, &usuffix); 629 624 order(t->kcycles, &kcycles, &ksuffix); … … 724 719 { 725 720 uint64_t time = get_cycle(); 726 THREAD->cycles += time - THREAD->last_cycle;727 721 if (user) { 728 722 THREAD->ucycles += time - THREAD->last_cycle; -
kernel/generic/src/ps/ps.c
rf0dcdc5 r1ba37fa 140 140 uint64_t ucycles; 141 141 uint64_t kcycles; 142 uint64_t cycles = task_get_accounting(t, &ucycles, &kcycles); 143 copy_to_uspace(&uspace_info->cycles, &cycles, sizeof(cycles)); 144 copy_to_uspace(&uspace_info->ucycles, &ucycles, sizeof(cycles)); 145 copy_to_uspace(&uspace_info->kcycles, &kcycles, sizeof(cycles)); 142 task_get_accounting(t, &ucycles, &kcycles); 143 copy_to_uspace(&uspace_info->ucycles, &ucycles, sizeof(uint64_t)); 144 copy_to_uspace(&uspace_info->kcycles, &kcycles, sizeof(uint64_t)); 146 145 147 146 size_t pages = get_pages_count(t->as); … … 178 177 result.state = t->state; 179 178 result.priority = t->priority; 180 result.cycles = t->cycles;181 179 result.ucycles = t->ucycles; 182 180 result.kcycles = t->kcycles; -
uspace/app/ps/ps.c
rf0dcdc5 r1ba37fa 82 82 task_info_t taskinfo; 83 83 get_task_info(tasks[i], &taskinfo); 84 uint64_t ucycles, kcycles , fault;85 char usuffix, ksuffix , fsuffix;84 uint64_t ucycles, kcycles; 85 char usuffix, ksuffix; 86 86 order(taskinfo.ucycles, &ucycles, &usuffix); 87 87 order(taskinfo.kcycles, &kcycles, &ksuffix); 88 order((taskinfo.kcycles + taskinfo.ucycles) - taskinfo.cycles, &fault, &fsuffix); 89 printf("%8llu %8u %8u %12llu%c %12llu%c %12llu%c %s\n", tasks[i], 88 printf("%8llu %8u %8u %12llu%c %12llu%c %s\n", tasks[i], 90 89 taskinfo.thread_count, taskinfo.pages, ucycles, usuffix, 91 kcycles, ksuffix, fault, fsuffix,taskinfo.name);90 kcycles, ksuffix, taskinfo.name); 92 91 } 93 92 … … 115 114 printf(" ID State CPU Prio [k]uCycles [k]kcycles Cycle fault\n"); 116 115 for (i = 0; i < result; ++i) { 117 uint64_t ucycles, kcycles , fault;118 char usuffix, ksuffix , fsuffix;116 uint64_t ucycles, kcycles; 117 char usuffix, ksuffix; 119 118 order(threads[i].ucycles, &ucycles, &usuffix); 120 119 order(threads[i].kcycles, &kcycles, &ksuffix); 121 order((threads[i].kcycles + threads[i].ucycles) - threads[i].cycles, &fault, &fsuffix); 122 printf("%6llu %-8s %4u %6d %12llu%c %12llu%c %12llu%c\n", threads[i].tid, 120 printf("%6llu %-8s %4u %6d %12llu%c %12llu%c\n", threads[i].tid, 123 121 thread_states[threads[i].state], threads[i].cpu, 124 122 threads[i].priority, ucycles, usuffix, 125 kcycles, ksuffix , fault, fsuffix);123 kcycles, ksuffix); 126 124 } 127 125
Note:
See TracChangeset
for help on using the changeset viewer.