1 | /*
|
---|
2 | * Copyright (c) 2010 Stanislav Kozina
|
---|
3 | * Copyright (c) 2010 Martin Decky
|
---|
4 | * All rights reserved.
|
---|
5 | *
|
---|
6 | * Redistribution and use in source and binary forms, with or without
|
---|
7 | * modification, are permitted provided that the following conditions
|
---|
8 | * are met:
|
---|
9 | *
|
---|
10 | * - Redistributions of source code must retain the above copyright
|
---|
11 | * notice, this list of conditions and the following disclaimer.
|
---|
12 | * - Redistributions in binary form must reproduce the above copyright
|
---|
13 | * notice, this list of conditions and the following disclaimer in the
|
---|
14 | * documentation and/or other materials provided with the distribution.
|
---|
15 | * - The name of the author may not be used to endorse or promote products
|
---|
16 | * derived from this software without specific prior written permission.
|
---|
17 | *
|
---|
18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
28 | */
|
---|
29 |
|
---|
30 | /** @addtogroup top
|
---|
31 | * @{
|
---|
32 | */
|
---|
33 |
|
---|
34 | #ifndef TOP_TOP_H_
|
---|
35 | #define TOP_TOP_H_
|
---|
36 |
|
---|
37 | #include <task.h>
|
---|
38 | #include <stats.h>
|
---|
39 | #include <time.h>
|
---|
40 |
|
---|
41 | #define FRACTION_TO_FLOAT(float, a, b) \
|
---|
42 | do { \
|
---|
43 | if ((b) != 0) { \
|
---|
44 | (float).upper = (a); \
|
---|
45 | (float).lower = (b); \
|
---|
46 | } else { \
|
---|
47 | (float).upper = 0; \
|
---|
48 | (float).lower = 1; \
|
---|
49 | } \
|
---|
50 | } while (0)
|
---|
51 |
|
---|
52 | typedef enum {
|
---|
53 | OP_TASKS,
|
---|
54 | OP_IPC,
|
---|
55 | OP_EXCS,
|
---|
56 | OP_HELP
|
---|
57 | } op_mode_t;
|
---|
58 |
|
---|
59 | typedef enum {
|
---|
60 | SORT_TASK_CYCLES
|
---|
61 | } sort_mode_t;
|
---|
62 |
|
---|
63 | extern op_mode_t op_mode;
|
---|
64 | extern sort_mode_t sort_mode;
|
---|
65 | extern bool excs_all;
|
---|
66 |
|
---|
67 | typedef struct {
|
---|
68 | uint64_t upper;
|
---|
69 | uint64_t lower;
|
---|
70 | } fixed_float;
|
---|
71 |
|
---|
72 | typedef struct {
|
---|
73 | fixed_float idle;
|
---|
74 | fixed_float busy;
|
---|
75 | } perc_cpu_t;
|
---|
76 |
|
---|
77 | typedef struct {
|
---|
78 | fixed_float virtmem;
|
---|
79 | fixed_float resmem;
|
---|
80 | fixed_float ucycles;
|
---|
81 | fixed_float kcycles;
|
---|
82 | } perc_task_t;
|
---|
83 |
|
---|
84 | typedef struct {
|
---|
85 | fixed_float cycles;
|
---|
86 | fixed_float count;
|
---|
87 | } perc_exc_t;
|
---|
88 |
|
---|
89 | typedef struct {
|
---|
90 | time_t hours;
|
---|
91 | time_t minutes;
|
---|
92 | time_t seconds;
|
---|
93 |
|
---|
94 | sysarg_t udays;
|
---|
95 | sysarg_t uhours;
|
---|
96 | sysarg_t uminutes;
|
---|
97 | sysarg_t useconds;
|
---|
98 |
|
---|
99 | size_t load_count;
|
---|
100 | load_t *load;
|
---|
101 |
|
---|
102 | size_t cpus_count;
|
---|
103 | stats_cpu_t *cpus;
|
---|
104 | perc_cpu_t *cpus_perc;
|
---|
105 |
|
---|
106 | size_t tasks_count;
|
---|
107 | stats_task_t *tasks;
|
---|
108 | perc_task_t *tasks_perc;
|
---|
109 | size_t *tasks_map;
|
---|
110 |
|
---|
111 | size_t threads_count;
|
---|
112 | stats_thread_t *threads;
|
---|
113 |
|
---|
114 | size_t exceptions_count;
|
---|
115 | stats_exc_t *exceptions;
|
---|
116 | perc_exc_t *exceptions_perc;
|
---|
117 |
|
---|
118 | stats_physmem_t *physmem;
|
---|
119 |
|
---|
120 | uint64_t *ucycles_diff;
|
---|
121 | uint64_t *kcycles_diff;
|
---|
122 | uint64_t *ecycles_diff;
|
---|
123 | uint64_t *ecount_diff;
|
---|
124 | } data_t;
|
---|
125 |
|
---|
126 | #endif
|
---|
127 |
|
---|
128 | /**
|
---|
129 | * @}
|
---|
130 | */
|
---|