aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2012-04-26 16:53:06 -0400
committerJonathan Herman <hermanjl@cs.unc.edu>2012-04-26 16:53:06 -0400
commitff87ca319b0cd76f96f78f0347ad9aaa967bb16e (patch)
treea8ad3fec8814818363157ddd2a4efb9a6bc5b852
parentbffbb34c86e0d14aac65207aa55c5b769b2e4128 (diff)
Bespin now requests resources
-rw-r--r--Makefile14
-rw-r--r--bin/bespin.c15
-rw-r--r--bin/common.c41
-rw-r--r--bin/rtspin.c14
-rw-r--r--include/common.h3
-rw-r--r--src/kernel_iface.c7
-rw-r--r--src/litmus.c1
7 files changed, 80 insertions, 15 deletions
diff --git a/Makefile b/Makefile
index c5a8c0a..6b1feed 100644
--- a/Makefile
+++ b/Makefile
@@ -12,14 +12,15 @@ host-arch := $(shell uname -m | \
12ARCH ?= ${host-arch} 12ARCH ?= ${host-arch}
13 13
14# LITMUS_KERNEL -- where to find the litmus kernel? 14# LITMUS_KERNEL -- where to find the litmus kernel?
15LITMUS_KERNEL ?= ../litmus2010 15LITMUS_KERNEL ?= ../litmus-rt
16 16
17 17
18# ############################################################################## 18# ##############################################################################
19# Internal configuration. 19# Internal configuration.
20 20
21# compiler flags 21# compiler flags
22flags-debug = -Wall -Werror -g -Wdeclaration-after-statement 22# flags-debug = -Wall -Werror -g -Wdeclaration-after-statement
23flags-debug = -Wall -g -Wdeclaration-after-statement
23flags-api = -D_XOPEN_SOURCE=600 -D_GNU_SOURCE 24flags-api = -D_XOPEN_SOURCE=600 -D_GNU_SOURCE
24 25
25# architecture-specific flags 26# architecture-specific flags
@@ -154,7 +155,7 @@ arch/${include-${ARCH}}/include/asm/%.h: \
154 cp $< $@ 155 cp $< $@
155 156
156litmus-headers = include/litmus/rt_param.h include/litmus/unistd_32.h \ 157litmus-headers = include/litmus/rt_param.h include/litmus/unistd_32.h \
157 include/litmus/unistd_64.h include/litmus/sched_mc.h 158 include/litmus/unistd_64.h include/litmus/sched_mc.h include/litmus/color.h
158 159
159unistd-headers = \ 160unistd-headers = \
160 $(foreach file,${unistd-${ARCH}},arch/${include-${ARCH}}/include/asm/$(file)) 161 $(foreach file,${unistd-${ARCH}},arch/${include-${ARCH}}/include/asm/$(file))
@@ -207,14 +208,13 @@ obj-base_mt_task = base_mt_task.o
207ldf-base_mt_task = -pthread 208ldf-base_mt_task = -pthread
208 209
209obj-rt_launch = rt_launch.o common.o 210obj-rt_launch = rt_launch.o common.o
211lib-rt_launch = -lgsl -lgslcblas
210 212
211obj-rtspin = rtspin.o common.o 213obj-rtspin = rtspin.o common.o
212lib-rtspin = -lrt 214lib-rtspin = -lrt -lgsl -lgslcblas
213 215
214obj-rtspin.ovh = rtspin.ovh.o common.o 216obj-rtspin.ovh = rtspin.ovh.o common.o
215lib-rtspin.ovh = -lrt 217lib-rtspin.ovh = -lrt -lgsl -lgslcblas
216
217
218 218
219obj-rtspin.beta = rtspin.beta.o common.o 219obj-rtspin.beta = rtspin.beta.o common.o
220lib-rtspin.beta = -lrt $(shell gsl-config --libs) 220lib-rtspin.beta = -lrt $(shell gsl-config --libs)
diff --git a/bin/bespin.c b/bin/bespin.c
index 5c98a1f..4495721 100644
--- a/bin/bespin.c
+++ b/bin/bespin.c
@@ -51,6 +51,8 @@ static void usage(char *error) {
51static int num[NUMS]; 51static int num[NUMS];
52static char* progname; 52static char* progname;
53 53
54static int task_colors, avg_ways;
55
54static gsl_rng *exec_rng; 56static gsl_rng *exec_rng;
55static gsl_rng *ia_rng; 57static gsl_rng *ia_rng;
56static struct timespec sleep_ts = { .tv_sec = 0 }; 58static struct timespec sleep_ts = { .tv_sec = 0 };
@@ -240,6 +242,8 @@ static void setup_litmus_task(const double phase_ms, const int cpu)
240 if (ret < 0) 242 if (ret < 0)
241 bail_out("could not setup rt task params"); 243 bail_out("could not setup rt task params");
242 244
245 request_resources(task_colors, avg_ways);
246
243 init_litmus(); 247 init_litmus();
244 248
245 ret = task_mode(LITMUS_RT_TASK); 249 ret = task_mode(LITMUS_RT_TASK);
@@ -247,7 +251,7 @@ static void setup_litmus_task(const double phase_ms, const int cpu)
247 bail_out("could not become RT task"); 251 bail_out("could not become RT task");
248} 252}
249 253
250#define OPTSTR "p:wnos:f:" 254#define OPTSTR "p:wl:r:nos:f:h:"
251 255
252int main(int argc, char** argv) 256int main(int argc, char** argv)
253{ 257{
@@ -286,9 +290,9 @@ int main(int argc, char** argv)
286 case 's': 290 case 's':
287 seed = atoi(optarg); 291 seed = atoi(optarg);
288 break; 292 break;
289 case 'h': 293 /* case 'h': */
290 phase_ms = atof(optarg); 294 /* phase_ms = atof(optarg); */
291 break; 295 /* break; */
292 case 'e': 296 case 'e':
293 exec_mean_ms = atof(optarg); 297 exec_mean_ms = atof(optarg);
294 break; 298 break;
@@ -298,6 +302,9 @@ int main(int argc, char** argv)
298 case 'f': 302 case 'f':
299 out_fname = optarg; 303 out_fname = optarg;
300 break; 304 break;
305 case 'h':
306 sscanf(optarg, "%d,%d", &task_colors, &avg_ways);
307 break;
301 case ':': 308 case ':':
302 usage("Argument missing."); 309 usage("Argument missing.");
303 break; 310 break;
diff --git a/bin/common.c b/bin/common.c
index 452b882..2aa9a7c 100644
--- a/bin/common.c
+++ b/bin/common.c
@@ -3,9 +3,50 @@
3#include <errno.h> 3#include <errno.h>
4 4
5#include "common.h" 5#include "common.h"
6#include "litmus.h"
7#include <litmus/color.h>
8
9#include <gsl/gsl_rng.h>
10#include <gsl/gsl_randist.h>
6 11
7void bail_out(const char* msg) 12void bail_out(const char* msg)
8{ 13{
9 perror(msg); 14 perror(msg);
10 exit(-1 * errno); 15 exit(-1 * errno);
11} 16}
17
18void request_resources(int task_colors, int avg_ways)
19{
20 const gsl_rng *way_rng = gsl_rng_alloc(gsl_rng_taus);
21 struct control_page *page = get_ctrl_page();
22 int color, ways, rem = task_colors;
23 float random;
24 char taken[NUM_COLORS];
25
26 memset(page->requests, 0, NUM_COLORS*sizeof(*page->requests));
27
28 gsl_rng_set(way_rng, rand());
29 memset(taken, 0, NUM_COLORS);
30
31 srand(getpid());
32 gsl_rng_set(way_rng, getpid());
33
34 while (rem) {
35 /* select a random unchosen color */
36 do {
37 color = rand() % NUM_COLORS;
38 } while (taken[color]);
39
40 if (rand() % NUM_COLORS <= task_colors) {
41 taken[color] = 1;
42 rem --;
43
44 random = gsl_ran_exponential(way_rng, avg_ways + 1);
45 ways = 1 + (int)random;
46 ways = (ways < 1) ? 1 : ways;
47 ways = (ways > NUM_WAYS) ? NUM_WAYS : ways;
48
49 page->requests[color] = ways;
50 }
51 }
52}
diff --git a/bin/rtspin.c b/bin/rtspin.c
index 9800eb2..c680529 100644
--- a/bin/rtspin.c
+++ b/bin/rtspin.c
@@ -6,14 +6,14 @@
6#include <time.h> 6#include <time.h>
7#include <assert.h> 7#include <assert.h>
8#include <strings.h> 8#include <strings.h>
9 9#include <string.h>
10 10
11#include "litmus.h" 11#include "litmus.h"
12#include "common.h" 12#include "common.h"
13/* #include "color.h" */
13 14
14#include <litmus/sched_mc.h> 15#include <litmus/sched_mc.h>
15 16
16
17static void usage(char *error) { 17static void usage(char *error) {
18 fprintf(stderr, "Error: %s\n", error); 18 fprintf(stderr, "Error: %s\n", error);
19 fprintf(stderr, 19 fprintf(stderr,
@@ -24,6 +24,7 @@ static void usage(char *error) {
24 "\n" 24 "\n"
25 "COMMON-OPTS = [-w] [-p PARTITION] [-c CLASS] [-s SCALE]\n" 25 "COMMON-OPTS = [-w] [-p PARTITION] [-c CLASS] [-s SCALE]\n"
26 " [-r CRITICALITY = [a|b|c|d]] [-i MC-LVL-A-ID]\n" 26 " [-r CRITICALITY = [a|b|c|d]] [-i MC-LVL-A-ID]\n"
27 " [-h NUM-COLORS,AVG-WAYS]\n"
27 "\n" 28 "\n"
28 "WCET and PERIOD are milliseconds, DURATION is seconds.\n"); 29 "WCET and PERIOD are milliseconds, DURATION is seconds.\n");
29 exit(EXIT_FAILURE); 30 exit(EXIT_FAILURE);
@@ -176,7 +177,7 @@ enum crit_level str2crit(const char* str)
176 return NUM_CRIT_LEVELS; 177 return NUM_CRIT_LEVELS;
177} 178}
178 179
179#define OPTSTR "p:c:wlveo:f:s:r:i:" 180#define OPTSTR "p:c:wlveo:f:s:r:i:h:"
180 181
181int main(int argc, char** argv) 182int main(int argc, char** argv)
182{ 183{
@@ -197,6 +198,8 @@ int main(int argc, char** argv)
197 double scale = 1.0; 198 double scale = 1.0;
198 task_class_t class = RT_CLASS_HARD; 199 task_class_t class = RT_CLASS_HARD;
199 int cur_job, num_jobs; 200 int cur_job, num_jobs;
201 int task_colors = 0;
202 int avg_ways = 0;
200 struct mc_task mc_task = { .crit = NUM_CRIT_LEVELS, .lvl_a_id = -1 }; 203 struct mc_task mc_task = { .crit = NUM_CRIT_LEVELS, .lvl_a_id = -1 };
201 204
202 progname = argv[0]; 205 progname = argv[0];
@@ -238,6 +241,9 @@ int main(int argc, char** argv)
238 case 'i': 241 case 'i':
239 mc_task.lvl_a_id = atoi(optarg); 242 mc_task.lvl_a_id = atoi(optarg);
240 break; 243 break;
244 case 'h':
245 sscanf(optarg, "%d,%d", &task_colors, &avg_ways);
246 break;
241 case ':': 247 case ':':
242 usage("Argument missing."); 248 usage("Argument missing.");
243 break; 249 break;
@@ -313,6 +319,8 @@ int main(int argc, char** argv)
313 319
314 init_litmus(); 320 init_litmus();
315 321
322 request_resources(task_colors, avg_ways);
323
316 ret = task_mode(LITMUS_RT_TASK); 324 ret = task_mode(LITMUS_RT_TASK);
317 if (ret != 0) 325 if (ret != 0)
318 bail_out("could not become RT task"); 326 bail_out("could not become RT task");
diff --git a/include/common.h b/include/common.h
index d1234ba..5c7ed68 100644
--- a/include/common.h
+++ b/include/common.h
@@ -1,7 +1,8 @@
1#ifndef COMMON_H 1#ifndef COMMON_H
2#define COMMON_H 2#define COMMON_H
3 3
4
5void bail_out(const char* msg); 4void bail_out(const char* msg);
6 5
6void request_resources(int task_colors, int avg_ways);
7
7#endif 8#endif
diff --git a/src/kernel_iface.c b/src/kernel_iface.c
index 1426795..6286810 100644
--- a/src/kernel_iface.c
+++ b/src/kernel_iface.c
@@ -71,6 +71,13 @@ void exit_np(void)
71 } 71 }
72} 72}
73 73
74void request_resource(int resource, int replicas)
75{
76 if (likely(ctrl_page != NULL)) {
77 ctrl_page->requests[resource] = replicas;
78 }
79}
80
74/* init and return a ptr to the control page for 81/* init and return a ptr to the control page for
75 * preemption and migration overhead analysis 82 * preemption and migration overhead analysis
76 * 83 *
diff --git a/src/litmus.c b/src/litmus.c
index d3cc6bb..d8a6b96 100644
--- a/src/litmus.c
+++ b/src/litmus.c
@@ -72,6 +72,7 @@ int sporadic_task_ns(lt_t e, lt_t p, lt_t phase,
72 ret = be_migrate_to(cpu); 72 ret = be_migrate_to(cpu);
73 check("migrate to cpu"); 73 check("migrate to cpu");
74 } 74 }
75
75 return set_rt_task_param(gettid(), &param); 76 return set_rt_task_param(gettid(), &param);
76} 77}
77 78