diff options
| author | Glenn Elliott <gelliott@cs.unc.edu> | 2013-03-05 18:32:01 -0500 |
|---|---|---|
| committer | Glenn Elliott <gelliott@cs.unc.edu> | 2013-03-12 12:47:20 -0400 |
| commit | 0a54a84457bb8a33113c7dd2a2b63b2a837cc92e (patch) | |
| tree | 78bd56eec72c7d47749155315d3506c424e0dc24 | |
| parent | 93ffe5be8fd1954bbfe5a04e55b81ac1d83d2de7 (diff) | |
Cluster-aware rtspin and rt_launch.
This patch adds cluster scheduling options to
rtspin and rt_launch. The convenience routines
in litmus.h were also updated to facilitate
clustered scheduling. For partitioned scheduling,
just set cluster_size = 1 (default size for rtspin
and rt_launch).
| -rw-r--r-- | bin/rt_launch.c | 22 | ||||
| -rw-r--r-- | bin/rtspin.c | 24 | ||||
| -rw-r--r-- | include/litmus.h | 36 | ||||
| -rw-r--r-- | src/litmus.c | 17 | ||||
| -rw-r--r-- | src/task.c | 14 |
5 files changed, 68 insertions, 45 deletions
diff --git a/bin/rt_launch.c b/bin/rt_launch.c index 97d9df9..ae68601 100644 --- a/bin/rt_launch.c +++ b/bin/rt_launch.c | |||
| @@ -29,10 +29,11 @@ int launch(void *task_info_p) { | |||
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | void usage(char *error) { | 31 | void usage(char *error) { |
| 32 | fprintf(stderr, "%s\nUsage: rt_launch [-w][-v][-p cpu][-q prio][-c hrt | srt | be] wcet period program [arg1 arg2 ...]\n" | 32 | fprintf(stderr, "%s\nUsage: rt_launch [-w][-v][-p partition/cluster [-z cluster size]][-q prio][-c hrt | srt | be] wcet period program [arg1 arg2 ...]\n" |
| 33 | "\t-w\tSynchronous release\n" | 33 | "\t-w\tSynchronous release\n" |
| 34 | "\t-v\tVerbose\n" | 34 | "\t-v\tVerbose\n" |
| 35 | "\t-p\tcpu (or initial cpu)\n" | 35 | "\t-p\tpartition or cluster\n" |
| 36 | "\t-z\tsize of cluster (default = 1 for partitioned)\n" | ||
| 36 | "\t-c\tClass\n" | 37 | "\t-c\tClass\n" |
| 37 | "\twcet, period in ms\n" | 38 | "\twcet, period in ms\n" |
| 38 | "\tprogram to be launched\n", | 39 | "\tprogram to be launched\n", |
| @@ -41,7 +42,7 @@ void usage(char *error) { | |||
| 41 | } | 42 | } |
| 42 | 43 | ||
| 43 | 44 | ||
| 44 | #define OPTSTR "p:c:vwq:" | 45 | #define OPTSTR "p:z:c:vwq:" |
| 45 | 46 | ||
| 46 | int main(int argc, char** argv) | 47 | int main(int argc, char** argv) |
| 47 | { | 48 | { |
| @@ -49,7 +50,8 @@ int main(int argc, char** argv) | |||
| 49 | lt_t wcet; | 50 | lt_t wcet; |
| 50 | lt_t period; | 51 | lt_t period; |
| 51 | int migrate = 0; | 52 | int migrate = 0; |
| 52 | int cpu = 0; | 53 | int cluster = 0; |
| 54 | int cluster_size = 1; | ||
| 53 | int opt; | 55 | int opt; |
| 54 | int verbose = 0; | 56 | int verbose = 0; |
| 55 | int wait = 0; | 57 | int wait = 0; |
| @@ -66,9 +68,12 @@ int main(int argc, char** argv) | |||
| 66 | verbose = 1; | 68 | verbose = 1; |
| 67 | break; | 69 | break; |
| 68 | case 'p': | 70 | case 'p': |
| 69 | cpu = atoi(optarg); | 71 | cluster = atoi(optarg); |
| 70 | migrate = 1; | 72 | migrate = 1; |
| 71 | break; | 73 | break; |
| 74 | case 'z': | ||
| 75 | cluster_size = atoi(optarg); | ||
| 76 | break; | ||
| 72 | case 'q': | 77 | case 'q': |
| 73 | priority = atoi(optarg); | 78 | priority = atoi(optarg); |
| 74 | if (!litmus_is_valid_fixed_prio(priority)) | 79 | if (!litmus_is_valid_fixed_prio(priority)) |
| @@ -109,11 +114,12 @@ int main(int argc, char** argv) | |||
| 109 | info.argv = argv + optind + 2; | 114 | info.argv = argv + optind + 2; |
| 110 | info.wait = wait; | 115 | info.wait = wait; |
| 111 | if (migrate) { | 116 | if (migrate) { |
| 112 | ret = be_migrate_to_cpu(cpu); | 117 | ret = be_migrate_to_cluster(cluster, cluster_size); |
| 113 | if (ret < 0) | 118 | if (ret < 0) |
| 114 | bail_out("could not migrate to target partition"); | 119 | bail_out("could not migrate to target partition or cluster"); |
| 115 | } | 120 | } |
| 116 | ret = __create_rt_task(launch, &info, cpu, wcet, period, priority, class); | 121 | ret = __create_rt_task(launch, &info, cluster, cluster_size, wcet, period, |
| 122 | priority, class); | ||
| 117 | 123 | ||
| 118 | 124 | ||
| 119 | if (ret < 0) | 125 | if (ret < 0) |
diff --git a/bin/rtspin.c b/bin/rtspin.c index 5f12930..b05c17c 100644 --- a/bin/rtspin.c +++ b/bin/rtspin.c | |||
| @@ -21,7 +21,8 @@ static void usage(char *error) { | |||
| 21 | " rt_spin [COMMON-OPTS] -f FILE [-o COLUMN] WCET PERIOD\n" | 21 | " rt_spin [COMMON-OPTS] -f FILE [-o COLUMN] WCET PERIOD\n" |
| 22 | " rt_spin -l\n" | 22 | " rt_spin -l\n" |
| 23 | "\n" | 23 | "\n" |
| 24 | "COMMON-OPTS = [-w] [-p PARTITION] [-c CLASS] [-s SCALE]\n" | 24 | "COMMON-OPTS = [-w] [-s SCALE]\n" |
| 25 | " [-p PARTITION/CLUSTER [-z CLUSTER SIZE]] [-c CLASS]\n" | ||
| 25 | " [-X LOCKING-PROTOCOL] [-L CRITICAL SECTION LENGTH] [-Q RESOURCE-ID]" | 26 | " [-X LOCKING-PROTOCOL] [-L CRITICAL SECTION LENGTH] [-Q RESOURCE-ID]" |
| 26 | "\n" | 27 | "\n" |
| 27 | "WCET and PERIOD are milliseconds, DURATION is seconds.\n" | 28 | "WCET and PERIOD are milliseconds, DURATION is seconds.\n" |
| @@ -183,7 +184,7 @@ static int job(double exec_time, double program_end, int lock_od, double cs_leng | |||
| 183 | } | 184 | } |
| 184 | } | 185 | } |
| 185 | 186 | ||
| 186 | #define OPTSTR "p:c:wlveo:f:s:q:X:L:Q:" | 187 | #define OPTSTR "p:z:c:wlveo:f:s:q:X:L:Q:" |
| 187 | 188 | ||
| 188 | int main(int argc, char** argv) | 189 | int main(int argc, char** argv) |
| 189 | { | 190 | { |
| @@ -193,7 +194,8 @@ int main(int argc, char** argv) | |||
| 193 | double wcet_ms, period_ms; | 194 | double wcet_ms, period_ms; |
| 194 | unsigned int priority = LITMUS_LOWEST_PRIORITY; | 195 | unsigned int priority = LITMUS_LOWEST_PRIORITY; |
| 195 | int migrate = 0; | 196 | int migrate = 0; |
| 196 | int cpu = 0; | 197 | int cluster = 0; |
| 198 | int cluster_size = 1; | ||
| 197 | int opt; | 199 | int opt; |
| 198 | int wait = 0; | 200 | int wait = 0; |
| 199 | int test_loop = 0; | 201 | int test_loop = 0; |
| @@ -221,9 +223,12 @@ int main(int argc, char** argv) | |||
| 221 | wait = 1; | 223 | wait = 1; |
| 222 | break; | 224 | break; |
| 223 | case 'p': | 225 | case 'p': |
| 224 | cpu = atoi(optarg); | 226 | cluster = atoi(optarg); |
| 225 | migrate = 1; | 227 | migrate = 1; |
| 226 | break; | 228 | break; |
| 229 | case 'z': | ||
| 230 | cluster_size = atoi(optarg); | ||
| 231 | break; | ||
| 227 | case 'q': | 232 | case 'q': |
| 228 | priority = atoi(optarg); | 233 | priority = atoi(optarg); |
| 229 | if (!litmus_is_valid_fixed_prio(priority)) | 234 | if (!litmus_is_valid_fixed_prio(priority)) |
| @@ -320,13 +325,8 @@ int main(int argc, char** argv) | |||
| 320 | else if (file && num_jobs > 1) | 325 | else if (file && num_jobs > 1) |
| 321 | duration += period_ms * 0.001 * (num_jobs - 1); | 326 | duration += period_ms * 0.001 * (num_jobs - 1); |
| 322 | 327 | ||
| 323 | if (migrate) { | 328 | ret = sporadic_task_ns(wcet, period, 0, cluster, cluster_size, |
| 324 | ret = be_migrate_to_cpu(cpu); | 329 | priority, class, |
| 325 | if (ret < 0) | ||
| 326 | bail_out("could not migrate to target partition"); | ||
| 327 | } | ||
| 328 | |||
| 329 | ret = sporadic_task_ns(wcet, period, 0, cpu, priority, class, | ||
| 330 | want_enforcement ? PRECISE_ENFORCEMENT | 330 | want_enforcement ? PRECISE_ENFORCEMENT |
| 331 | : NO_ENFORCEMENT, | 331 | : NO_ENFORCEMENT, |
| 332 | migrate); | 332 | migrate); |
| @@ -341,7 +341,7 @@ int main(int argc, char** argv) | |||
| 341 | 341 | ||
| 342 | if (protocol >= 0) { | 342 | if (protocol >= 0) { |
| 343 | /* open reference to semaphore */ | 343 | /* open reference to semaphore */ |
| 344 | lock_od = litmus_open_lock(protocol, resource_id, lock_namespace, &cpu); | 344 | lock_od = litmus_open_lock(protocol, resource_id, lock_namespace, &cluster); |
| 345 | if (lock_od < 0) { | 345 | if (lock_od < 0) { |
| 346 | perror("litmus_open_lock"); | 346 | perror("litmus_open_lock"); |
| 347 | usage("Could not open lock."); | 347 | usage("Could not open lock."); |
diff --git a/include/litmus.h b/include/litmus.h index b2e81f2..335d01b 100644 --- a/include/litmus.h +++ b/include/litmus.h | |||
| @@ -21,6 +21,13 @@ extern "C" { | |||
| 21 | int set_rt_task_param(pid_t pid, struct rt_task* param); | 21 | int set_rt_task_param(pid_t pid, struct rt_task* param); |
| 22 | int get_rt_task_param(pid_t pid, struct rt_task* param); | 22 | int get_rt_task_param(pid_t pid, struct rt_task* param); |
| 23 | 23 | ||
| 24 | /* Release-master-aware functions for getting the first | ||
| 25 | * CPU in a particular cluster or partition. Use these | ||
| 26 | * to set rt_task::cpu for cluster/partitioned scheduling. | ||
| 27 | */ | ||
| 28 | int partition_to_cpu(int partition); | ||
| 29 | int cluster_to_first_cpu(int cluster, int cluster_size); | ||
| 30 | |||
| 24 | /* setup helper */ | 31 | /* setup helper */ |
| 25 | 32 | ||
| 26 | /* Times are given in ms. The 'priority' parameter | 33 | /* Times are given in ms. The 'priority' parameter |
| @@ -30,9 +37,9 @@ int get_rt_task_param(pid_t pid, struct rt_task* param); | |||
| 30 | */ | 37 | */ |
| 31 | int sporadic_task( | 38 | int sporadic_task( |
| 32 | lt_t e, lt_t p, lt_t phase, | 39 | lt_t e, lt_t p, lt_t phase, |
| 33 | int partition, unsigned int priority, | 40 | int cluster, int cluster_size, unsigned int priority, |
| 34 | task_class_t cls, | 41 | task_class_t cls, |
| 35 | budget_policy_t budget_policy, int set_cpu_set); | 42 | budget_policy_t budget_policy, int be_migrate); |
| 36 | 43 | ||
| 37 | /* Times are given in ns. The 'priority' parameter | 44 | /* Times are given in ns. The 'priority' parameter |
| 38 | * is only relevant under fixed-priority scheduling (and | 45 | * is only relevant under fixed-priority scheduling (and |
| @@ -41,16 +48,19 @@ int sporadic_task( | |||
| 41 | */ | 48 | */ |
| 42 | int sporadic_task_ns( | 49 | int sporadic_task_ns( |
| 43 | lt_t e, lt_t p, lt_t phase, | 50 | lt_t e, lt_t p, lt_t phase, |
| 44 | int cpu, unsigned int priority, | 51 | int cluster, int cluster_size, unsigned int priority, |
| 45 | task_class_t cls, | 52 | task_class_t cls, |
| 46 | budget_policy_t budget_policy, int set_cpu_set); | 53 | budget_policy_t budget_policy, int be_migrate); |
| 47 | 54 | ||
| 48 | /* Convenience macros. Budget enforcement off by default in these macros. */ | 55 | /* Convenience macros. Budget enforcement off by default in these macros. */ |
| 49 | #define sporadic_global(e, p) \ | 56 | #define sporadic_global(e, p) \ |
| 50 | |||
