00001 /* 00002 * Copyright (c) 2010 Stanislav Kozina 00003 * Copyright (c) 2010 Martin Decky 00004 * All rights reserved. 00005 * 00006 * Redistribution and use in source and binary forms, with or without 00007 * modification, are permitted provided that the following conditions 00008 * are met: 00009 * 00010 * - Redistributions of source code must retain the above copyright 00011 * notice, this list of conditions and the following disclaimer. 00012 * - Redistributions in binary form must reproduce the above copyright 00013 * notice, this list of conditions and the following disclaimer in the 00014 * documentation and/or other materials provided with the distribution. 00015 * - The name of the author may not be used to endorse or promote products 00016 * derived from this software without specific prior written permission. 00017 * 00018 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 00019 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00020 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 00021 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 00022 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 00023 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00024 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00025 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00026 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 00027 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00028 */ 00029 00034 #ifndef TOP_TOP_H_ 00035 #define TOP_TOP_H_ 00036 00037 #include <task.h> 00038 #include <stats.h> 00039 #include <time.h> 00040 00041 #define FRACTION_TO_FLOAT(float, a, b) \ 00042 do { \ 00043 if ((b) != 0) { \ 00044 (float).upper = (a); \ 00045 (float).lower = (b); \ 00046 } else { \ 00047 (float).upper = 0; \ 00048 (float).lower = 1; \ 00049 } \ 00050 } while (0) 00051 00052 typedef enum { 00053 OP_TASKS, 00054 OP_IPC, 00055 OP_EXCS, 00056 OP_HELP 00057 } op_mode_t; 00058 00059 typedef enum { 00060 SORT_TASK_CYCLES 00061 } sort_mode_t; 00062 00063 extern op_mode_t op_mode; 00064 extern sort_mode_t sort_mode; 00065 extern bool excs_all; 00066 00067 typedef struct { 00068 uint64_t upper; 00069 uint64_t lower; 00070 } fixed_float; 00071 00072 typedef struct { 00073 fixed_float idle; 00074 fixed_float busy; 00075 } perc_cpu_t; 00076 00077 typedef struct { 00078 fixed_float virtmem; 00079 fixed_float resmem; 00080 fixed_float ucycles; 00081 fixed_float kcycles; 00082 } perc_task_t; 00083 00084 typedef struct { 00085 fixed_float cycles; 00086 fixed_float count; 00087 } perc_exc_t; 00088 00089 typedef struct { 00090 time_t hours; 00091 time_t minutes; 00092 time_t seconds; 00093 00094 sysarg_t udays; 00095 sysarg_t uhours; 00096 sysarg_t uminutes; 00097 sysarg_t useconds; 00098 00099 size_t load_count; 00100 load_t *load; 00101 00102 size_t cpus_count; 00103 stats_cpu_t *cpus; 00104 perc_cpu_t *cpus_perc; 00105 00106 size_t tasks_count; 00107 stats_task_t *tasks; 00108 perc_task_t *tasks_perc; 00109 size_t *tasks_map; 00110 00111 size_t threads_count; 00112 stats_thread_t *threads; 00113 00114 size_t exceptions_count; 00115 stats_exc_t *exceptions; 00116 perc_exc_t *exceptions_perc; 00117 00118 stats_physmem_t *physmem; 00119 00120 uint64_t *ucycles_diff; 00121 uint64_t *kcycles_diff; 00122 uint64_t *ecycles_diff; 00123 uint64_t *ecount_diff; 00124 } data_t; 00125 00126 #endif 00127