Changeset 452268a in mainline
- Timestamp:
- 2010-04-03T16:52:07Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- acc3f745
- Parents:
- ee35ba0b
- Location:
- uspace/app/top
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/top/ps.c
ree35ba0b r452268a 58 58 }; 59 59 60 unsigned int get_tasks(task_i d_t **out_tasks)60 unsigned int get_tasks(task_info_t **out_infos) 61 61 { 62 62 int task_count = TASK_COUNT; … … 70 70 } 71 71 72 /*73 72 int i; 73 task_info_t *taskinfos = malloc(result * sizeof(task_info_t)); 74 74 for (i = 0; i < result; ++i) { 75 task_info_t taskinfo; 76 get_task_info(tasks[i], &taskinfo); 75 get_task_info(tasks[i], &taskinfos[i]); 77 76 } 78 */79 77 80 *out_ tasks = tasks;78 *out_infos = taskinfos; 81 79 return result; 82 80 } -
uspace/app/top/ps.h
ree35ba0b r452268a 39 39 40 40 extern const char *thread_states[]; 41 extern unsigned int get_tasks(task_i d_t **out_tasks);41 extern unsigned int get_tasks(task_info_t **out_infos); 42 42 extern thread_info_t *get_threads(task_id_t taskid); 43 43 extern unsigned int get_cpu_infos(uspace_cpu_info_t **out_infos); -
uspace/app/top/screen.c
ree35ba0b r452268a 53 53 static void print_float(float f, int precision) 54 54 { 55 printf("% u.", (unsigned int) f);55 printf("%2u.", (unsigned int) f); 56 56 int i; 57 57 float rest = (f - (int)f) * 10; … … 141 141 if (row + i > rows) 142 142 return; 143 task_info_t taskinfo; 144 get_task_info(data->tasks[i], &taskinfo); 145 printf("%8llu %8u %8u %12llu %12llu %s\n", taskinfo.taskid, 146 taskinfo.thread_count, taskinfo.pages, taskinfo.ucycles / 1000 / 1000, 147 taskinfo.kcycles / 1000 / 1000, taskinfo.name); 143 task_info_t *taskinfo = &data->taskinfos[i]; 144 printf("%8llu %8u %8u ", taskinfo->taskid, 145 taskinfo->thread_count, taskinfo->pages); 146 task_perc_t *taskperc = &data->task_perc[i]; 147 puts(" "); 148 print_float(taskperc->pages, 2); 149 puts("% "); 150 print_float(taskperc->ucycles, 2); 151 puts("% "); 152 print_float(taskperc->kcycles, 2); 153 puts("% "); 154 printf("%s\n", taskinfo->name); 148 155 } 149 156 } … … 153 160 fflush(stdout); 154 161 console_set_rgb_color(fphone(stdout), WHITE, BLACK); 155 printf(" ID Threads Pages uCycleskCycles Name");162 printf(" ID Threads Pages %%Pages %%uCycles %%kCycles Name"); 156 163 int i; 157 164 for (i = 60; i < colls; ++i) -
uspace/app/top/top.c
ree35ba0b r452268a 80 80 81 81 /* Read task ids */ 82 target->task_count = get_tasks(&target->task s);82 target->task_count = get_tasks(&target->taskinfos); 83 83 84 84 /* Read cpu infos */ … … 102 102 uint64_t busy = new_data->cpus[i].busy_ticks - old_data->cpus[i].busy_ticks; 103 103 uint64_t sum = idle + busy; 104 new_data->cpu_perc[i].idle = ((float)(idle * 100) / sum); 105 new_data->cpu_perc[i].busy = ((float)(busy * 100) / sum); 106 } 104 new_data->cpu_perc[i].idle = (float)(idle * 100) / sum; 105 new_data->cpu_perc[i].busy = (float)(busy * 100) / sum; 106 } 107 108 /* For all tasks compute sum and differencies of all cycles */ 109 uint64_t pages_total = 0; 110 uint64_t ucycles_total = 0; 111 uint64_t kcycles_total = 0; 112 uint64_t *ucycles_diff = malloc(new_data->task_count * sizeof(uint64_t)); 113 uint64_t *kcycles_diff = malloc(new_data->task_count * sizeof(uint64_t)); 114 unsigned int j = 0; 115 for (i = 0; i < new_data->task_count; ++i) { 116 /* Jump over all death tasks */ 117 while (old_data->taskinfos[j].taskid < new_data->taskinfos[i].taskid) 118 ++j; 119 if (old_data->taskinfos[j].taskid > new_data->taskinfos[i].taskid) { 120 /* This is newly borned task, ignore it */ 121 ucycles_diff[i] = 0; 122 kcycles_diff[i] = 0; 123 continue; 124 } 125 /* Now we now we have task with same id */ 126 ucycles_diff[i] = new_data->taskinfos[i].ucycles - old_data->taskinfos[j].ucycles; 127 kcycles_diff[i] = new_data->taskinfos[i].kcycles - old_data->taskinfos[j].kcycles; 128 129 pages_total += new_data->taskinfos[i].pages; 130 ucycles_total += ucycles_diff[i]; 131 kcycles_total += kcycles_diff[i]; 132 } 133 134 /* And now compute percental change */ 135 new_data->task_perc = malloc(new_data->task_count * sizeof(task_perc_t)); 136 for (i = 0; i < new_data->task_count; ++i) { 137 new_data->task_perc[i].pages = (float)(new_data->taskinfos[i].pages * 100) / pages_total; 138 new_data->task_perc[i].ucycles = (float)(ucycles_diff[i] * 100) / ucycles_total; 139 new_data->task_perc[i].kcycles = (float)(kcycles_diff[i] * 100) / kcycles_total; 140 } 141 142 /* And free temporary structures */ 143 free(ucycles_diff); 144 free(kcycles_diff); 107 145 } 108 146 109 147 static void free_data(data_t *target) 110 148 { 111 free(target->task s);149 free(target->taskinfos); 112 150 free(target->cpus); 113 151 free(target->cpu_perc); 152 free(target->task_perc); 114 153 } 115 154 -
uspace/app/top/top.h
ree35ba0b r452268a 36 36 #include <task.h> 37 37 #include <kernel/ps/cpuinfo.h> 38 #include <kernel/ps/taskinfo.h> 38 39 39 40 typedef struct { … … 43 44 44 45 typedef struct { 45 float u ser;46 float system;47 float memory;46 float ucycles; 47 float kcycles; 48 float pages; 48 49 } task_perc_t; 49 50 … … 61 62 62 63 unsigned int task_count; 63 task_id_t *tasks; 64 task_info_t *taskinfos; 65 task_perc_t *task_perc; 64 66 65 67 unsigned int cpu_count;
Note:
See TracChangeset
for help on using the changeset viewer.