diff options
author | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2011-07-21 13:50:26 -0400 |
---|---|---|
committer | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2011-07-21 13:50:26 -0400 |
commit | eab1497d8b46a2367a78d47a3bc35b9a1b68e2c2 (patch) | |
tree | 6acf09cc27ab57572be12175f6dc0834798d9f4a | |
parent | 3ad3402d3e82eef8d08ab6e1196d14cfa7834813 (diff) |
Adapt FMLP+ priority boosting order in P-FP plugin.
Generic priority-points also clear the way for xPCP variants.
-rw-r--r-- | litmus/sched_pfp.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/litmus/sched_pfp.c b/litmus/sched_pfp.c index c98429938033..45c838f1413e 100644 --- a/litmus/sched_pfp.c +++ b/litmus/sched_pfp.c | |||
@@ -325,19 +325,19 @@ static void pfp_task_exit(struct task_struct * t) | |||
325 | #include <litmus/fdso.h> | 325 | #include <litmus/fdso.h> |
326 | #include <litmus/srp.h> | 326 | #include <litmus/srp.h> |
327 | 327 | ||
328 | static void boost_priority(struct task_struct* t) | 328 | static void boost_priority(struct task_struct* t, lt_t priority_point) |
329 | { | 329 | { |
330 | unsigned long flags; | 330 | unsigned long flags; |
331 | pfp_domain_t* pfp = task_pfp(t); | 331 | pfp_domain_t* pfp = task_pfp(t); |
332 | lt_t now; | ||
333 | 332 | ||
334 | raw_spin_lock_irqsave(&pfp->slock, flags); | 333 | raw_spin_lock_irqsave(&pfp->slock, flags); |
335 | now = litmus_clock(); | 334 | |
336 | 335 | ||
337 | TRACE_TASK(t, "priority boosted at %llu\n", now); | 336 | TRACE_TASK(t, "priority boosted at %llu\n", now); |
338 | 337 | ||
339 | tsk_rt(t)->priority_boosted = 1; | 338 | tsk_rt(t)->priority_boosted = 1; |
340 | tsk_rt(t)->boost_start_time = now; | 339 | /* tie-break by protocol-specific priority point */ |
340 | tsk_rt(t)->boost_start_time = priority_point; | ||
341 | 341 | ||
342 | if (pfp->scheduled != t) { | 342 | if (pfp->scheduled != t) { |
343 | /* holder may be queued: first stop queue changes */ | 343 | /* holder may be queued: first stop queue changes */ |
@@ -411,12 +411,20 @@ int pfp_fmlp_lock(struct litmus_lock* l) | |||
411 | struct fmlp_semaphore *sem = fmlp_from_lock(l); | 411 | struct fmlp_semaphore *sem = fmlp_from_lock(l); |
412 | wait_queue_t wait; | 412 | wait_queue_t wait; |
413 | unsigned long flags; | 413 | unsigned long flags; |
414 | lt_t time_of_request; | ||
414 | 415 | ||
415 | if (!is_realtime(t)) | 416 | if (!is_realtime(t)) |
416 | return -EPERM; | 417 | return -EPERM; |
417 | 418 | ||
418 | spin_lock_irqsave(&sem->wait.lock, flags); | 419 | spin_lock_irqsave(&sem->wait.lock, flags); |
419 | 420 | ||
421 | /* tie-break by this point in time */ | ||
422 | time_of_request = litmus_clock(); | ||
423 | |||
424 | /* Priority-boost ourself *before* we suspend so that | ||
425 | * our priority is boosted when we resume. */ | ||
426 | boost_priority(t, time_of_request); | ||
427 | |||
420 | if (sem->owner) { | 428 | if (sem->owner) { |
421 | /* resource is not free => must suspend and wait */ | 429 | /* resource is not free => must suspend and wait */ |
422 | 430 | ||
@@ -449,9 +457,6 @@ int pfp_fmlp_lock(struct litmus_lock* l) | |||
449 | /* it's ours now */ | 457 | /* it's ours now */ |
450 | sem->owner = t; | 458 | sem->owner = t; |
451 | 459 | ||
452 | /* mark the task as priority-boosted. */ | ||
453 | boost_priority(t); | ||
454 | |||
455 | spin_unlock_irqrestore(&sem->wait.lock, flags); | 460 | spin_unlock_irqrestore(&sem->wait.lock, flags); |
456 | } | 461 | } |
457 | 462 | ||
@@ -479,13 +484,10 @@ int pfp_fmlp_unlock(struct litmus_lock* l) | |||
479 | /* check if there are jobs waiting for this resource */ | 484 | /* check if there are jobs waiting for this resource */ |
480 | next = __waitqueue_remove_first(&sem->wait); | 485 | next = __waitqueue_remove_first(&sem->wait); |
481 | if (next) { | 486 | if (next) { |
482 | /* boost next job */ | ||
483 | boost_priority(next); | ||
484 | |||
485 | /* next becomes the resouce holder */ | 487 | /* next becomes the resouce holder */ |
486 | sem->owner = next; | 488 | sem->owner = next; |
487 | 489 | ||
488 | /* wake up next */ | 490 | /* Wake up next. The waiting job is already priority-boosted. */ |
489 | wake_up_process(next); | 491 | wake_up_process(next); |
490 | } else | 492 | } else |
491 | /* resource becomes available */ | 493 | /* resource becomes available */ |