aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2011-04-06 16:48:24 -0400
committerJonathan Herman <hermanjl@cs.unc.edu>2011-04-06 16:48:24 -0400
commitc124ecc9f502b11f331153ffaba243b7b1031a92 (patch)
tree597157a1bbc8d3f1a27b5fe5462a7a79f46b6047 /include
parent2a604f8edec24b291ba2c5491108808176c9020f (diff)
Consolidated data into server_domain_t.
Diffstat (limited to 'include')
-rw-r--r--include/litmus/servers.h179
1 files changed, 106 insertions, 73 deletions
diff --git a/include/litmus/servers.h b/include/litmus/servers.h
index 97fd0ce76207..d3e45857653b 100644
--- a/include/litmus/servers.h
+++ b/include/litmus/servers.h
@@ -3,125 +3,161 @@
3 3
4struct server; 4struct server;
5struct periodic_server; 5struct periodic_server;
6struct proc_read_args;
7struct proc_dir_entry; 6struct proc_dir_entry;
8struct server_domain; 7struct server_domain;
9struct server_release_heap; 8struct server_release_heap;
9struct completion_timer;
10struct server_proc;
10 11
11#define SERVER_RELEASE_QUEUE_SLOTS 127 12#define SERVER_RELEASE_QUEUE_SLOTS 127
12 13
13#define SERVER_FMT "{server/%d:%d}" 14#define SERVER_FMT "{server/%d:%d}"
14#define SERVER_ARGS(s) (s)->id, (s)->job_no 15#define SERVER_ARGS(s) (s)->id, (s)->job_no
15 16
17#define server_task(s) (((s)->cpu != NO_CPU)?s->domain->linked_tasks[(s)->cpu]:NULL)
18#define is_server_linked(s) ((s)->cpu != NO_CPU)
19
16/* 20/*
17 * Called when a server is released. 21 * A single schedulable server.
18 */
19typedef void (*post_release_t)(struct periodic_server *server);
20/*
21 * Called when a server exhausts its budget.
22 */
23typedef void (*server_completed_t)(struct server *server,
24 struct task_struct *was_running);
25/*
26 * Used to read server entries.
27 */
28typedef int (*admit_server_t)(unsigned long long wcet,
29 unsigned long long period, int cpu);
30/*
31 * Must call server_proc_read on each server to print.
32 */
33typedef void (*list_servers_t)(struct proc_read_args *args);
34/*
35 * Called after each proc write before new values are read.
36 */
37typedef void (*stop_servers_t)(void);
38/*
39 * Called when a group of servers release
40 */ 22 */
41typedef void (*servers_released_t)(struct list_head *servers);
42
43typedef struct server { 23typedef struct server {
44 /* Specified by the user */ 24 /* Specified by the user */
45 int id; 25 int id;
46 lt_t wcet; 26 lt_t wcet;
47 lt_t period; 27 lt_t period;
48 28
29 /* Optional */
30 int type;
31 void* data;
32
49 /* Managed internally */ 33 /* Managed internally */
50 lt_t deadline; 34 lt_t deadline;
51 lt_t release; 35 lt_t release;
52 lt_t budget; /* The remaining budget for current period */ 36 lt_t budget; /* The remaining budget for current period */
53 lt_t start_time; /* The time the server started executing or 0 */
54 int running; /* True if server is currently executing */
55 int job_no; /* Current job of server */ 37 int job_no; /* Current job of server */
38 int cpu; /* CPU the server is running on or NO_CPU */
56 39
57 int type; /* Optional */ 40 struct server_domain *domain;
58
59 /* Used for grouped releases */
60 struct server_release_heap *release_heap;
61 struct list_head release_list;
62 41
63 /* Useful in general */ 42 /* For membership in collections */
64 struct bheap_node *hn; 43 struct bheap_node *hn;
65 struct list_head list; 44 struct list_head list;
66 45
67 void* data; 46 /* Used for grouped releases */
68 47 struct server_release_heap *release_heap;
69 struct task_struct* scheduled; 48 struct list_head release_list;
70} server_t; 49} server_t;
71 50
72/* 51/*
73 * Because pointer arithmetic wasn't working. TODO: pointer arithmetic 52 * Called when a server exhausts its budget.
74 */ 53 */
75typedef struct completion_timer { 54typedef void (*server_completed_t)(struct server *server,
76 int armed; 55 struct task_struct *was_running);
77 int cpu; 56/*
78 struct hrtimer timer; 57 * Called when a group of servers release
79 struct hrtimer_start_on_info info; 58 */
80 struct server_domain *domain; 59typedef void (*servers_released_t)(struct list_head *servers);
81} completion_timer_t; 60/*
61 * Used to read server entries.
62 */
63typedef int (*admit_server_t)(unsigned long long wcet,
64 unsigned long long period, int cpu);
65/*
66 * Lists all servers for a proc entry by calling list_server on each.
67 */
68typedef void (*list_servers_t)(struct server_proc *proc);
69/*
70 * Stop all servers. Used to destroy servers on a proc entry rewrite.
71 */
72typedef void (*stop_servers_t)(void);
82 73
83/* 74/*
84 * Useful tools for scheduling servers. 75 * Useful tools for scheduling servers.
85 */ 76 */
86typedef struct server_domain { 77typedef struct server_domain {
78 /* Collection of grouped releases */
87 raw_spinlock_t release_lock; 79 raw_spinlock_t release_lock;
88 struct list_head release_queue[SERVER_RELEASE_QUEUE_SLOTS]; 80 struct list_head release_queue[SERVER_RELEASE_QUEUE_SLOTS];
89 81
90 int release_master; 82 /* List of tasks to be added to the grouped releases */
83 raw_spinlock_t tobe_lock;
84 struct list_head tobe_released;
91 85
92 completion_timer_t* completion_timers; 86 /* CPU on which to release servers */
93 server_t** running; 87 int release_master;
94 88
95 raw_spinlock_t* timer_lock; 89 /* Per CPU information for running servers */
90 struct completion_timer* completion_timers;
91 server_t** linked_servers;
92 struct task_struct** linked_tasks;
93 lt_t* start_times;
96 94
95 /* Used to lock firing of the completion timer.
96 * This is needed here and not for the release timer because
97 * the completion timer actually modifies the state of the
98 * server itself.
99 */
100 raw_spinlock_t* completion_lock;
101
102 /* Event callbacks */
97 server_completed_t server_completed; 103 server_completed_t server_completed;
98 servers_released_t servers_released; 104 servers_released_t servers_released;
99 105
100 struct kmem_cache *server_release_cache; 106 /* Proc entries for controlling groups of servers */
101 107 struct list_head server_procs;
102 raw_spinlock_t tobe_lock;
103 struct list_head tobe_released;
104} server_domain_t; 108} server_domain_t;
105 109
106/* 110/*
107 * A group of servers releasing simultaneously. 111 * A group of servers releasing simultaneously.
108 */ 112 */
109typedef struct server_release_heap { 113typedef struct server_release_heap {
110 struct list_head list; 114 /* Servers to be released */
111 lt_t release_time; 115 struct list_head servers;
116 lt_t release_time;
112 117
113 struct list_head servers; 118 /* For membership in the domain */
119 struct list_head list;
120
121 /* For callbacks */
122 server_domain_t *domain;
114 123
115 struct hrtimer timer; 124 struct hrtimer timer;
116 struct hrtimer_start_on_info info; 125 struct hrtimer_start_on_info info;
117
118 server_domain_t *domain;
119} server_release_heap_t; 126} server_release_heap_t;
120 127
121/* 128/*
129 * A timer for managing server completions. Can be managed concurrently.
130 */
131typedef struct completion_timer {
132 int armed; /* Is the timer armed or not? Seperate from the timer
133 * so that it can be used to disarm a timer which
134 * is already firing.
135 */
136 int cpu; /* CPU where the server is running. This is not the
137 * cpu on which the timer will fire.
138 */
139 struct hrtimer timer;
140 struct hrtimer_start_on_info info;
141 struct server_domain *domain; /* For callbacks */
142} completion_timer_t;
143
144/*
145 * A proc directory entry which controls a group of servers.
146 */
147typedef struct server_proc {
148 struct proc_dir_entry *entry;
149 struct list_head list;
150 admit_server_t admit_server; /* Add a server from the entry */
151 list_servers_t list_servers; /* List each server in the entry */
152 stop_servers_t stop_servers; /* Disables all servers in the entry */
153 char* page; /* Used internally by proc */
154 int length; /* Used internally by proc */
155} server_proc_t;
156
157/*
122 * Initialize and exit servers 158 * Initialize and exit servers
123 */ 159 */
124void server_init(server_t *server, int id, 160void server_init(server_t *server, server_domain_t *domain, int id,
125 lt_t wcet, lt_t period, int grouped); 161 lt_t wcet, lt_t period, int grouped);
126void server_destroy(server_t *server); 162void server_destroy(server_t *server);
127 163
@@ -137,7 +173,7 @@ void server_free(server_t *server);
137void server_domain_init(server_domain_t *domain, 173void server_domain_init(server_domain_t *domain,
138 servers_released_t servers_released, 174 servers_released_t servers_released,
139 server_completed_t server_completed, 175 server_completed_t server_completed,
140 int release_master, raw_spinlock_t* timer_lock); 176 int release_master, raw_spinlock_t* completion_lock);
141void server_domain_destroy(server_domain_t *domain); 177void server_domain_destroy(server_domain_t *domain);
142 178
143/* 179/*
@@ -148,13 +184,12 @@ int add_server_release(server_t *server, server_domain_t *server_domain);
148/* 184/*
149 * Runs a task on the server. 185 * Runs a task on the server.
150 */ 186 */
151void server_run(server_t *server, struct task_struct *task, 187void server_run(server_t *server, struct task_struct *task);
152 server_domain_t *server_domain);
153 188
154/* 189/*
155 * Stops server execution. 190 * Stops server execution.
156 */ 191 */
157void server_stop(server_t *server, server_domain_t *domain); 192void server_stop(server_t *server);
158 193
159/* 194/*
160 * Begins a server's next period. 195 * Begins a server's next period.
@@ -167,20 +202,18 @@ void server_release(server_t *server);
167void server_release_at(server_t *server, lt_t time); 202void server_release_at(server_t *server, lt_t time);
168 203
169/* 204/*
170 * Call once for every server which should be printed 205 * Call once for every server which should be printed by list_servers.
171 * out on a proc dir read. Should be called inside a list_servers_t
172 * method.
173 */ 206 */
174void server_proc_read_single(server_t *server, int cpu, 207void list_server(server_t *server, int cpu, server_proc_t *proc);
175 struct proc_read_args *args);
176 208
177/* 209/*
178 * Create and destroy a proc dir entry with the given file name. 210 * Create and destroy a proc dir entry with the given file name.
179 */ 211 */
180int server_proc_init(struct proc_dir_entry *proc_dir, char *file, 212server_proc_t* server_proc_init(server_domain_t *domain,
181 admit_server_t admit_server, 213 struct proc_dir_entry *proc_dir, char *file,
182 list_servers_t list_servers, 214 admit_server_t admit_server,
183 stop_servers_t stop_servers); 215 list_servers_t list_servers,
184void server_proc_exit(struct proc_dir_entry *proc_dir, char *file); 216 stop_servers_t stop_servers);
217void server_proc_exit(server_proc_t *proc);
185 218
186#endif 219#endif