aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/syscalls.c1
-rw-r--r--src/task.c9
2 files changed, 6 insertions, 4 deletions
diff --git a/src/syscalls.c b/src/syscalls.c
index bc14443..b2ab900 100644
--- a/src/syscalls.c
+++ b/src/syscalls.c
@@ -1,7 +1,6 @@
1/* To get syscall() we need to define _GNU_SOURCE 1/* To get syscall() we need to define _GNU_SOURCE
2 * in modern glibc versions. 2 * in modern glibc versions.
3 */ 3 */
4#define _GNU_SOURCE
5#include <unistd.h> 4#include <unistd.h>
6#include <linux/unistd.h> 5#include <linux/unistd.h>
7#include <sys/types.h> 6#include <sys/types.h>
diff --git a/src/task.c b/src/task.c
index df12777..f9e4ccf 100644
--- a/src/task.c
+++ b/src/task.c
@@ -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
62int task_mode(int mode) 64int 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, &param);
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, &param);
75 } else { 78 } else {
76 errno = -EINVAL; 79 errno = -EINVAL;
77 return -1; 80 return -1;