Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 452268a in mainline


Ignore:
Timestamp:
2010-04-03T16:52:07Z (12 years ago)
Author:
Stanislav Kozina <stanislav.kozina@…>
Branches:
lfn, master
Children:
acc3f745
Parents:
ee35ba0b
Message:

top echoes also percentage differencies of task cycles

Location:
uspace/app/top
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/top/ps.c

    ree35ba0b r452268a  
    5858};
    5959
    60 unsigned int get_tasks(task_id_t **out_tasks)
     60unsigned int get_tasks(task_info_t **out_infos)
    6161{
    6262        int task_count = TASK_COUNT;
     
    7070        }
    7171
    72 /*
    7372        int i;
     73        task_info_t *taskinfos = malloc(result * sizeof(task_info_t));
    7474        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]);
    7776        }
    78         */
    7977
    80         *out_tasks = tasks;
     78        *out_infos = taskinfos;
    8179        return result;
    8280}
  • uspace/app/top/ps.h

    ree35ba0b r452268a  
    3939
    4040extern const char *thread_states[];
    41 extern unsigned int get_tasks(task_id_t **out_tasks);
     41extern unsigned int get_tasks(task_info_t **out_infos);
    4242extern thread_info_t *get_threads(task_id_t taskid);
    4343extern unsigned int get_cpu_infos(uspace_cpu_info_t **out_infos);
  • uspace/app/top/screen.c

    ree35ba0b r452268a  
    5353static void print_float(float f, int precision)
    5454{
    55         printf("%u.", (unsigned int) f);
     55        printf("%2u.", (unsigned int) f);
    5656        int i;
    5757        float rest = (f - (int)f) * 10;
     
    141141                if (row + i > rows)
    142142                        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);
    148155        }
    149156}
     
    153160        fflush(stdout);
    154161        console_set_rgb_color(fphone(stdout), WHITE, BLACK);
    155         printf("      ID  Threads    Pages      uCycles      kCycles Name");
     162        printf("      ID  Threads    Pages    %%Pages %%uCycles %%kCycles Name");
    156163        int i;
    157164        for (i = 60; i < colls; ++i)
  • uspace/app/top/top.c

    ree35ba0b r452268a  
    8080
    8181        /* Read task ids */
    82         target->task_count = get_tasks(&target->tasks);
     82        target->task_count = get_tasks(&target->taskinfos);
    8383
    8484        /* Read cpu infos */
     
    102102                uint64_t busy = new_data->cpus[i].busy_ticks - old_data->cpus[i].busy_ticks;
    103103                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);
    107145}
    108146
    109147static void free_data(data_t *target)
    110148{
    111         free(target->tasks);
     149        free(target->taskinfos);
    112150        free(target->cpus);
    113151        free(target->cpu_perc);
     152        free(target->task_perc);
    114153}
    115154
  • uspace/app/top/top.h

    ree35ba0b r452268a  
    3636#include <task.h>
    3737#include <kernel/ps/cpuinfo.h>
     38#include <kernel/ps/taskinfo.h>
    3839
    3940typedef struct {
     
    4344
    4445typedef struct {
    45         float user;
    46         float system;
    47         float memory;
     46        float ucycles;
     47        float kcycles;
     48        float pages;
    4849} task_perc_t;
    4950
     
    6162
    6263        unsigned int task_count;
    63         task_id_t *tasks;
     64        task_info_t *taskinfos;
     65        task_perc_t *task_perc;
    6466
    6567        unsigned int cpu_count;
Note: See TracChangeset for help on using the changeset viewer.