From fa7932bf8c8881f2c8484d54db3ebac7b6832500 Mon Sep 17 00:00:00 2001 From: Jeremy Erickson Date: Sat, 4 May 2013 12:38:33 -0400 Subject: Properly assign cpu --- bin/rt_launch_edfos.c | 25 +++++++++++-------------- bin/rtspin_edfos.c | 29 ++++++++++++++--------------- 2 files changed, 25 insertions(+), 29 deletions(-) (limited to 'bin') diff --git a/bin/rt_launch_edfos.c b/bin/rt_launch_edfos.c index 43ebee5..2b26fb2 100644 --- a/bin/rt_launch_edfos.c +++ b/bin/rt_launch_edfos.c @@ -50,9 +50,8 @@ int main(int argc, char** argv) lt_t wcet; lt_t period; /* [num,den] */ - lt_t fracs[NR_CPUS][2]; - int migrate = 0; - int cpu = 0; + lt_t fracs[NR_CPUS_EDF_OS][2]; + int cpu = -1; int opt; int verbose = 0; int wait = 0; @@ -60,7 +59,7 @@ int main(int argc, char** argv) startup_info_t info; task_class_t class = RT_CLASS_HARD; - for (i = 0; i < NR_CPUS; i++) { + for (i = 0; i < NR_CPUS_EDF_OS; i++) { fracs[i][0] = 0; fracs[i][1] = 0; } @@ -77,7 +76,6 @@ int main(int argc, char** argv) cpu = atoi(optarg); fracs[cpu][0] = 1; fracs[cpu][1] = 1; - migrate = 1; break; case 'c': class = str2class(optarg); @@ -106,9 +104,11 @@ int main(int argc, char** argv) fracs[cpu][0] = atoi(argv[i]); fracs[cpu][1] = atoi(argv[i+1]); } + if (cpu == -1) + cpu = compute_initial_cpu_edfos(fracs); if (wcet <= 0) - usage("The worst-case execution time must be a " - "positive number."); + usage("The worst-case execution time must be a " + "positive number."); if (period <= 0) usage("The period must be a positive number."); if (wcet > period) { @@ -118,17 +118,14 @@ int main(int argc, char** argv) info.exec_path = argv[optind + 8]; info.argv = argv + optind + 8; info.wait = wait; - if (migrate) { - ret = be_migrate_to(cpu); - if (ret < 0) - bail_out("could not migrate to target partition"); - } + ret = be_migrate_to(cpu); + if (ret < 0) + bail_out("could not migrate to target partition"); /* create in src/task.c a new wrapper for the __launch_rt_task * which takes the fraction and the cpus */ - ret = __create_rt_task_edfos(launch, &info, wcet, period, fracs, + ret = __create_rt_task_edfos(launch, &info, cpu, wcet, period, fracs, class); - if (ret < 0) bail_out("could not create rt child process"); else if (verbose) diff --git a/bin/rtspin_edfos.c b/bin/rtspin_edfos.c index e39a8c0..3ea41c7 100644 --- a/bin/rtspin_edfos.c +++ b/bin/rtspin_edfos.c @@ -141,10 +141,10 @@ int main(int argc, char** argv) lt_t wcet; lt_t period; /* [num,den] */ - lt_t fracs[NR_CPUS][2]; + lt_t fracs[NR_CPUS_EDF_OS][2]; double wcet_ms, period_ms; - int migrate = 0; - int cpu = 0; + int cpu = -1; + int ccpu; int opt; int wait = 0; int test_loop = 0; @@ -156,9 +156,9 @@ int main(int argc, char** argv) progname = argv[0]; - for (i = 0; i < NR_CPUS; i++) { + for (i = 0; i < NR_CPUS_EDF_OS; i++) { fracs[i][0] = 0; - fracs[i][1] = 1; + fracs[i][1] = 0; } while ((opt = getopt(argc, argv, OPTSTR)) != -1) { @@ -170,7 +170,6 @@ int main(int argc, char** argv) cpu = atoi(optarg); fracs[cpu][0] = 1; fracs[cpu][1] = 1; - migrate = 1; break; case 'c': class = str2class(optarg); @@ -215,10 +214,12 @@ int main(int argc, char** argv) duration = atof(argv[optind + 2]); /* frac num, den = 0 means fixed task */ for (i = optind + 3; i < argc; i += 3) { - cpu = atof(argv[i]); - fracs[cpu][0] = argv[i+1]; - fracs[cpu][1] = argv[i+2]; + ccpu = atof(argv[i]); + fracs[ccpu][0] = argv[i+1]; + fracs[ccpu][1] = argv[i+2]; } + if (cpu == -1) + cpu = compute_initial_cpu_edfos(fracs); wcet = wcet_ms * __NS_PER_MS; period = period_ms * __NS_PER_MS; if (wcet <= 0) @@ -231,13 +232,11 @@ int main(int argc, char** argv) "exceed the period."); } - if (migrate) { - ret = be_migrate_to(cpu); - if (ret < 0) - bail_out("could not migrate to target partition"); - } + ret = be_migrate_to(cpu); + if (ret < 0) + bail_out("could not migrate to target partition"); - ret = sporadic_task_ns_edfos(wcet, period, 0, fracs, class, + ret = sporadic_task_ns_edfos(wcet, period, 0, cpu, fracs, class, NO_ENFORCEMENT); if (ret < 0) -- cgit v1.2.2