aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjoern B. Brandenburg <bbb@cs.unc.edu>2008-05-02 11:16:42 -0400
committerBjoern B. Brandenburg <bbb@cs.unc.edu>2008-05-02 11:16:42 -0400
commit2ecaa462efc710ae8f55af9dd5371b4d67bfd620 (patch)
treedc25beae0ffc4a0e41084d3ade3e80a5d434e128
parent1cea952a55ff91028b4e7f89be26efd3a2cbe04b (diff)
Use _GNU_SOURCE for all files. Fix wrong prototypes.
-rw-r--r--Makefile2
-rw-r--r--include/internal.h3
-rw-r--r--src/syscalls.c1
-rw-r--r--src/task.c9
4 files changed, 7 insertions, 8 deletions
diff --git a/Makefile b/Makefile
index 46fd9b3..b84b865 100644
--- a/Makefile
+++ b/Makefile
@@ -11,7 +11,7 @@ else
11endif 11endif
12 12
13 13
14CFLAGS=-Wall -Wdeclaration-after-statement ${INC} ${CPU} -g -D_XOPEN_SOURCE=600 14CFLAGS=-Wall -Wdeclaration-after-statement ${INC} ${CPU} -g -D_XOPEN_SOURCE=600 -D_GNU_SOURCE
15CPPFLAGS=-Wall -g 15CPPFLAGS=-Wall -g
16 16
17LIBS= ./liblitmus.a 17LIBS= ./liblitmus.a
diff --git a/include/internal.h b/include/internal.h
index 761c434..fc88ef5 100644
--- a/include/internal.h
+++ b/include/internal.h
@@ -20,6 +20,3 @@ int __launch_rt_task(rt_fn_t rt_prog, void *rt_arg,
20 20
21#endif 21#endif
22 22
23
24int sched_setscheduler(pid_t pid, int policy, int* prioriy);
25int sched_getscheduler(pid_t pid);
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;