Changeset 62550dce in mainline for uspace/app/ps/ps.c


Ignore:
Timestamp:
2010-04-01T21:31:25Z (14 years ago)
Author:
Stanislav Kozina <stanislav.kozina@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
dd6c71c
Parents:
79edc36
Message:

ps -c echoes info about CPU's
cpu count is accessible through sysinfo("cpu.count")

File:
1 edited

Legend:

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

    r79edc36 r62550dce  
    4343#include <malloc.h>
    4444#include <load.h>
     45#include <sysinfo.h>
    4546
    4647#include "func.h"
     
    141142}
    142143
     144static void echo_cpus(void)
     145{
     146        size_t cpu_count = sysinfo_value("cpu.count");
     147        printf("Found %u cpu's:\n", cpu_count);
     148        uspace_cpu_info_t *cpus = malloc(cpu_count * sizeof(uspace_cpu_info_t));
     149        get_cpu_info(cpus);
     150        size_t i;
     151        for (i = 0; i < cpu_count; ++i) {
     152                printf("%2u (%4u Mhz): Busy ticks: %8llu, Idle ticks: %8llu\n", cpus[i].id,
     153                                (size_t)cpus[i].frequency_mhz, cpus[i].busy_ticks, cpus[i].idle_ticks);
     154        }
     155}
     156
    143157static void usage()
    144158{
    145         printf("Usage: ps [-t pid -l]\n");
     159        printf("Usage: ps [-t pid|-l|-c]\n");
    146160}
    147161
     
    169183                        }
    170184                        echo_load();
     185                } else if (str_cmp(*argv, "-c") == 0) {
     186                        --argc; ++argv;
     187                        if (argc != 0) {
     188                                printf("Bad argument count!\n");
     189                                usage();
     190                                exit(1);
     191                        }
     192                        echo_cpus();
    171193                } else {
    172194                        printf("Unknown argument %s!\n", *argv);
Note: See TracChangeset for help on using the changeset viewer.