init
[protos/xbee-avr.git] / scheduler_stats.h
1 /*  
2  *  Copyright Droids Corporation (2009)
3  * 
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program; if not, write to the Free Software
16  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  *
18  *  Revision : $Id: scheduler_stats.h,v 1.1.2.1 2009-11-08 17:33:14 zer0 Exp $
19  *
20  * Olivier MATZ <zer0@droids-corp.org>
21  */
22
23 #ifndef _SCHEDULER_STATS_H_
24 #define _SCHEDULER_STATS_H_
25
26 #ifdef CONFIG_MODULE_SCHEDULER_STATS
27 struct scheduler_stats {
28         uint32_t alloc_fails;
29         uint32_t add_event;
30         uint32_t del_event;
31         uint32_t max_stacking;
32         uint32_t task_delayed[SCHEDULER_NB_MAX_EVENT];
33         uint32_t task_scheduled[SCHEDULER_NB_MAX_EVENT];
34 };
35
36 extern struct scheduler_stats sched_stats;
37
38 #define SCHED_INC_STAT(x) do {                  \
39                 uint8_t flags;                  \
40                 IRQ_LOCK(flags);                \
41                 sched_stats.x++;                \
42                 IRQ_UNLOCK(flags);              \
43         } while(0)
44
45 #define SCHED_INC_STAT2(x, i) do {              \
46                 uint8_t flags;                  \
47                 IRQ_LOCK(flags);                \
48                 sched_stats.x[i]++;             \
49                 IRQ_UNLOCK(flags);              \
50         } while(0)
51
52
53 #else /* CONFIG_MODULE_SCHEDULER_STATS */
54
55 #define SCHED_INC_STAT(x) do { } while(0)
56 #define SCHED_INC_STAT2(x, i) do { } while(0)
57
58 #endif /* CONFIG_MODULE_SCHEDULER_STATS */
59
60 void scheduler_stats_dump(void);
61
62 #endif /* _SCHEDULER_STATS_H_ */