Changeset ee35ba0b in mainline for uspace/app/top/screen.c


Ignore:
Timestamp:
2010-04-03T15:26:34Z (14 years ago)
Author:
Stanislav Kozina <stanislav.kozina@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
452268a
Parents:
8b2aba5
Message:

top echoes also percentage usage of cpu

File:
1 edited

Legend:

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

    r8b2aba5 ree35ba0b  
    5050#define WHITE 0xf0f0f0
    5151#define BLACK 0x000000
     52
     53static void print_float(float f, int precision)
     54{
     55        printf("%u.", (unsigned int) f);
     56        int i;
     57        float rest = (f - (int)f) * 10;
     58        for (i = 0; i < precision; ++i) {
     59                printf("%d", (unsigned int)rest);
     60                rest = (rest - (int)rest) * 10;
     61        }
     62}
    5263
    5364static void resume_normal(void)
     
    112123        uspace_cpu_info_t *cpus = data->cpus;
    113124        for (i = 0; i < data->cpu_count; ++i) {
    114                 printf("Cpu%u (%4u Mhz): Busy ticks: %6llu, Idle Ticks: %6llu\n",
     125                printf("Cpu%u (%4u Mhz): Busy ticks: %6llu, Idle Ticks: %6llu",
    115126                        i, (unsigned int)cpus[i].frequency_mhz, cpus[i].busy_ticks,
    116127                        cpus[i].idle_ticks);
     128                printf(", idle: ");
     129                print_float(data->cpu_perc[i].idle, 2);
     130                puts("%, busy: ");
     131                print_float(data->cpu_perc[i].busy, 2);
     132                puts("%\n");
    117133                ++up_rows;
    118134        }
     
    163179        print_head();
    164180        puts("\n");
    165         print_tasks(data, 4);
     181        print_tasks(data, up_rows);
    166182        fflush(stdout);
    167183}
Note: See TracChangeset for help on using the changeset viewer.