00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _XENO_NUCLEUS_STAT_H
00022 #define _XENO_NUCLEUS_STAT_H
00023
00024 #ifdef CONFIG_XENO_OPT_STATS
00025
00026 #include <nucleus/types.h>
00027
00028 typedef struct xnstat_runtime {
00029
00030 xnticks_t start;
00031
00032 xnticks_t total;
00033
00034 } xnstat_runtime_t;
00035
00036
00037
00038 #define xnstat_runtime_now() xnarch_get_cpu_tsc()
00039
00040
00041 #define xnstat_runtime_update(sched, start) \
00042 do { \
00043 (sched)->current_account->total += \
00044 start - (sched)->last_account_switch; \
00045 (sched)->last_account_switch = start; \
00046 } while (0)
00047
00048
00049 #define xnstat_runtime_set_current(sched, new_account) \
00050 ({ \
00051 xnstat_runtime_t *__prev; \
00052 __prev = xnarch_atomic_xchg(&(sched)->current_account, (new_account)); \
00053 __prev; \
00054 })
00055
00056
00057 #define xnstat_runtime_get_current(sched) ((sched)->current_account)
00058
00059
00060
00061 #define xnstat_runtime_finalize(sched, new_account) \
00062 do { \
00063 (sched)->last_account_switch = xnarch_get_cpu_tsc(); \
00064 (sched)->current_account = (new_account); \
00065 } while (0)
00066
00067
00068
00069 #define xnstat_runtime_reset_stats(stat) \
00070 do { \
00071 (stat)->total = 0; \
00072 (stat)->start = xnarch_get_cpu_tsc(); \
00073 } while (0)
00074
00075
00076 typedef struct xnstat_counter {
00077 int counter;
00078 } xnstat_counter_t;
00079
00080 static inline int xnstat_counter_inc(xnstat_counter_t *c) {
00081 return c->counter++;
00082 }
00083
00084 static inline int xnstat_counter_get(xnstat_counter_t *c) {
00085 return c->counter;
00086 }
00087
00088 #else
00089 typedef struct xnstat_runtime {
00090 } xnstat_runtime_t;
00091
00092 #define xnstat_runtime_now() 0
00093 #define xnstat_runtime_update(sched, start) do { } while (0)
00094 #define xnstat_runtime_set_current(sched, new_account) ({ NULL; })
00095 #define xnstat_runtime_get_current(sched) ({ NULL; })
00096 #define xnstat_runtime_finalize(sched, new_account) do { } while (0)
00097 #define xnstat_runtime_reset_stats(account) do { } while (0)
00098
00099 typedef struct xnstat_counter {
00100 } xnstat_counter_t;
00101
00102 static inline int xnstat_counter_inc(xnstat_counter_t *c) { return 0; }
00103 static inline int xnstat_counter_get(xnstat_counter_t *c) { return 0; }
00104 #endif
00105
00106
00107
00108 #define xnstat_runtime_switch(sched, new_account) \
00109 ({ \
00110 xnstat_runtime_update(sched, xnstat_runtime_now()); \
00111 xnstat_runtime_set_current(sched, new_account); \
00112 })
00113
00114
00115
00116 #define xnstat_runtime_lazy_switch(sched, new_account, start) \
00117 ({ \
00118 xnstat_runtime_update(sched, start); \
00119 xnstat_runtime_set_current(sched, new_account); \
00120 })
00121
00122 #endif