aboutsummaryrefslogtreecommitdiffstats
path: root/include/litmus/event_group.h
blob: f17631e4e23084e01b6b335bbe336ba9102942aa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef _LINUX_EVENT_QUEUE_H_
#define _LINUX_EVENT_QUEUE_H_

#define EVENT_QUEUE_SLOTS 127 /* prime */

typedef void (*fire_event_t)(void *data);

/**
 * event_group_t - 
 */
typedef struct event_group {
	lt_t 			res;
	int 			cpu;
	struct list_head 	event_queue[EVENT_QUEUE_SLOTS];
	raw_spinlock_t 	queue_lock;
} event_group_t;

/**
 * event_list_t - A group of actions to fire at a given time
 */
typedef struct event_list {
	struct list_head events;

	/* For timer firing */
	lt_t 				fire_time;
	struct hrtimer 			timer;
	struct hrtimer_start_on_info 	info;

	struct list_head list;  /* For event_queue */
	event_group_t *group; /* For callback    */
} event_list_t;

/**
 * rt_event_t - A single action to fire at a time
 */
typedef struct rt_event {
	/* Function to call on event expiration */
	fire_event_t 	 fire;
	/* To be passed into fire */
	void* 	 	 data;
	/* Priority of this event (lower is better */
	int 		 prio;

	/* For membership in the event_list */
	struct list_head list;
	/* To avoid runtime allocation. This is NOT necessarily
	 * the event_list containing this event. This is just a
	 * pre-allocated event list which can be used for merging
	 * events.
	 */
	event_list_t*	 event_list;
} rt_event_t;

void init_event_group(event_group_t *group, lt_t res, int cpu);
void add_event(event_group_t *group, rt_event_t *e);
void cancel_event(event_group_t *group, rt_event_t event);
event_list_t* event_list_alloc(int gfp_flags);

#endif