aboutsummaryrefslogtreecommitdiffstats
path: root/include/litmus.h
blob: 669921391edfd16baec1dbf53659fef0e9b2a57e (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
#ifndef LITMUS_H
#define LITMUS_H

#include <litmus/rt_param.h>
#include <sys/types.h>

typedef int pid_t;	 /* PID of a task */

/* obtain the PID of a thread */
pid_t gettid(void);

int set_rt_task_param(pid_t pid, struct rt_task* param);
int get_rt_task_param(pid_t pid, struct rt_task* param);

/* setup helper */
/* times are givin in ms */
int sporadic_task(unsigned long exec_cost, unsigned long period,
		  int partition, task_class_t cls);

#define sporadic_global(e, p) \
	sporadic_task(e, p, 0, RT_CLASS_SOFT)
#define sporadic_partitioned(e, p, cpu) \
	sporadic_task(e, p, cpu, RT_CLASS_SOFT)

/* file descriptor attached shared objects support */
typedef enum  {
	PI_SEM 		= 0,
	SRP_SEM		= 1,
} obj_type_t;

int od_openx(int fd, obj_type_t type, int obj_id, void* config);
int od_close(int od);

static inline int od_open(int fd, obj_type_t type, int obj_id)
{
	return od_openx(fd, type, obj_id, 0);
}

/* FMLP support */
int pi_down(int od);
int pi_up(int od);
int srp_down(int od);
int srp_up(int od);
int reg_task_srp_sem(int od);

/* job control*/
int get_job_no(unsigned int* job_no);
int wait_for_job_release(unsigned int job_no);
int sleep_next_period(void);

/*  library functions */
int  init_litmus(void);
int  init_rt_thread(void);
void exit_litmus(void);

/* A real-time program. */
typedef int (*rt_fn_t)(void*);

int create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, int wcet, int period);
int __create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, int wcet,
		     int period, task_class_t cls);

/*	per-task modes */
enum rt_task_mode_t {
	BACKGROUND_TASK = 0,
	LITMUS_RT_TASK  = 1
};
int task_mode(int target_mode);

void show_rt_param(struct rt_task* tp);
task_class_t str2class(const char* str);

/* non-preemptive section support */
void enter_np(void);
void exit_np(void);

#endif