Changeset 34bba0e in mainline for uspace/app/ps/ps.c


Ignore:
Timestamp:
2010-03-25T15:15:09Z (14 years ago)
Author:
Stanislav Kozina <stanislav.kozina@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a2a00e8
Parents:
f773206d
Message:

Tweaking ps
ps -t echoes also current CPU

File:
1 edited

Legend:

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

    rf773206d r34bba0e  
    4747#define THREAD_COUNT 50
    4848
     49/** Thread states */
     50static const char *thread_states[] = {
     51        "Invalid",
     52        "Running",
     53        "Sleeping",
     54        "Ready",
     55        "Entering",
     56        "Exiting",
     57        "Lingering"
     58};
     59
    4960static void list_tasks(void)
    5061{
     
    8293        }
    8394
     95        if (result == 0) {
     96                printf("No task with given pid!\n");
     97                exit(1);
     98        }
     99
    84100        int i;
    85         printf("    ID    State  Prio    [k]Cycles\n");
     101        printf("    ID    State  CPU  Prio    [k]Cycles\n");
    86102        for (i = 0; i < result; ++i) {
    87                 printf("%6llu %8d %6d %12llu\n", threads[i].tid, threads[i].state,
    88                                 threads[i].priority, threads[i].cycles / 1000);
     103                printf("%6llu %-8s %4u %6d %12llu\n", threads[i].tid, thread_states[threads[i].state],
     104                                threads[i].cpu, threads[i].priority, threads[i].cycles / 1000);
    89105        }
     106}
     107
     108static void usage()
     109{
     110        printf("Usage: ps [-t pid]\n");
    90111}
    91112
     
    100121                        if (argc != 1) {
    101122                                printf("Bad argument count!\n");
     123                                usage();
    102124                                exit(1);
    103125                        }
     
    106128                } else {
    107129                        printf("Unknown argument %s!\n", *argv);
     130                        usage();
    108131                        exit(1);
    109132                }
Note: See TracChangeset for help on using the changeset viewer.