diff options
Diffstat (limited to 'src/task.c')
| -rw-r--r-- | src/task.c | 9 |
1 files changed, 6 insertions, 3 deletions
| @@ -3,6 +3,8 @@ | |||
| 3 | #include <unistd.h> | 3 | #include <unistd.h> |
| 4 | #include <errno.h> | 4 | #include <errno.h> |
| 5 | 5 | ||
| 6 | #include <sched.h> | ||
| 7 | |||
| 6 | #include "litmus.h" | 8 | #include "litmus.h" |
| 7 | #include "internal.h" | 9 | #include "internal.h" |
| 8 | 10 | ||
| @@ -61,17 +63,18 @@ int create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, int wcet, int period) { | |||
| 61 | 63 | ||
| 62 | int task_mode(int mode) | 64 | int task_mode(int mode) |
| 63 | { | 65 | { |
| 64 | int prio = 0; | 66 | struct sched_param param; |
| 65 | int me = gettid(); | 67 | int me = gettid(); |
| 66 | int policy = sched_getscheduler(gettid()); | 68 | int policy = sched_getscheduler(gettid()); |
| 67 | int old_mode = policy == SCHED_LITMUS ? LITMUS_RT_TASK : BACKGROUND_TASK; | 69 | int old_mode = policy == SCHED_LITMUS ? LITMUS_RT_TASK : BACKGROUND_TASK; |
| 68 | 70 | ||
| 71 | param.sched_priority = 0; | ||
| 69 | if (old_mode == LITMUS_RT_TASK && mode == BACKGROUND_TASK) { | 72 | if (old_mode == LITMUS_RT_TASK && mode == BACKGROUND_TASK) { |
| 70 | /* transition to normal task */ | 73 | /* transition to normal task */ |
| 71 | return sched_setscheduler(me, SCHED_NORMAL, &prio); | 74 | return sched_setscheduler(me, SCHED_NORMAL, ¶m); |
| 72 | } else if (old_mode == BACKGROUND_TASK && mode == LITMUS_RT_TASK) { | 75 | } else if (old_mode == BACKGROUND_TASK && mode == LITMUS_RT_TASK) { |
| 73 | /* transition to RT task */ | 76 | /* transition to RT task */ |
| 74 | return sched_setscheduler(me, SCHED_LITMUS, &prio); | 77 | return sched_setscheduler(me, SCHED_LITMUS, ¶m); |
| 75 | } else { | 78 | } else { |
| 76 | errno = -EINVAL; | 79 | errno = -EINVAL; |
| 77 | return -1; | 80 | return -1; |
