diff options
author | Jonathan Herman <hermanjl@cs.unc.edu> | 2011-08-29 17:44:05 -0400 |
---|---|---|
committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2011-08-29 17:44:05 -0400 |
commit | 6dd87915584e687f014a546a83ec56a0396e2eb5 (patch) | |
tree | ba93f8449098254445b4c39ee0366a5baa0dd37a /litmus/rt_domain.c | |
parent | 0db09db5c908a470a8746fab0b0e6b8fa8e131f2 (diff) |
created generic domain interface for tasks
Diffstat (limited to 'litmus/rt_domain.c')
-rw-r--r-- | litmus/rt_domain.c | 65 |
1 files changed, 62 insertions, 3 deletions
diff --git a/litmus/rt_domain.c b/litmus/rt_domain.c index fd0e6c235e1..f781a2c61fc 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 | */ | ||
365 | static 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 | */ | ||
383 | static 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 | */ | ||
392 | static 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 | */ | ||
399 | void 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 | |||
412 | void pd_domain_free(domain_t *dom) | ||
413 | { | ||
414 | kfree(dom->data); | ||
415 | } | ||