Changeset 8565a42 in mainline for uspace/app/top


Ignore:
Timestamp:
2018-03-02T20:34:50Z (8 years ago)
Author:
GitHub <noreply@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a1a81f69, d5e5fd1
Parents:
3061bc1 (diff), 34e1206 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:34:50)
git-committer:
GitHub <noreply@…> (2018-03-02 20:34:50)
Message:

Remove all trailing whitespace, everywhere.

See individual commit messages for details.

Location:
uspace/app/top
Files:
3 edited

Legend:

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

    r3061bc1 r8565a42  
    9999{
    100100        screen_style_normal();
    101        
     101
    102102        if (clear) {
    103103                console_flush(console);
    104104                console_clear(console);
    105105        }
    106        
     106
    107107        screen_moveto(0, 0);
    108108}
     
    113113        sysarg_t rows;
    114114        screen_get_size(&cols, &rows);
    115        
     115
    116116        sysarg_t c;
    117117        sysarg_t r;
    118118        screen_get_pos(&c, &r);
    119        
     119
    120120        sysarg_t i;
    121121        for (i = c + 1; i < cols; i++)
    122122                puts(" ");
    123        
     123
    124124        if (r + 1 < rows)
    125125                puts("\n");
     
    129129{
    130130        console = console_init(stdin, stdout);
    131        
     131
    132132        console_flush(console);
    133133        console_cursor_visibility(console, false);
    134        
     134
    135135        screen_restart(true);
    136136}
     
    142142
    143143        screen_restart(true);
    144        
     144
    145145        console_flush(console);
    146146        console_cursor_visibility(console, true);
     
    150150{
    151151        printf("%3" PRIu64 ".", ffloat.upper / ffloat.lower);
    152        
     152
    153153        unsigned int i;
    154154        uint64_t rest = (ffloat.upper % ffloat.lower) * 10;
     
    157157                rest = (rest % ffloat.lower) * 10;
    158158        }
    159        
     159
    160160        printf("%%");
    161161}
     
    166166        sysarg_t rows;
    167167        screen_get_size(&cols, &rows);
    168        
     168
    169169        sysarg_t c;
    170170        sysarg_t r;
    171171        screen_get_pos(&c, &r);
    172        
     172
    173173        if (c < cols) {
    174174                int pos = cols - c - 1;
     
    184184            data->hours, data->minutes, data->seconds,
    185185            data->udays, data->uhours, data->uminutes, data->useconds);
    186        
     186
    187187        size_t i;
    188188        for (i = 0; i < data->load_count; i++) {
     
    190190                stats_print_load_fragment(data->load[i], 2);
    191191        }
    192        
     192
    193193        screen_newline();
    194194}
     
    209209        size_t other = 0;
    210210        size_t invalid = 0;
    211        
     211
    212212        size_t i;
    213213        for (i = 0; i < data->threads_count; i++) {
    214214                total++;
    215                
     215
    216216                switch (data->threads[i].state) {
    217217                case Running:
     
    235235                }
    236236        }
    237        
     237
    238238        printf("threads: %zu total, %zu running, %zu ready, "
    239239            "%zu sleeping, %zu lingering, %zu other, %zu invalid",
     
    251251                        char busy_suffix;
    252252                        char idle_suffix;
    253                        
     253
    254254                        order_suffix(data->cpus[i].busy_cycles, &busy, &busy_suffix);
    255255                        order_suffix(data->cpus[i].idle_cycles, &idle, &idle_suffix);
    256                        
     256
    257257                        printf("cpu%u (%4" PRIu16 " MHz): busy cycles: "
    258258                            "%" PRIu64 "%c, idle cycles: %" PRIu64 "%c",
     
    265265                } else
    266266                        printf("cpu%u inactive", data->cpus[i].id);
    267                
     267
    268268                screen_newline();
    269269        }
     
    280280        const char *used_suffix;
    281281        const char *free_suffix;
    282        
     282
    283283        bin_order_suffix(data->physmem->total, &total, &total_suffix, false);
    284284        bin_order_suffix(data->physmem->unavail, &unavail, &unavail_suffix, false);
    285285        bin_order_suffix(data->physmem->used, &used, &used_suffix, false);
    286286        bin_order_suffix(data->physmem->free, &free, &free_suffix, false);
    287        
     287
    288288        printf("memory: %" PRIu64 "%s total, %" PRIu64 "%s unavail, %"
    289289            PRIu64 "%s used, %" PRIu64 "%s free", total, total_suffix,
     
    305305        sysarg_t rows;
    306306        screen_get_size(&cols, &rows);
    307        
    308         screen_newline();
    309        
     307
     308        screen_newline();
     309
    310310        printf("Operation modes:");
    311311        screen_newline();
    312        
     312
    313313        printf(" t .. tasks statistics");
    314314        screen_newline();
    315        
     315
    316316        printf(" i .. IPC statistics");
    317317        screen_newline();
    318        
     318
    319319        printf(" e .. exceptions statistics");
    320320        screen_newline();
    321        
     321
    322322        printf("      a .. toggle display of all/hot exceptions");
    323323        screen_newline();
     
    330330        printf("Other keys:");
    331331        screen_newline();
    332        
     332
    333333        printf(" s .. choose column to sort by");
    334334        screen_newline();
    335        
     335
    336336        printf(" r .. toggle reversed sorting");
    337337        screen_newline();
    338        
     338
    339339        printf(" q .. quit");
    340340        screen_newline();
    341        
     341
    342342        sysarg_t col;
    343343        sysarg_t row;
    344344        screen_get_pos(&col, &row);
    345        
     345
    346346        while (row < rows) {
    347347                screen_newline();
     
    380380        sysarg_t rows;
    381381        screen_get_size(&cols, &rows);
    382        
     382
    383383        sysarg_t col;
    384384        sysarg_t row;
    385385        screen_get_pos(&col, &row);
    386        
     386
    387387        size_t i;
    388388        for (i = 0; (i < table->num_fields) && (row < rows); i++) {
     
    441441                }
    442442        }
    443        
     443
    444444        while (row < rows) {
    445445                screen_newline();
     
    453453        sysarg_t rows;
    454454        screen_get_size(&cols, &rows);
    455        
     455
    456456        sysarg_t col;
    457457        sysarg_t row;
     
    464464                row++;
    465465        }
    466        
     466
    467467        while (row < rows) {
    468468                screen_newline();
     
    494494        print_physmem_info(data);
    495495        print_warning();
    496        
     496
    497497        switch (screen_mode) {
    498498        case SCREEN_TABLE:
     
    507507                print_help();
    508508        }
    509        
     509
    510510        console_flush(console);
    511511}
     
    527527        vsnprintf(warning_text, warning_text_size, fmt, args);
    528528        va_end(args);
    529        
     529
    530530        warning_timeleft = 2 * USEC_COUNT;
    531531
     
    543543         * Reset timeleft whenever it is not positive.
    544544         */
    545        
     545
    546546        if (timeleft <= 0)
    547547                timeleft = sec * USEC_COUNT;
    548        
     548
    549549        /*
    550550         * Wait to see if there is any input. If so, take it and
     
    553553         * make timeleft zero and return -1.
    554554         */
    555        
     555
    556556        wchar_t c = 0;
    557        
     557
    558558        while (c == 0) {
    559559                cons_event_t event;
    560                
     560
    561561                warning_timeleft -= timeleft;
    562562                if (!console_get_event_timeout(console, &event, &timeleft)) {
     
    565565                }
    566566                warning_timeleft += timeleft;
    567                
     567
    568568                if (event.type == CEV_KEY && event.ev.key.type == KEY_PRESS)
    569569                        c = event.ev.key.c;
    570570        }
    571        
     571
    572572        return (int) c;
    573573}
  • uspace/app/top/top.c

    r3061bc1 r8565a42  
    153153        target->table.num_fields = 0;
    154154        target->table.fields = NULL;
    155        
     155
    156156        /* Get current time */
    157157        struct timeval time;
    158158        gettimeofday(&time, NULL);
    159        
     159
    160160        target->hours = (time.tv_sec % DAY) / HOUR;
    161161        target->minutes = (time.tv_sec % HOUR) / MINUTE;
    162162        target->seconds = time.tv_sec % MINUTE;
    163        
     163
    164164        /* Get uptime */
    165165        struct timeval uptime;
    166166        getuptime(&uptime);
    167        
     167
    168168        target->udays = uptime.tv_sec / DAY;
    169169        target->uhours = (uptime.tv_sec % DAY) / HOUR;
    170170        target->uminutes = (uptime.tv_sec % HOUR) / MINUTE;
    171171        target->useconds = uptime.tv_sec % MINUTE;
    172        
     172
    173173        /* Get load */
    174174        target->load = stats_get_load(&(target->load_count));
    175175        if (target->load == NULL)
    176176                return "Cannot get system load";
    177        
     177
    178178        /* Get CPUs */
    179179        target->cpus = stats_get_cpus(&(target->cpus_count));
    180180        if (target->cpus == NULL)
    181181                return "Cannot get CPUs";
    182        
     182
    183183        target->cpus_perc =
    184184            (perc_cpu_t *) calloc(target->cpus_count, sizeof(perc_cpu_t));
    185185        if (target->cpus_perc == NULL)
    186186                return "Not enough memory for CPU utilization";
    187        
     187
    188188        /* Get tasks */
    189189        target->tasks = stats_get_tasks(&(target->tasks_count));
    190190        if (target->tasks == NULL)
    191191                return "Cannot get tasks";
    192        
     192
    193193        target->tasks_perc =
    194194            (perc_task_t *) calloc(target->tasks_count, sizeof(perc_task_t));
    195195        if (target->tasks_perc == NULL)
    196196                return "Not enough memory for task utilization";
    197        
     197
    198198        /* Get threads */
    199199        target->threads = stats_get_threads(&(target->threads_count));
    200200        if (target->threads == NULL)
    201201                return "Cannot get threads";
    202        
     202
    203203        /* Get Exceptions */
    204204        target->exceptions = stats_get_exceptions(&(target->exceptions_count));
    205205        if (target->exceptions == NULL)
    206206                return "Cannot get exceptions";
    207        
     207
    208208        target->exceptions_perc =
    209209            (perc_exc_t *) calloc(target->exceptions_count, sizeof(perc_exc_t));
    210210        if (target->exceptions_perc == NULL)
    211211                return "Not enough memory for exception utilization";
    212        
     212
    213213        /* Get physical memory */
    214214        target->physmem = stats_get_physmem();
    215215        if (target->physmem == NULL)
    216216                return "Cannot get physical memory";
    217        
     217
    218218        target->ucycles_diff = calloc(target->tasks_count,
    219219            sizeof(uint64_t));
    220220        if (target->ucycles_diff == NULL)
    221221                return "Not enough memory for user utilization";
    222        
     222
    223223        /* Allocate memory for computed values */
    224224        target->kcycles_diff = calloc(target->tasks_count,
     
    226226        if (target->kcycles_diff == NULL)
    227227                return "Not enough memory for kernel utilization";
    228        
     228
    229229        target->ecycles_diff = calloc(target->exceptions_count,
    230230            sizeof(uint64_t));
    231231        if (target->ecycles_diff == NULL)
    232232                return "Not enough memory for exception cycles utilization";
    233        
     233
    234234        target->ecount_diff = calloc(target->exceptions_count,
    235235            sizeof(uint64_t));
    236236        if (target->ecount_diff == NULL)
    237237                return "Not enough memory for exception count utilization";
    238        
     238
    239239        return NULL;
    240240}
     
    250250        /* For each CPU: Compute total cycles and divide it between
    251251           user and kernel */
    252        
     252
    253253        size_t i;
    254254        for (i = 0; i < new_data->cpus_count; i++) {
     
    258258                    new_data->cpus[i].busy_cycles - old_data->cpus[i].busy_cycles;
    259259                uint64_t sum = idle + busy;
    260                
     260
    261261                FRACTION_TO_FLOAT(new_data->cpus_perc[i].idle, idle * 100, sum);
    262262                FRACTION_TO_FLOAT(new_data->cpus_perc[i].busy, busy * 100, sum);
    263263        }
    264        
     264
    265265        /* For all tasks compute sum and differencies of all cycles */
    266        
     266
    267267        uint64_t virtmem_total = 0;
    268268        uint64_t resmem_total = 0;
    269269        uint64_t ucycles_total = 0;
    270270        uint64_t kcycles_total = 0;
    271        
     271
    272272        for (i = 0; i < new_data->tasks_count; i++) {
    273273                /* Match task with the previous instance */
    274                
     274
    275275                bool found = false;
    276276                size_t j;
     
    281281                        }
    282282                }
    283                
     283
    284284                if (!found) {
    285285                        /* This is newly borned task, ignore it */
     
    288288                        continue;
    289289                }
    290                
     290
    291291                new_data->ucycles_diff[i] =
    292292                    new_data->tasks[i].ucycles - old_data->tasks[j].ucycles;
    293293                new_data->kcycles_diff[i] =
    294294                    new_data->tasks[i].kcycles - old_data->tasks[j].kcycles;
    295                
     295
    296296                virtmem_total += new_data->tasks[i].virtmem;
    297297                resmem_total += new_data->tasks[i].resmem;
     
    299299                kcycles_total += new_data->kcycles_diff[i];
    300300        }
    301        
     301
    302302        /* For each task compute percential change */
    303        
     303
    304304        for (i = 0; i < new_data->tasks_count; i++) {
    305305                FRACTION_TO_FLOAT(new_data->tasks_perc[i].virtmem,
     
    312312                    new_data->kcycles_diff[i] * 100, kcycles_total);
    313313        }
    314        
     314
    315315        /* For all exceptions compute sum and differencies of cycles */
    316        
     316
    317317        uint64_t ecycles_total = 0;
    318318        uint64_t ecount_total = 0;
    319        
     319
    320320        for (i = 0; i < new_data->exceptions_count; i++) {
    321321                /*
     
    324324                 * usually disappear, but it does not hurt.
    325325                 */
    326                
     326
    327327                bool found = false;
    328328                size_t j;
     
    333333                        }
    334334                }
    335                
     335
    336336                if (!found) {
    337337                        /* This is a new exception, ignore it */
     
    340340                        continue;
    341341                }
    342                
     342
    343343                new_data->ecycles_diff[i] =
    344344                    new_data->exceptions[i].cycles - old_data->exceptions[j].cycles;
    345345                new_data->ecount_diff[i] =
    346346                    new_data->exceptions[i].count - old_data->exceptions[i].count;
    347                
     347
    348348                ecycles_total += new_data->ecycles_diff[i];
    349349                ecount_total += new_data->ecount_diff[i];
    350350        }
    351        
     351
    352352        /* For each exception compute percential change */
    353        
     353
    354354        for (i = 0; i < new_data->exceptions_count; i++) {
    355355                FRACTION_TO_FLOAT(new_data->exceptions_perc[i].cycles,
     
    364364        field_t *fa = (field_t *)a + sort_column;
    365365        field_t *fb = (field_t *)b + sort_column;
    366        
     366
    367367        if (fa->type > fb->type)
    368368                return 1 * sort_reverse;
     
    536536        if (target->load != NULL)
    537537                free(target->load);
    538        
     538
    539539        if (target->cpus != NULL)
    540540                free(target->cpus);
    541        
     541
    542542        if (target->cpus_perc != NULL)
    543543                free(target->cpus_perc);
    544        
     544
    545545        if (target->tasks != NULL)
    546546                free(target->tasks);
    547        
     547
    548548        if (target->tasks_perc != NULL)
    549549                free(target->tasks_perc);
    550        
     550
    551551        if (target->threads != NULL)
    552552                free(target->threads);
    553        
     553
    554554        if (target->exceptions != NULL)
    555555                free(target->exceptions);
    556        
     556
    557557        if (target->exceptions_perc != NULL)
    558558                free(target->exceptions_perc);
    559        
     559
    560560        if (target->physmem != NULL)
    561561                free(target->physmem);
    562        
     562
    563563        if (target->ucycles_diff != NULL)
    564564                free(target->ucycles_diff);
    565        
     565
    566566        if (target->kcycles_diff != NULL)
    567567                free(target->kcycles_diff);
    568        
     568
    569569        if (target->ecycles_diff != NULL)
    570570                free(target->ecycles_diff);
    571        
     571
    572572        if (target->ecount_diff != NULL)
    573573                free(target->ecount_diff);
     
    582582        data_t data_prev;
    583583        const char *ret = NULL;
    584        
     584
    585585        screen_init();
    586586        printf("Reading initial data...\n");
    587        
     587
    588588        if ((ret = read_data(&data)) != NULL)
    589589                goto out;
    590        
     590
    591591        /* Compute some rubbish to have initialised values */
    592592        compute_percentages(&data, &data);
    593        
     593
    594594        /* And paint screen until death */
    595595        while (true) {
     
    602602                                goto out;
    603603                        }
    604                        
     604
    605605                        compute_percentages(&data_prev, &data);
    606606                        free_data(&data_prev);
     
    672672                print_data(&data);
    673673        }
    674        
     674
    675675out:
    676676        screen_done();
    677677        free_data(&data);
    678        
     678
    679679        if (ret != NULL) {
    680680                fprintf(stderr, "%s: %s\n", NAME, ret);
    681681                return 1;
    682682        }
    683        
     683
    684684        return 0;
    685685}
  • uspace/app/top/top.h

    r3061bc1 r8565a42  
    112112        time_t minutes;
    113113        time_t seconds;
    114        
     114
    115115        sysarg_t udays;
    116116        sysarg_t uhours;
    117117        sysarg_t uminutes;
    118118        sysarg_t useconds;
    119        
     119
    120120        size_t load_count;
    121121        load_t *load;
    122        
     122
    123123        size_t cpus_count;
    124124        stats_cpu_t *cpus;
    125125        perc_cpu_t *cpus_perc;
    126        
     126
    127127        size_t tasks_count;
    128128        stats_task_t *tasks;
    129129        perc_task_t *tasks_perc;
    130        
     130
    131131        size_t threads_count;
    132132        stats_thread_t *threads;
    133        
     133
    134134        size_t exceptions_count;
    135135        stats_exc_t *exceptions;
    136136        perc_exc_t *exceptions_perc;
    137        
     137
    138138        stats_physmem_t *physmem;
    139        
     139
    140140        uint64_t *ucycles_diff;
    141141        uint64_t *kcycles_diff;
Note: See TracChangeset for help on using the changeset viewer.