Changeset 34bba0e in mainline


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

Files:
3 edited

Legend:

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

    rf773206d r34bba0e  
    7575        int priority;
    7676        uint64_t cycles;
     77        unsigned int cpu;
    7778} thread_info_t;
    7879
  • kernel/generic/src/ps/ps.c

    rf773206d r34bba0e  
    170170        result.cycles = t->cycles;
    171171
     172        if (t->cpu)
     173                result.cpu = t->cpu->id;
     174        else
     175                result.cpu = -1;
     176
    172177        WRITE_THREAD_INFO(infos, count - 1, &result);
    173178
     
    187192        spinlock_unlock(&tasks_lock);
    188193
     194        if (!selected_task) {
     195                return 0;
     196        }
     197
    189198        spinlock_lock(&threads_lock);
    190199
  • 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.