aboutsummaryrefslogtreecommitdiffstats
path: root/gpu/normal_task.c
blob: ccc265c5f543fd895ea9a89f04e92add1d8adf9b (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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <unistd.h>
#include <assert.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <time.h>
#include <math.h>

/* Include gettid() */
#include <sys/types.h>

/* Include threading support. */
#include <pthread.h>

/* Include the LITMUS^RT API.*/
#include "litmus.h"

/* Catch errors.
 */
#if 1
#define CALL( exp ) do { \
		int ret; \
		ret = exp; \
		if (ret != 0) \
			fprintf(stderr, "%s failed: %m\n", #exp);\
		else \
			fprintf(stderr, "%s ok.\n", #exp); \
	} while (0)

#define TH_CALL( exp ) do { \
		int ret; \
		ret = exp; \
		if (ret != 0) \
			fprintf(stderr, "[%d] %s failed: %m\n", ctx->id, #exp); \
		else \
			fprintf(stderr, "[%d] %s ok.\n", ctx->id, #exp); \
	} while (0)

#define TH_SAFE_CALL( exp ) do { \
		int ret; \
		fprintf(stderr, "[%d] calling %s...\n", ctx->id, #exp); \
		ret = exp; \
		if (ret != 0) \
			fprintf(stderr, "\t...[%d] %s failed: %m\n", ctx->id, #exp); \
		else \
			fprintf(stderr, "\t...[%d] %s ok.\n", ctx->id, #exp); \
	} while (0)
#else
#define CALL( exp )
#define TH_CALL( exp )
#define TH_SAFE_CALL( exp )
#endif

/* these are only default values */
// 1000 = 1us
#define EXEC_COST 	1000*1
#define PERIOD		2*1000*100


int main(int argc, char** argv)
{
	struct rt_task param;

	init_rt_task_param(&param);
	param.exec_cost = EXEC_COST;
	param.period = PERIOD;
	param.cls = RT_CLASS_SOFT;

	CALL( init_litmus() );

	CALL( init_rt_thread() );
	CALL( set_rt_task_param(gettid(), &param) );
	//CALL( task_mode(LITMUS_RT_TASK) );

	fprintf(stdout, "Waiting for TS release.\n ");
	wait_for_ts_release();

	fprintf(stdout, "Released!\n");

	//sleep_next_period();
	//CALL( task_mode(BACKGROUND_TASK) );

	return 0;
}