aboutsummaryrefslogtreecommitdiffstats
path: root/include/litmus/domain.h
blob: cc93fea8a99665a84172bb3ae0c4fe0e89d1c6bf (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
/**
 * --Todo--
 * Naming: this should become rt_domain while the old rt_domain should be
 * changed to sd_domain (sporadic) or pd_domain (periodic).
 * task_new: need to add and use this method
 */
#ifndef _LITMUS_DOMAIN_H_
#define _LITMUS_DOMAIN_H_

struct domain;

typedef void (*requeue_t)(struct domain*, struct task_struct*);
typedef void (*remove_t)(struct domain*, struct task_struct*);
typedef struct task_struct* (*peek_ready_t)(struct domain*);
typedef struct task_struct* (*take_ready_t)(struct domain*);
typedef int (*task_prio_t)(struct task_struct*, struct task_struct*);
typedef int (*acquire_resources_t)(struct task_struct *t);
typedef void (*release_resources_t)(struct task_struct *t);

typedef struct domain {
	raw_spinlock_t*		lock; /* for coarse serialization     	*/
	struct list_head	list; /* list membership              	*/
	void*			data; /* implementation-specific data	*/
	char*			name; /* for debugging 		      	*/

	/* add a task to the domain */
	requeue_t		requeue;
	/* prevent a task from being returned by the domain */
	remove_t		remove;
	/* return next ready task */
	peek_ready_t		peek_ready;
	/* remove and return next ready task */
	take_ready_t		take_ready;
	/* for tasks within this domain, returns true if the first has
	 * has a higher priority than the second
	 */
	task_prio_t		higher_prio;

	acquire_resources_t	acquire_resources;
	release_resources_t	release_resources;
} domain_t;

void domain_init(domain_t *dom,
		 raw_spinlock_t *lock,
		 requeue_t requeue,
		 peek_ready_t peek_ready,
		 take_ready_t take_ready,
		 task_prio_t priority);
#endif