diff options
| author | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2008-05-02 11:18:56 -0400 |
|---|---|---|
| committer | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2008-05-02 11:18:56 -0400 |
| commit | 9b85a6e707adff71ea3b329756f2b854fbdc6b0b (patch) | |
| tree | 4fadb5d34c42d10616079cd6adf39c334cecebba /src | |
| parent | 2ecaa462efc710ae8f55af9dd5371b4d67bfd620 (diff) | |
Add best effort task migration, so that we can support PSN-EDF.
Diffstat (limited to 'src')
| -rw-r--r-- | src/litmus.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/litmus.c b/src/litmus.c index 4fe6572..8f03f4c 100644 --- a/src/litmus.c +++ b/src/litmus.c | |||
| @@ -5,6 +5,8 @@ | |||
| 5 | #include <signal.h> | 5 | #include <signal.h> |
| 6 | #include <sys/mman.h> | 6 | #include <sys/mman.h> |
| 7 | 7 | ||
| 8 | #include <sched.h> /* for cpu sets */ | ||
| 9 | |||
| 8 | #include "litmus.h" | 10 | #include "litmus.h" |
| 9 | #include "internal.h" | 11 | #include "internal.h" |
| 10 | 12 | ||
| @@ -29,15 +31,30 @@ task_class_t str2class(const char* str) | |||
| 29 | 31 | ||
| 30 | #define NS_PER_MS 1000000 | 32 | #define NS_PER_MS 1000000 |
| 31 | 33 | ||
| 34 | /* only for best-effort execution: migrate to target_cpu */ | ||
| 35 | int be_migrate_to(int target_cpu) | ||
| 36 | { | ||
| 37 | cpu_set_t cpu_set; | ||
| 38 | |||
| 39 | CPU_ZERO(&cpu_set); | ||
| 40 | CPU_SET(target_cpu, &cpu_set); | ||
| 41 | return sched_setaffinity(0, sizeof(cpu_set_t), &cpu_set); | ||
| 42 | } | ||
| 43 | |||
| 32 | int sporadic_task(lt_t e, lt_t p, lt_t phase, | 44 | int sporadic_task(lt_t e, lt_t p, lt_t phase, |
| 33 | int cpu, task_class_t cls) | 45 | int cpu, task_class_t cls, int set_cpu_set) |
| 34 | { | 46 | { |
| 35 | struct rt_task param; | 47 | struct rt_task param; |
| 48 | int ret; | ||
| 36 | param.exec_cost = e * NS_PER_MS; | 49 | param.exec_cost = e * NS_PER_MS; |
| 37 | param.period = p * NS_PER_MS; | 50 | param.period = p * NS_PER_MS; |
| 38 | param.cpu = cpu; | 51 | param.cpu = cpu; |
| 39 | param.cls = cls; | 52 | param.cls = cls; |
| 40 | param.phase = phase; | 53 | param.phase = phase; |
| 54 | if (set_cpu_set) { | ||
| 55 | ret = be_migrate_to(cpu); | ||
| 56 | check("migrate to cpu"); | ||
| 57 | } | ||
| 41 | return set_rt_task_param(gettid(), ¶m); | 58 | return set_rt_task_param(gettid(), ¶m); |
| 42 | } | 59 | } |
| 43 | 60 | ||
