Changeset e43cdac in mainline
- Timestamp:
- 2010-04-13T12:57:05Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a307beb
- Parents:
- 638927a
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/ps/taskinfo.h
r638927a re43cdac 77 77 state_t state; 78 78 int priority; 79 uint64_t cycles;80 79 uint64_t ucycles; 81 80 uint64_t kcycles; -
uspace/app/top/screen.c
r638927a re43cdac 52 52 #define BLACK 0x000000 53 53 54 static void print_float( float f, int precision)55 { 56 printf("%2u.", (unsigned int) f);54 static void print_float(ps_float f, int precision) 55 { 56 printf("%2u.", f.upper / f.lower); 57 57 int i; 58 float rest = (f - (int)f) * 10;58 unsigned int rest = (f.upper % f.lower) * 10; 59 59 for (i = 0; i < precision; ++i) { 60 printf("%d", (unsigned int)rest);61 rest = (rest - (int)rest) * 10;60 printf("%d", rest / f.lower); 61 rest = (rest % f.lower) * 10; 62 62 } 63 63 } … … 208 208 fflush(stdout); 209 209 console_set_rgb_color(fphone(stdout), WHITE, BLACK); 210 printf(" ID Threads Mem %%Mem %%uCycles %%kCycles Name");210 printf(" ID Threads Mem %%Mem %%uCycles %%kCycles Name"); 211 211 int i; 212 for (i = 6 0; i < colls; ++i)212 for (i = 61; i < colls; ++i) 213 213 puts(" "); 214 214 fflush(stdout); -
uspace/app/top/top.c
r638927a re43cdac 110 110 uint64_t busy = new_data->cpus[i].busy_ticks - old_data->cpus[i].busy_ticks; 111 111 uint64_t sum = idle + busy; 112 new_data->cpu_perc[i].idle = (float)(idle * 100) / sum;113 new_data->cpu_perc[i].busy = (float)(busy * 100) / sum;112 FRACTION_TO_FLOAT(new_data->cpu_perc[i].idle, idle * 100, sum); 113 FRACTION_TO_FLOAT(new_data->cpu_perc[i].busy, busy * 100, sum); 114 114 } 115 115 … … 143 143 new_data->task_perc = malloc(new_data->task_count * sizeof(task_perc_t)); 144 144 for (i = 0; i < new_data->task_count; ++i) { 145 new_data->task_perc[i].mem = (float)(new_data->taskinfos[i].virt_mem * 100) / mem_total;146 new_data->task_perc[i].ucycles = (float)(ucycles_diff[i] * 100) / ucycles_total;147 new_data->task_perc[i].kcycles = (float)(kcycles_diff[i] * 100) / kcycles_total;145 FRACTION_TO_FLOAT(new_data->task_perc[i].mem, new_data->taskinfos[i].virt_mem * 100, mem_total); 146 FRACTION_TO_FLOAT(new_data->task_perc[i].ucycles, ucycles_diff[i] * 100, ucycles_total); 147 FRACTION_TO_FLOAT(new_data->task_perc[i].kcycles, kcycles_diff[i] * 100, kcycles_total); 148 148 } 149 149 -
uspace/app/top/top.h
r638927a re43cdac 38 38 #include <kernel/ps/taskinfo.h> 39 39 40 #define FRACTION_TO_FLOAT(float, a, b) { \ 41 (float).upper = (a); \ 42 (float).lower = (b); \ 43 } 44 40 45 typedef struct { 41 float idle; 42 float busy; 46 uint64_t upper; 47 uint64_t lower; 48 } ps_float; 49 50 typedef struct { 51 ps_float idle; 52 ps_float busy; 43 53 } cpu_perc_t; 44 54 45 55 typedef struct { 46 float ucycles;47 float kcycles;48 float mem;56 ps_float ucycles; 57 ps_float kcycles; 58 ps_float mem; 49 59 } task_perc_t; 50 60
Note:
See TracChangeset
for help on using the changeset viewer.