summaryrefslogtreecommitdiff
path: root/src/rt-app_types.h
blob: 8e33e936298bb4d566a3f72418c46eadb9e7821d (plain)
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/* 
This file is part of rt-app - https://launchpad.net/rt-app
Copyright (C) 2010  Giacomo Bagnoli <g.bagnoli@asidev.com>

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/ 

#ifndef _RTAPP_TYPES_H_
#define _RTAPP_TYPES_H_

#include "config.h"
#ifdef DLSCHED
#include "dl_syscalls.h"
#endif
#include <sched.h>
#include <pthread.h>
#include <time.h>
#include <stdio.h>
#include <sched.h>
#ifdef AQUOSA
#include <aquosa/qres_lib.h>
#endif /* AQUOSA */

#define RTAPP_POLICY_DESCR_LENGTH 16
/* exit codes */

#define EXIT_SUCCESS 0
#define EXIT_FAILURE 1
#define EXIT_INV_CONFIG 2
#define EXIT_INV_COMMANDLINE 3

typedef enum policy_t 
{ 
	other = SCHED_OTHER, 
	rr = SCHED_RR, 
	fifo = SCHED_FIFO
#ifdef AQUOSA
	, aquosa = 1000 
#endif
#ifdef DLSCHED
	, deadline = SCHED_DEADLINE
#endif
} policy_t;

/* Shared resources */
typedef struct _rtapp_resource_t {
	pthread_mutex_t mtx;
	int index;
} rtapp_resource_t;

typedef struct _rtapp_resource_access_list_t {
	rtapp_resource_t *res;
	struct _rtapp_resource_access_list_t *next;
	struct _rtapp_resource_access_list_t *prev;
} rtapp_resource_access_list_t;

typedef struct _rtapp_tasks_resource_list_t {
	struct timespec usage;
	struct _rtapp_resource_access_list_t *acl;
} rtapp_tasks_resource_list_t; 

typedef struct _thread_data_t {
	int ind;
	char *name;
	int lock_pages;
	int duration;
	cpu_set_t *cpuset;
	char *cpuset_str;
	unsigned long wait_before_start;
	struct timespec min_et, max_et;
	struct timespec period, deadline;
	struct timespec main_app_start;
    
	FILE *log_handler;
	policy_t sched_policy;
	char sched_policy_descr[RTAPP_POLICY_DESCR_LENGTH];
	int sched_prio;

	rtapp_tasks_resource_list_t *blockages;
	int nblockages;

#ifdef AQUOSA
	int fragment;
	int sid;
	qres_params_t params;
#endif

#ifdef DLSCHED
	struct sched_param_ex dl_params;
#endif
} thread_data_t;

typedef struct _rtapp_options_t {
    int lock_pages;

    thread_data_t *threads_data;
    int nthreads;

    policy_t policy;
    int duration;
    unsigned long spacing;

    char *logdir;
    char *logbasename;
    int gnuplot;

    rtapp_resource_t *resources;
    int nresources;

#ifdef AQUOSA
    int fragment;
#endif
} rtapp_options_t;

typedef struct _timing_point_t {
	int ind;
	unsigned long period;
	unsigned long min_et;
	unsigned long max_et;
	unsigned long rel_start_time;
	unsigned long abs_start_time;
	unsigned long end_time;
	unsigned long deadline;
	unsigned long duration;
	long slack;
#ifdef AQUOSA
	qres_time_t budget;
	qres_time_t used_budget;
#endif
} timing_point_t;

#endif // _RTAPP_TYPES_H_