aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2011-08-29 17:44:05 -0400
committerJonathan Herman <hermanjl@cs.unc.edu>2011-08-29 17:44:05 -0400
commit6dd87915584e687f014a546a83ec56a0396e2eb5 (patch)
treeba93f8449098254445b4c39ee0366a5baa0dd37a
parent0db09db5c908a470a8746fab0b0e6b8fa8e131f2 (diff)
created generic domain interface for tasks
-rw-r--r--include/litmus/rt_domain.h10
-rw-r--r--include/litmus/sched_mc.h1
-rw-r--r--litmus/Makefile3
-rw-r--r--litmus/rt_domain.c65
-rw-r--r--litmus/sched_mc.c12
5 files changed, 82 insertions, 9 deletions
diff --git a/include/litmus/rt_domain.h b/include/litmus/rt_domain.h
index ac249292e866..cba1979744ca 100644
--- a/include/litmus/rt_domain.h
+++ b/include/litmus/rt_domain.h
@@ -6,6 +6,7 @@
6#define __UNC_RT_DOMAIN_H__ 6#define __UNC_RT_DOMAIN_H__
7 7
8#include <litmus/bheap.h> 8#include <litmus/bheap.h>
9#include <litmus/domain.h>
9 10
10#define RELEASE_QUEUE_SLOTS 127 /* prime */ 11#define RELEASE_QUEUE_SLOTS 127 /* prime */
11 12
@@ -76,7 +77,14 @@ static inline struct task_struct* __next_ready(rt_domain_t* rt)
76 77
77void rt_domain_init(rt_domain_t *rt, bheap_prio_t order, 78void rt_domain_init(rt_domain_t *rt, bheap_prio_t order,
78 check_resched_needed_t check, 79 check_resched_needed_t check,
79 release_jobs_t relase); 80 release_jobs_t release);
81
82void pd_domain_init(domain_t *dom, bheap_prio_t order,
83 check_resched_needed_t check,
84 release_jobs_t release,
85 preempt_needed_t preempt_needed);
86
87void pd_domain_free(domain_t *dom);
80 88
81void __add_ready(rt_domain_t* rt, struct task_struct *new); 89void __add_ready(rt_domain_t* rt, struct task_struct *new);
82void __merge_ready(rt_domain_t* rt, struct bheap *tasks); 90void __merge_ready(rt_domain_t* rt, struct bheap *tasks);
diff --git a/include/litmus/sched_mc.h b/include/litmus/sched_mc.h
index 941a9f4470cc..66910773f430 100644
--- a/include/litmus/sched_mc.h
+++ b/include/litmus/sched_mc.h
@@ -13,7 +13,6 @@ enum crit_level {
13 NUM_CRIT_LEVELS = 4, 13 NUM_CRIT_LEVELS = 4,
14}; 14};
15 15
16
17struct mc_task { 16struct mc_task {
18 enum crit_level crit; 17 enum crit_level crit;
19}; 18};
diff --git a/litmus/Makefile b/litmus/Makefile
index 782022be6f28..7d7003592138 100644
--- a/litmus/Makefile
+++ b/litmus/Makefile
@@ -17,7 +17,8 @@ obj-y = sched_plugin.o litmus.o \
17 bheap.o \ 17 bheap.o \
18 ctrldev.o \ 18 ctrldev.o \
19 sched_gsn_edf.o \ 19 sched_gsn_edf.o \
20 sched_psn_edf.o 20 sched_psn_edf.o \
21 domain.o
21 22
22obj-$(CONFIG_PLUGIN_CEDF) += sched_cedf.o 23obj-$(CONFIG_PLUGIN_CEDF) += sched_cedf.o
23obj-$(CONFIG_PLUGIN_PFAIR) += sched_pfair.o 24obj-$(CONFIG_PLUGIN_PFAIR) += sched_pfair.o
diff --git a/litmus/rt_domain.c b/litmus/rt_domain.c
index fd0e6c235e1b..f781a2c61fc6 100644
--- a/litmus/rt_domain.c
+++ b/litmus/rt_domain.c
@@ -14,13 +14,11 @@
14#include <litmus/litmus.h> 14#include <litmus/litmus.h>
15#include <litmus/sched_plugin.h> 15#include <litmus/sched_plugin.h>
16#include <litmus/sched_trace.h> 16#include <litmus/sched_trace.h>
17
18#include <litmus/rt_domain.h> 17#include <litmus/rt_domain.h>
19
20#include <litmus/trace.h> 18#include <litmus/trace.h>
21
22#include <litmus/bheap.h> 19#include <litmus/bheap.h>
23 20
21
24/* Uncomment when debugging timer races... */ 22/* Uncomment when debugging timer races... */
25#if 0 23#if 0
26#define VTRACE_TASK TRACE_TASK 24#define VTRACE_TASK TRACE_TASK
@@ -354,3 +352,64 @@ void __add_release(rt_domain_t* rt, struct task_struct *task)
354 TS_SCHED2_END(task); 352 TS_SCHED2_END(task);
355} 353}
356 354
355/******************************************************************************
356 * domain_t wrapper
357 ******************************************************************************/
358
359/* pd_requeue - calls underlying rt_domain add methods.
360 * If the task is not yet released, it is inserted into the rt_domain
361 * ready queue. Otherwise, it is queued for release.
362 *
363 * Assumes the caller already holds dom->lock.
364 */
365static void pd_requeue(domain_t *dom, struct task_struct *task)
366{
367 rt_domain_t *domain = (rt_domain_t*)dom->data;
368 BUG_ON(!task || !is_realtime(task));
369 BUG_ON(is_queued(task));
370
371 if (is_released(task, litmus_clock())) {
372 __add_ready(domain, task);
373 } else {
374 /* task has to wait for next release */
375 add_release(domain, task);
376 }
377}
378
379/* pd_take_ready - removes and returns the next ready task from the rt_domain
380 *
381 * Assumes the caller already holds dom->lock.
382 */
383static struct task_struct* pd_take_ready(domain_t *dom)
384{
385 return __take_ready((rt_domain_t*)dom->data);
386}
387
388/* pd_peek_ready - returns the head of the rt_domain ready queue
389 *
390 * Assumes the caller already holds dom->lock.
391 */
392static struct task_struct* pd_peek_ready(domain_t *dom)
393{
394 return __next_ready((rt_domain_t*)dom->data);
395}
396
397/* pd_domain_init - create a generic domain wrapper for an rt_domain
398 */
399void pd_domain_init(domain_t *dom, bheap_prio_t order,
400 check_resched_needed_t check,
401 release_jobs_t release,
402 preempt_needed_t preempt_needed)
403{
404 rt_domain_t *domain = kmalloc(sizeof(rt_domain_t), GFP_ATOMIC);
405
406 rt_domain_init(domain, order, check, release);
407 domain_init(dom, &domain->ready_lock,
408 pd_requeue, pd_peek_ready, pd_take_ready,
409 preempt_needed);
410}
411
412void pd_domain_free(domain_t *dom)
413{
414 kfree(dom->data);
415}
diff --git a/litmus/sched_mc.c b/litmus/sched_mc.c
index eb5728c97c87..dcf86d60275a 100644
--- a/litmus/sched_mc.c
+++ b/litmus/sched_mc.c
@@ -1,4 +1,4 @@
1/* 1/**
2 * litmus/sched_mc.c 2 * litmus/sched_mc.c
3 * 3 *
4 * Implementation of the Mixed Criticality scheduling algorithm. 4 * Implementation of the Mixed Criticality scheduling algorithm.
@@ -8,6 +8,12 @@
8 * This version uses the simple approach and serializes all scheduling 8 * This version uses the simple approach and serializes all scheduling
9 * decisions by the use of a queue lock. This is probably not the 9 * decisions by the use of a queue lock. This is probably not the
10 * best way to do it, but it should suffice for now. 10 * best way to do it, but it should suffice for now.
11 *
12 * --Todo--
13 * Timer Accounting: adjusting the clock values of the ghost timer using
14 * the _tick() method is relatively expensive. This should be changed.
15 * Locks: Accesses to domains should be serialized using a per-domain lock.
16 * CPU locks should be properly used e.g. wip-semi-part
11 */ 17 */
12 18
13#include <linux/spinlock.h> 19#include <linux/spinlock.h>
@@ -586,9 +592,9 @@ static noinline void requeue(struct task_struct* task)
586 /* sanity check before insertion */ 592 /* sanity check before insertion */
587 BUG_ON(is_queued(task)); 593 BUG_ON(is_queued(task));
588 594
589 if (is_released(task, litmus_clock())) 595 if (is_released(task, litmus_clock())) {
590 __add_ready(tsk_rt(task)->domain, task); 596 __add_ready(tsk_rt(task)->domain, task);
591 else { 597 } else {
592 /* it has got to wait */ 598 /* it has got to wait */
593 add_release(tsk_rt(task)->domain, task); 599 add_release(tsk_rt(task)->domain, task);
594 } 600 }