aboutsummaryrefslogblamecommitdiffstats
path: root/include/litmus/event_group.h
blob: f17631e4e23084e01b6b335bbe336ba9102942aa (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14













                                                               

                                   












                                                            
                                                   




























                                                                 
#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