-
Notifications
You must be signed in to change notification settings - Fork 1
/
simrts.h
140 lines (109 loc) · 3.23 KB
/
simrts.h
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
#ifndef _SIMRTS_H_
#define _SIMRTS_H_
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include <stdarg.h>
#include <string.h>
#include <assert.h>
#include <math.h>
#include "ecm_list.h"
#define TRUE 1
#define FALSE 0
#define MAX_CPU_FREQS 10
#define MAX_MEMS 2
#define ASSERT(cond) do { assert(cond); } while (0)
#define FATAL(exitcode, fmt, ...) do { errmsg(fmt, ## __VA_ARGS__); exit(exitcode); } while (0)
typedef int BOOL;
typedef enum {
MEMTYPE_NONE = 0,
MEMTYPE_DRAM = 1,
MEMTYPE_NVRAM = 2,
} mem_type_t;
typedef struct {
unsigned no;
unsigned wcet;
unsigned period;
unsigned memreq;
double mem_active_ratio;
int idx_cpufreq;
mem_type_t mem_type;
/* dynamic execution time */
unsigned det; /* in tick */
/* remaining execution time */
unsigned det_remain; /* in tick */
/* for reverting */
unsigned det_old, det_remain_old;
/* ticks gap from a simtime if a task is a head task */
unsigned gap_head; /* in tick */
/* ticks from a start tick of a following task if any */
unsigned gap; /* in tick */
/* deadline ticks including det
*/
unsigned deadline; /* in tick */
struct list_head list_sched;
} task_t;
typedef struct {
double wcet_scale;
double power_active, power_idle; /* per tick */
} cpufreq_t;
typedef struct {
mem_type_t mem_type;
unsigned max_capacity;
double wcet_scale;
double power_active, power_idle; /* per tick * mem_req */
unsigned amount;
unsigned n_tasks;
} mem_t;
typedef struct {
const char *name;
const char *desc;
BOOL single_memtype;
BOOL (*init)(void);
BOOL (*assign_task)(task_t *task);
BOOL (*reassign_task)(task_t *task);
} policy_t;
extern BOOL verbose;
extern unsigned simtime;
extern unsigned n_tasks;
extern unsigned n_cpufreqs;
extern cpufreq_t cpufreqs[];
extern policy_t *policy;
extern struct list_head tasks;
extern unsigned n_mem_types;
extern mem_t mems[];
extern double power_consumed_cpu_active;
extern double power_consumed_mem_active;
extern double power_consumed_cpu_idle;
extern double power_consumed_mem_idle;
void errmsg(const char *fmt, ...);
void load_conf(const char *fpath);
void init_mems(void);
void reinit_mems(void);
void insert_task(unsigned wcet, unsigned period, unsigned memreq, double mem_active_ratio);
BOOL setup_tasks(void);
void calc_task_det(task_t *task);
void revert_task_det(task_t *task);
task_t *pop_head_task(void);
double get_tasks_ndet(void);
BOOL is_schedulable(task_t *task);
BOOL schedule_task(task_t *task);
void requeue_task(task_t *task, unsigned ticks);
void check_queued_tasks(void);
void reinit_tasks(void);
BOOL insert_cpufreq(double wcet_scale, double power_active, double power_idle);
void insert_mem(const char *memstr, unsigned max_capacity, double wcet_scale, double power_active, double power_idle);
BOOL assign_mem(task_t *task, mem_type_t mem_type);
void revoke_mem(task_t *task);
void calc_idle_power_consumed_task(task_t *task, unsigned idle);
void calc_idle_power_consumed_mem(unsigned idle);
void calc_active_power_consumed(task_t *task, unsigned ret);
double calc_task_power_consumed(task_t *task);
void add_utilization(void);
void report_header(void);
void report_result(void);
void cleanup_report(void);
extern const char *desc_task(task_t *task);
extern void show_queued_tasks(void);
#endif