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 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244
|
/*
This file is part of rt-app - https://launchpad.net/rt-app
Copyright (C) 2010 Giacomo Bagnoli <g.bagnoli@asidev.com>
Copyright (C) 2014 Juri Lelli <juri.lelli@gmail.com>
Copyright (C) 2014 Vincent Guittot <vincent.guittot@linaro.org>
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 <pthread.h>
#include "config.h"
#include "dl_syscalls.h"
#define RTAPP_POLICY_DESCR_LENGTH 16
#define RTAPP_RESOURCE_DESCR_LENGTH 16
#define RTAPP_FTRACE_PATH_LENGTH 256
#define DEFAULT_THREAD_PRIORITY 10
#define DEFAULT_THREAD_NICE 0
#define PATH_LENGTH 256
/* 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 DLSCHED
, deadline = SCHED_DEADLINE
#endif
} policy_t;
typedef enum resource_t
{
rtapp_unknown = 0,
rtapp_mutex,
rtapp_wait,
rtapp_signal,
rtapp_broadcast,
rtapp_sleep,
rtapp_run,
rtapp_sig_and_wait,
rtapp_lock,
rtapp_unlock,
rtapp_timer,
rtapp_suspend,
rtapp_resume,
rtapp_mem,
rtapp_iorun,
rtapp_runtime,
rtapp_yield,
rtapp_barrier
} resource_t;
struct _rtapp_mutex {
pthread_mutex_t obj;
pthread_mutexattr_t attr;
} ;
struct _rtapp_cond {
pthread_cond_t obj;
pthread_condattr_t attr;
};
struct _rtapp_barrier_like {
/* sync operation which works without ordering - everyone waits
* until the last task arrives at the sync point. Conceptually
* just like pthread_barrier except we don't have any cleanup
* issues which barrier would impose */
/* mutex to guard read/write of the flag */
pthread_mutex_t m_obj;
pthread_mutexattr_t m_attr;
/* flag to indicate how many are waiting */
int waiting;
/* condvar to wait/signal on */
pthread_cond_t c_obj;
};
struct _rtapp_signal {
pthread_cond_t *target;
};
struct _rtapp_timer {
struct timespec t_next;
int init;
int relative;
};
struct _rtapp_iomem_buf {
char *ptr;
int size;
};
struct _rtapp_iodev {
int fd;
};
/* Shared resources */
typedef struct _rtapp_resource_t {
union {
struct _rtapp_mutex mtx;
struct _rtapp_cond cond;
struct _rtapp_signal signal;
struct _rtapp_timer timer;
struct _rtapp_iomem_buf buf;
struct _rtapp_iodev dev;
struct _rtapp_barrier_like barrier;
} res;
int index;
resource_t type;
char *name;
} rtapp_resource_t;
typedef struct _event_data_t {
resource_t type;
int res;
int dep;
int duration;
int count;
} event_data_t;
typedef struct _cpuset_data_t {
cpu_set_t *cpuset;
char *cpuset_str;
size_t cpusetsize;
} cpuset_data_t;
typedef struct _phase_data_t {
int loop;
event_data_t *events;
int nbevents;
cpuset_data_t cpu_data;
} phase_data_t;
typedef struct _thread_data_t {
int ind;
char *name;
int lock_pages;
int duration;
rtapp_resource_t **resources;
cpuset_data_t cpu_data; /* cpu set information */
cpuset_data_t *curr_cpu_data; /* Current cpu set being used */
cpuset_data_t def_cpu_data; /* Default cpu set for task */
unsigned long runtime, deadline, period;
int loop;
int nphases;
phase_data_t *phases;
struct timespec main_app_start;
FILE *log_handler;
policy_t sched_policy;
char sched_policy_descr[RTAPP_POLICY_DESCR_LENGTH];
int sched_prio;
unsigned long delay;
#ifdef DLSCHED
struct sched_attr dl_params;
#endif
} thread_data_t;
typedef struct _ftrace_data_t {
char *debugfs;
int trace_fd;
int marker_fd;
} ftrace_data_t;
typedef struct _log_data_t {
unsigned long perf;
unsigned long duration;
unsigned long wu_latency;
unsigned long c_duration;
unsigned long c_period;
long slack;
} log_data_t;
typedef struct _rtapp_options_t {
int lock_pages;
thread_data_t *threads_data;
int nthreads;
policy_t policy;
int duration;
char *logdir;
char *logbasename;
int logsize;
int gnuplot;
int calib_cpu;
int calib_ns_per_loop;
rtapp_resource_t *resources;
int nresources;
int pi_enabled;
int ftrace;
int die_on_dmiss;
int mem_buffer_size;
char *io_device;
int cumulative_slack;
} rtapp_options_t;
typedef struct _timing_point_t {
int ind;
unsigned long perf;
unsigned long duration;
unsigned long period;
unsigned long c_duration;
unsigned long c_period;
unsigned long wu_latency;
long slack;
__u64 start_time;
__u64 end_time;
__u64 rel_start_time;
} timing_point_t;
#endif // _RTAPP_TYPES_H_
|