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

Changeset e43cdac in mainline


Ignore:
Timestamp:
2010-04-13T12:57:05Z (12 years ago)
Author:
Stanislav Kozina <stanislav.kozina@…>
Branches:
lfn, master
Children:
a307beb
Parents:
638927a
Message:

Removed all floating point computation from top utility.
Now all percentages are computed using fixed point.
FPU was emmiting exception 16 when storing float from FP register into the
memory and I really cannot figure out why:-(

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/ps/taskinfo.h

    r638927a re43cdac  
    7777        state_t state;
    7878        int priority;
    79         uint64_t cycles;
    8079        uint64_t ucycles;
    8180        uint64_t kcycles;
  • uspace/app/top/screen.c

    r638927a re43cdac  
    5252#define BLACK 0x000000
    5353
    54 static void print_float(float f, int precision)
    55 {
    56         printf("%2u.", (unsigned int) f);
     54static void print_float(ps_float f, int precision)
     55{
     56        printf("%2u.", f.upper / f.lower);
    5757        int i;
    58         float rest = (f - (int)f) * 10;
     58        unsigned int rest = (f.upper % f.lower) * 10;
    5959        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;
    6262        }
    6363}
     
    208208        fflush(stdout);
    209209        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");
    211211        int i;
    212         for (i = 60; i < colls; ++i)
     212        for (i = 61; i < colls; ++i)
    213213                puts(" ");
    214214        fflush(stdout);
  • uspace/app/top/top.c

    r638927a re43cdac  
    110110                uint64_t busy = new_data->cpus[i].busy_ticks - old_data->cpus[i].busy_ticks;
    111111                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);
    114114        }
    115115
     
    143143        new_data->task_perc = malloc(new_data->task_count * sizeof(task_perc_t));
    144144        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);
    148148        }
    149149
  • uspace/app/top/top.h

    r638927a re43cdac  
    3838#include <kernel/ps/taskinfo.h>
    3939
     40#define FRACTION_TO_FLOAT(float, a, b) { \
     41        (float).upper = (a); \
     42        (float).lower = (b); \
     43}
     44
    4045typedef struct {
    41         float idle;
    42         float busy;
     46        uint64_t upper;
     47        uint64_t lower;
     48} ps_float;
     49
     50typedef struct {
     51        ps_float idle;
     52        ps_float busy;
    4353} cpu_perc_t;
    4454
    4555typedef struct {
    46         float ucycles;
    47         float kcycles;
    48         float mem;
     56        ps_float ucycles;
     57        ps_float kcycles;
     58        ps_float mem;
    4959} task_perc_t;
    5060
Note: See TracChangeset for help on using the changeset viewer.