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

Changeset dd6c71c in mainline


Ignore:
Timestamp:
2010-04-02T08:27:13Z (12 years ago)
Author:
Stanislav Kozina <stanislav.kozina@…>
Branches:
lfn, master
Children:
175ad5c6
Parents:
62550dce
Message:

top echoes counts of tasks

Location:
uspace/app
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/top/Makefile

    r62550dce rdd6c71c  
    3434        top.c \
    3535        screen.c \
    36         input.c
     36        input.c \
     37        ps.c
    3738
    3839include $(USPACE_PREFIX)/Makefile.common
  • uspace/app/top/screen.c

    r62550dce rdd6c71c  
    3838#include <io/console.h>
    3939#include <vfs/vfs.h>
     40#include <load.h>
    4041#include "screen.h"
    4142#include "top.h"
     
    7374static inline void print_uptime(data_t *data)
    7475{
    75         printf("up %4d days, %02d:%02d:%02d ", data->uptime_d, data->uptime_h,
     76        printf("up %4d days, %02d:%02d:%02d, ", data->uptime_d, data->uptime_h,
    7677                data->uptime_m, data->uptime_s);
    7778}
    7879
    79 static int i = 0;
     80static inline void print_load(data_t *data)
     81{
     82        puts("load avarage: ");
     83        print_load_fragment(data->load[0], 2);
     84        puts(" ");
     85        print_load_fragment(data->load[1], 2);
     86        puts(" ");
     87        print_load_fragment(data->load[2], 2);
     88}
     89
     90static inline void print_taskstat(data_t *data)
     91{
     92        puts("Tasks: ");
     93        printf("%4u total", data->task_count);
     94}
     95
    8096void print_data(data_t *data)
    8197{
     
    85101        print_time(data);
    86102        print_uptime(data);
    87         puts(" ... \n");
    88         printf("A dalsi radek topu - jiz po %dte", ++i);
     103        print_load(data);
     104        puts("\n");
     105        print_taskstat(data);
     106        puts("\n");
    89107        fflush(stdout);
    90108}
  • uspace/app/top/top.c

    r62550dce rdd6c71c  
    4747#include "input.h"
    4848#include "top.h"
     49#include "ps.h"
    4950
    5051#define UPDATE_INTERVAL 1
     
    7677        /* Read load */
    7778        get_load(target->load);
     79
     80        /* Read task ids */
     81        target->task_count = get_tasks(&target->tasks);
    7882}
    7983
     
    111115        }
    112116
     117        free(new_data.tasks);
    113118        puts("\n\n");
    114119        fflush(stdout);
  • uspace/app/top/top.h

    r62550dce rdd6c71c  
    3434#define TOP_TOP_H_
    3535
     36#include <task.h>
     37
    3638typedef struct {
    3739        unsigned int hours;
     
    4547
    4648        unsigned long load[3];
     49
     50        task_id_t *tasks;
     51        unsigned int task_count;
    4752} data_t;
    4853
  • uspace/app/uptime/uptime.c

    r62550dce rdd6c71c  
    4444#define MINUTE 60
    4545
    46 #define ECHOLOAD1(x) ((x) >> 11)
    47 #define ECHOLOAD2(x) (((x) & 0x7ff) / 2)
    48 
    4946int main(int argc, char *argv[])
    5047{
Note: See TracChangeset for help on using the changeset viewer.