aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/litmus.h
blob: 73ea6435f6402ef8d2784775997913c07407e909 (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*
 * Constant definitions related to 
 * scheduling policy. 
 */

#ifndef _LINUX_LITMUS_H_
#define _LINUX_LITMUS_H_

#include <linux/jiffies.h>
#include <linux/sched_trace.h>

typedef enum {
	SCHED_BEG 		=  0,
	SCHED_LINUX 		=  0,
	SCHED_PFAIR 		=  1,
	SCHED_PFAIR_STAGGER 	=  2,
	SCHED_PART_EDF 		=  3,
	SCHED_PART_EEVDF 	=  4,
	SCHED_GLOBAL_EDF 	=  5,
	SCHED_PFAIR_DESYNC 	=  6,
	SCHED_GLOBAL_EDF_NP 	=  7,	
	SCHED_CUSTOM 		=  8,
	SCHED_EDF_HSB		=  9,
	SCHED_GSN_EDF		= 10,
	SCHED_PSN_EDF		= 11,

	/*      Add your scheduling policy here */

	SCHED_END 		= 11,
	SCHED_DEFAULT 		=  0,
	SCHED_INVALID 		= -1,
} spolicy;

/* no options */
#define SCHED_NONE		0
/* make scheduling decisions at quantum boundaries */
#define SCHED_QUANTUM		1	
/* only schedule RT tasks at slot boundaries */
#define SCHED_RT_AT_BOUND	2	
/* default slot size - number of 1ms jiffies in a scheduling quantum */
#define DEFAULT_SLOT_SIZE 	1	
/* stagger value for no staggering of slot boundaries */
#define DEFAULT_NO_STAGGER	0
/* default stagger - number of 1ms jiffies by which processors 
 * are staggered, modulo the slot size
 */
#define DEFAULT_STAGGER		2

/*	Runtime modes */
/* CLEANUP: Should maybe an enum? */
#define MAX_MODES	2
#define MODE_NON_RT	0
#define MODE_RT_RUN	1

/*	Plugin boot options, for convenience */
#define PLUGIN_LINUX  		"linux"
#define PLUGIN_PFAIR  		"pfair"
#define PLUGIN_PART_EDF 	"part_edf"
#define PLUGIN_GLOBAL_EDF 	"global_edf"
#define PLUGIN_PFAIR_STAGGER 	"stagger"
#define PLUGIN_PFAIR_DESYNC	"desync"
#define PLUGIN_GLOBAL_EDF_NP 	"global_edf_np"
#define PLUGIN_EDF_HSB 		"edf_hsb"
#define PLUGIN_GSN_EDF		"gsn_edf"
#define PLUGIN_PSN_EDF		"psn_edf"


/*	Additional clone flags  
	Indicates that the thread is to be used in 
	realtime mode, therefore it should not be 
	woken up in a linux manner,
	we just set its state to TASK_STOPPED
	It must be prepared and added to the ready queue explicitly
*/

/*	Type definition for our quantums */
typedef unsigned long long quantum_t;

extern spolicy sched_policy;
extern int sched_options;
/*	Make this function available to plugins */
void set_sched_options(int);

extern unsigned long slot_size;
extern unsigned long stagger_offset;

/*	RT mode start time	*/
extern volatile unsigned long rt_start_time;

/*	Here we store the current mode of the system */
extern atomic_t rt_mode;

#define get_rt_mode() (atomic_read(&rt_mode))
#define set_rt_mode(a) atomic_set(&rt_mode,(a))

/* CLEANUP: Should be queue_lock, does it really belong here? */
extern  spinlock_t litmus_task_set_lock;


#define TRACE(fmt, args...) \
	sched_trace_log_message("%d: " fmt, raw_smp_processor_id(), ## args)

#define TRACE_TASK(t, fmt, args...) \
	TRACE("(%s/%d) " fmt, (t)->comm, (t)->pid, ##args)

#define TRACE_CUR(fmt, args...) \
	TRACE_TASK(current, fmt, ## args)

/* in_list - is a given list_head queued on some list?
 */
static inline int in_list(struct list_head* list)
{
	return !(  /* case 1: deleted */ 
		   (list->next == LIST_POISON1 &&    
		    list->prev == LIST_POISON2) 
		 || 
		   /* case 2: initialized */
		   (list->next == list && 
		    list->prev == list)
		);
}


#endif