From 2d8f8176515f2516b9a0b85642a7b842eb53552b Mon Sep 17 00:00:00 2001 From: Jonathan Herman Date: Sun, 13 May 2012 16:15:33 -0400 Subject: Can disable nonpreemptivity --- include/litmus/litmus.h | 18 ++++++++++++++++-- litmus/Kconfig | 2 -- litmus/dgl.c | 4 ++++ litmus/sched_color.c | 22 +++++++++++++++++----- 4 files changed, 37 insertions(+), 9 deletions(-) diff --git a/include/litmus/litmus.h b/include/litmus/litmus.h index f0ddb89e68dd..9fcf1f45820f 100644 --- a/include/litmus/litmus.h +++ b/include/litmus/litmus.h @@ -169,7 +169,7 @@ static inline void request_exit_np(struct task_struct *t) static inline void make_np(struct task_struct *t) { - tsk_rt(t)->kernel_np++; + tsk_rt(t)->kernel_np = 1; } /* Caller should check if preemption is necessary when @@ -177,7 +177,7 @@ static inline void make_np(struct task_struct *t) */ static inline int take_np(struct task_struct *t) { - return --tsk_rt(t)->kernel_np; + return tsk_rt(t)->kernel_np = 0; } /* returns 0 if remote CPU needs an IPI to preempt, 1 if no IPI is required */ @@ -210,6 +210,20 @@ static inline int request_exit_np_atomic(struct task_struct *t) #else + +static inline void make_np(struct task_struct *t) +{ + +} + +/* Caller should check if preemption is necessary when + * the function return 0. + */ +static inline int take_np(struct task_struct *t) +{ + return 0; +} + static inline int is_kernel_np(struct task_struct* t) { return 0; diff --git a/litmus/Kconfig b/litmus/Kconfig index 272b64c30ba3..f0c48a6a3efb 100644 --- a/litmus/Kconfig +++ b/litmus/Kconfig @@ -14,7 +14,6 @@ config PLUGIN_CEDF config PLUGIN_COLOR bool "Scheduling with Colors" - depends on NP_SECTION default y help Include the scheduling with colors scheduler. @@ -65,7 +64,6 @@ config NP_SECTION config LITMUS_LOCKING bool "Support for real-time locking protocols" - depends on NP_SECTION default n help Enable LITMUS^RT's deterministic multiprocessor real-time diff --git a/litmus/dgl.c b/litmus/dgl.c index 2df27b48fcdf..0c1ce73868e3 100644 --- a/litmus/dgl.c +++ b/litmus/dgl.c @@ -126,6 +126,10 @@ void set_req(struct dgl *dgl, struct dgl_group_req *greq, BUG_ON(replicas > dgl->num_replicas); +#ifndef CONFIG_NP_SECTION + BUG_ON(1); +#endif + mask_idx(resource, &word, &bit); __set_bit(bit, &greq->requested[word]); diff --git a/litmus/sched_color.c b/litmus/sched_color.c index 29b2be97da52..8554fde49c0b 100644 --- a/litmus/sched_color.c +++ b/litmus/sched_color.c @@ -57,11 +57,19 @@ static raw_spinlock_t dgl_lock; #define task_fserver(task) (&task_entry(task)->fifo_server.server) #define entry_lock(entry) (&entry->rm_domain.ready_lock) -#define has_resources(t, c) (tsk_rt(t)->req == group_lock.acquired[c]) + #define task_dom(entry, task) (is_be(task) ? &fifo_domain : &entry->rm_domain) #define task_lock(entry, task) (is_be(task) ? &fifo_lock : entry_lock(entry)) #define is_fifo_server(s) (s->sid > num_online_cpus()) +#ifdef CONFIG_NP_SECTION +#define has_resources(t, c) (tsk_rt(t)->req == group_lock.acquired[c]) +#else +#define has_resources(t, c) (1) +#endif + + + /* * Requeue onto domain's release or ready queue based on task state. */ @@ -90,6 +98,7 @@ static void requeue(rt_domain_t *dom, struct task_struct* t) static void release_resources(struct task_struct *t) { struct task_struct *sched; +#ifdef CONFIG_NP_SECTION TRACE_TASK(t, "Releasing resources\n"); @@ -99,7 +108,8 @@ static void release_resources(struct task_struct *t) release_resources(sched); } else if (is_kernel_np(t)) remove_group_req(&group_lock, tsk_rt(t)->req); - tsk_rt(t)->kernel_np = 0; + take_np(t); +#endif } /* @@ -112,6 +122,7 @@ static void acquire_resources(struct task_struct *t) struct rt_server *server; struct task_struct *sched; +#ifdef CONFIG_NP_SECTION /* Can't acquire resources if t is not running */ BUG_ON(!get_task_server(t)); @@ -134,17 +145,18 @@ static void acquire_resources(struct task_struct *t) /* Become np if there is a running task */ if (sched && has_resources(sched, cpu)) { TRACE_TASK(t, "Running task with resource\n"); - tsk_rt(t)->kernel_np = 1; + make_np(t); } else { TRACE_TASK(t, "Running no resources\n"); - tsk_rt(t)->kernel_np = 0; + take_np(t); } } else { TRACE_TASK(t, "Acquiring resources\n"); if (!has_resources(t, cpu)) add_group_req(&group_lock, tsk_rt(t)->req, cpu); - tsk_rt(t)->kernel_np = 1; + make_np(t); } +#endif } /* -- cgit v1.2.2