Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 638927a in mainline


Ignore:
Timestamp:
2010-04-09T11:18:08Z (12 years ago)
Author:
Stanislav Kozina <stanislav.kozina@…>
Branches:
lfn, master
Children:
e43cdac
Parents:
faf38b2
Message:

top echoes also thread state overview
write_barrier() after computing percentages

Files:
9 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/ps/ps.c

    rfaf38b2 r638927a  
    191191        ipl_t ipl;
    192192        ipl = interrupts_disable();
    193 
    194         printf("LIst threads, size: %llu\n", size);
    195193        spinlock_lock(&threads_lock);
    196194
  • uspace/app/ps/ps.c

    rfaf38b2 r638927a  
    9797static void list_threads(task_id_t taskid)
    9898{
    99         int thread_count = THREAD_COUNT;
     99        size_t thread_count = THREAD_COUNT;
    100100        thread_info_t *threads = malloc(thread_count * sizeof(thread_info_t));
    101         int result = get_task_threads(threads, sizeof(thread_info_t) * thread_count);
     101        size_t result = get_task_threads(threads, sizeof(thread_info_t) * thread_count);
    102102
    103103        while (result > thread_count) {
     
    112112        }
    113113
    114         int i;
     114        size_t i;
    115115        printf("    ID    State  CPU   Prio    [k]uCycles    [k]kcycles   Cycle fault\n");
    116116        for (i = 0; i < result; ++i) {
  • uspace/app/top/ps.c

    rfaf38b2 r638927a  
    5858};
    5959
    60 unsigned int get_tasks(task_info_t **out_infos)
     60size_t get_tasks(task_info_t **out_infos)
    6161{
    62         int task_count = TASK_COUNT;
     62        size_t task_count = TASK_COUNT;
    6363        task_id_t *tasks = malloc(task_count * sizeof(task_id_t));
    64         int result = get_task_ids(tasks, sizeof(task_id_t) * task_count);
     64        size_t result = get_task_ids(tasks, sizeof(task_id_t) * task_count);
    6565
    6666        while (result > task_count) {
     
    7070        }
    7171
    72         int i;
     72        size_t i;
    7373        task_info_t *taskinfos = malloc(result * sizeof(task_info_t));
    7474        for (i = 0; i < result; ++i) {
     
    8282}
    8383
    84 thread_info_t *get_threads(task_id_t taskid)
     84size_t get_threads(thread_info_t **thread_infos)
    8585{
    86         int thread_count = THREAD_COUNT;
     86        size_t thread_count = THREAD_COUNT;
    8787        thread_info_t *threads = malloc(thread_count * sizeof(thread_info_t));
    88         int result = get_task_threads(threads, sizeof(thread_info_t) * thread_count);
     88        size_t result = get_task_threads(threads, sizeof(thread_info_t) * thread_count);
    8989
    9090        while (result > thread_count) {
     
    9494        }
    9595       
    96         return threads;
     96        *thread_infos = threads;
     97        return result;
    9798}
    9899
  • uspace/app/top/ps.h

    rfaf38b2 r638927a  
    3939
    4040extern const char *thread_states[];
    41 extern unsigned int get_tasks(task_info_t **out_infos);
    42 extern thread_info_t *get_threads(task_id_t taskid);
     41extern size_t get_tasks(task_info_t **out_infos);
     42extern size_t get_threads(thread_info_t **thread_infos);
    4343extern unsigned int get_cpu_infos(uspace_cpu_info_t **out_infos);
    4444
  • uspace/app/top/screen.c

    rfaf38b2 r638927a  
    119119}
    120120
     121static inline void print_threadstat(data_t *data)
     122{
     123        size_t sleeping = 0;
     124        size_t running = 0;
     125        size_t invalid = 0;
     126        size_t other = 0;
     127        size_t total = 0;
     128        size_t i;
     129        for (i = 0; i < data->thread_count; ++i) {
     130                ++total;
     131                switch (data->thread_infos[i].state) {
     132                        case Invalid:
     133                        case Lingering:
     134                                ++invalid;
     135                                break;
     136                        case Running:
     137                        case Ready:
     138                                ++running;
     139                                break;
     140                        case Sleeping:
     141                                ++sleeping;
     142                                break;
     143                        case Entering:
     144                        case Exiting:
     145                                ++other;
     146                                break;
     147                }
     148        }
     149        printf("Threads: %5u total, %5u running, %5u sleeping, %5u invalid, %5u other",
     150                total, running, sleeping, invalid, other);
     151}
     152
    121153static inline void print_cpuinfo(data_t *data)
    122154{
     
    197229        puts("\n");
    198230        ++up_rows;
     231        print_threadstat(data);
     232        puts("\n");
     233        ++up_rows;
    199234        print_cpuinfo(data);
    200235        print_meminfo(data);
  • uspace/app/top/top.c

    rfaf38b2 r638927a  
    4444#include <load.h>
    4545#include <ps.h>
     46#include <arch/barrier.h>
    4647#include "screen.h"
    4748#include "input.h"
     
    8283        /* Read task ids */
    8384        target->task_count = get_tasks(&target->taskinfos);
     85
     86        /* Read all threads */
     87        target->thread_count = get_threads(&target->thread_infos);
    8488
    8589        /* Read cpu infos */
     
    144148        }
    145149
     150        /* Wait until coprocessor finishes its work */
     151        write_barrier();
     152
    146153        /* And free temporary structures */
    147154        free(ucycles_diff);
     
    152159{
    153160        free(target->taskinfos);
     161        free(target->thread_infos);
    154162        free(target->cpus);
    155163        free(target->cpu_perc);
  • uspace/app/top/top.h

    rfaf38b2 r638927a  
    6161        unsigned long load[3];
    6262
    63         unsigned int task_count;
     63        size_t task_count;
    6464        task_info_t *taskinfos;
    6565        task_perc_t *task_perc;
     66
     67        size_t thread_count;
     68        thread_info_t *thread_infos;
    6669
    6770        unsigned int cpu_count;
  • uspace/lib/c/generic/ps.c

    rfaf38b2 r638927a  
    7171 * @param size          Size of the infos array.
    7272 *
    73  * @return              0 on success.
     73 * @return              Count of written thread_infos. If higher than size, there
     74 *                      was not enough space.
    7475 *
    7576 */
    76 int get_task_threads(thread_info_t *infos, size_t size)
     77size_t get_task_threads(thread_info_t *infos, size_t size)
    7778{
    7879        return __SYSCALL2(SYS_PS_GET_THREADS, (sysarg_t) infos, (sysarg_t) size);
  • uspace/lib/c/include/ps.h

    rfaf38b2 r638927a  
    4545extern size_t get_task_ids(task_id_t *ids, size_t size);
    4646extern int get_task_info(task_id_t id, task_info_t *info);
    47 extern int get_task_threads(thread_info_t *infos, size_t size);
     47extern size_t get_task_threads(thread_info_t *infos, size_t size);
    4848
    4949#endif
Note: See TracChangeset for help on using the changeset viewer.