diff options
author | John M. Calandrino <jmc@jupiter-cs.cs.unc.edu> | 2007-04-18 00:38:57 -0400 |
---|---|---|
committer | John M. Calandrino <jmc@jupiter-cs.cs.unc.edu> | 2007-04-18 00:38:57 -0400 |
commit | 4838ef57bb645fcf41c0a33b3c08ea97680e4307 (patch) | |
tree | 1f158c7e46ecf89e77a5b834d14c39b53507a955 /kernel | |
parent | 2079fe2e162a13929631e5ef00992e0c0d09f614 (diff) |
Added stubs for modifying "semaphore" priority, in order to facilitate
priority inheritance. Also fixed a few bugs. Many files were modified, as
the PI semaphores were are implementing replicate much of the original
Linux semaphore implementation with minor changes, often causing a cascade
of changes as functions were chased down and changed in several files.
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/sched.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/kernel/sched.c b/kernel/sched.c index aa4a9e9426..27dcab489b 100644 --- a/kernel/sched.c +++ b/kernel/sched.c | |||
@@ -60,6 +60,7 @@ | |||
60 | #define __SCHED_C__ | 60 | #define __SCHED_C__ |
61 | #include <linux/sched_plugin.h> | 61 | #include <linux/sched_plugin.h> |
62 | #include <linux/sched_trace.h> | 62 | #include <linux/sched_trace.h> |
63 | #include <linux/rt_param.h> | ||
63 | 64 | ||
64 | /* | 65 | /* |
65 | * Convert user-nice values [ -20 ... 0 ... 19 ] | 66 | * Convert user-nice values [ -20 ... 0 ... 19 ] |
@@ -3802,6 +3803,36 @@ static void __wake_up_common(wait_queue_head_t *q, unsigned int mode, | |||
3802 | } | 3803 | } |
3803 | } | 3804 | } |
3804 | 3805 | ||
3806 | /* | ||
3807 | * The core wakeup function, this time including priority inheritance. As a result, | ||
3808 | * this function takes the semaphore as a parameter instead of just its waitqueue. | ||
3809 | */ | ||
3810 | static void __pi_wake_up_common(struct pi_semaphore *s, unsigned int mode, | ||
3811 | int nr_exclusive, int sync, void *key) | ||
3812 | { | ||
3813 | struct list_head *tmp, *next; | ||
3814 | jiffie_t highest_prio = LOWEST_SEM_PRIO; | ||
3815 | |||
3816 | list_for_each_safe(tmp, next, &s->wait.task_list) { | ||
3817 | wait_queue_t *curr = list_entry(tmp, wait_queue_t, task_list); | ||
3818 | unsigned flags = curr->flags; | ||
3819 | |||
3820 | /* TODO: Find highest priority task remaining in queue. */ | ||
3821 | /* task_priority = tmp_task->rt_param.times.deadline; | ||
3822 | * if (time_before(task_priority, highest_prio)) { | ||
3823 | * highest_prio = task_priority; | ||
3824 | * } | ||
3825 | */ | ||
3826 | |||
3827 | if (curr->func(curr, mode, sync, key) && | ||
3828 | (flags & WQ_FLAG_EXCLUSIVE) && !--nr_exclusive) | ||
3829 | break; | ||
3830 | } | ||
3831 | |||
3832 | /* TODO: Set new priority to highest priority task remaining in queue. */ | ||
3833 | /* s->sem_prio = highest_prio; */ | ||
3834 | } | ||
3835 | |||
3805 | /** | 3836 | /** |
3806 | * __wake_up - wake up threads blocked on a waitqueue. | 3837 | * __wake_up - wake up threads blocked on a waitqueue. |
3807 | * @q: the waitqueue | 3838 | * @q: the waitqueue |
@@ -3820,6 +3851,27 @@ void fastcall __wake_up(wait_queue_head_t *q, unsigned int mode, | |||
3820 | } | 3851 | } |
3821 | EXPORT_SYMBOL(__wake_up); | 3852 | EXPORT_SYMBOL(__wake_up); |
3822 | 3853 | ||
3854 | /** | ||
3855 | * __pi_wake_up - wake up threads blocked on a waitqueue, | ||
3856 | * and handle priority inheritance as well. | ||
3857 | * @s: the semaphore (NOT just the waitqueue, since we need to modify | ||
3858 | * semaphore priority as well!) | ||
3859 | * @mode: which threads | ||
3860 | * @nr_exclusive: how many wake-one or wake-many threads to wake up | ||
3861 | * @key: is directly passed to the wakeup function | ||
3862 | * | ||
3863 | */ | ||
3864 | void fastcall __pi_wake_up(struct pi_semaphore *s, unsigned int mode, | ||
3865 | int nr_exclusive, void *key) | ||
3866 | { | ||
3867 | unsigned long flags; | ||
3868 | |||
3869 | spin_lock_irqsave(&s->wait.lock, flags); | ||
3870 | __pi_wake_up_common(s, mode, nr_exclusive, 0, key); | ||
3871 | spin_unlock_irqrestore(&s->wait.lock, flags); | ||
3872 | } | ||
3873 | EXPORT_SYMBOL(__pi_wake_up); | ||
3874 | |||
3823 | /* | 3875 | /* |
3824 | * Same as __wake_up but called with the spinlock in wait_queue_head_t held. | 3876 | * Same as __wake_up but called with the spinlock in wait_queue_head_t held. |
3825 | */ | 3877 | */ |