32 |
|
|
33 |
/* If RUN_MAP is zero - there is no available threads in this policy. */ |
/* If RUN_MAP is zero - there is no available threads in this policy. */ |
34 |
|
|
35 |
|
spin_lock (&sp->interlock); |
36 |
if (! sp->run_map) |
if (! sp->run_map) |
37 |
return 0; |
{ |
38 |
|
spin_unlock (&sp->interlock); |
39 |
|
return 0; |
40 |
|
} |
41 |
|
|
42 |
/* Remove thread with highest priority from thread, and update the queue |
/* Remove thread with highest priority from thread, and update the queue |
43 |
map if the queue became empty. */ |
map if the queue became empty. */ |
55 |
empty_p = queue_empty (&sp->run_queues [whichq]); |
empty_p = queue_empty (&sp->run_queues [whichq]); |
56 |
--sp->run_count; |
--sp->run_count; |
57 |
sp->run_map &= ~((!! empty_p) << whichq); /* ??? optimize? */ |
sp->run_map &= ~((!! empty_p) << whichq); /* ??? optimize? */ |
58 |
|
spin_unlock (&sp->interlock); |
59 |
|
|
60 |
thread->runq_list = 0; |
thread->runq_list = 0; |
61 |
return thread; |
return thread; |
72 |
|
|
73 |
/* Insert thread into scheduling policy's run queue and update RUN_MAP. */ |
/* Insert thread into scheduling policy's run queue and update RUN_MAP. */ |
74 |
|
|
75 |
|
spin_lock (&sp->interlock); |
76 |
whichq = (15 - thread->sched_priority); |
whichq = (15 - thread->sched_priority); |
77 |
queue_enter (&sp->run_queues [whichq], thread, struct thread *, runq); |
queue_enter (&sp->run_queues [whichq], thread, struct thread *, runq); |
78 |
thread->runq_list = &sp->run_queues [whichq]; |
thread->runq_list = &sp->run_queues [whichq]; |
85 |
if (may_preempt_p) |
if (may_preempt_p) |
86 |
{ |
{ |
87 |
if (THREAD_CURRENT()->sched_premul < thread->sched_premul) |
if (THREAD_CURRENT()->sched_premul < thread->sched_premul) |
88 |
return may_preempt_p; |
{ |
89 |
|
spin_unlock (&sp->interlock); |
90 |
|
return may_preempt_p; |
91 |
|
} |
92 |
} |
} |
93 |
|
|
94 |
|
spin_unlock (&sp->interlock); |
95 |
return false; |
return false; |
96 |
} |
} |
97 |
|
|
105 |
|
|
106 |
/* Insert thread into scheduling policy's run queue and update RUN_MAP. */ |
/* Insert thread into scheduling policy's run queue and update RUN_MAP. */ |
107 |
|
|
108 |
|
spin_lock (&sp->interlock); |
109 |
whichq = thread->sched_priority; |
whichq = thread->sched_priority; |
110 |
queue_remove (&sp->run_queues [whichq], thread, struct thread *, runq); |
queue_remove (&sp->run_queues [whichq], thread, struct thread *, runq); |
111 |
empty_p = queue_empty (&sp->run_queues[whichq]); |
empty_p = queue_empty (&sp->run_queues[whichq]); |
113 |
|
|
114 |
--sp->run_count; |
--sp->run_count; |
115 |
sp->run_map &= ~((!! empty_p) << whichq); |
sp->run_map &= ~((!! empty_p) << whichq); |
116 |
|
spin_unlock (&sp->interlock); |
117 |
} |
} |
118 |
|
|
119 |
/* Scheduling decisions at periodic clock tick. Returns true if we should |
/* Scheduling decisions at periodic clock tick. Returns true if we should |
132 |
static bool |
static bool |
133 |
fifo_preempt_p (struct sched_policy *sp, struct thread *thread) |
fifo_preempt_p (struct sched_policy *sp, struct thread *thread) |
134 |
{ |
{ |
135 |
|
spin_lock (&sp->interlock); |
136 |
if (! sp->run_map) |
if (! sp->run_map) |
137 |
return false; |
{ |
138 |
|
spin_unlock (&sp->interlock); |
139 |
|
return false; |
140 |
|
} |
141 |
|
|
142 |
if (thread->sched_policy < sp->policy_index) |
if (thread->sched_policy < sp->policy_index) |
143 |
return true; |
{ |
144 |
|
spin_unlock (&sp->interlock); |
145 |
|
return true; |
146 |
|
} |
147 |
|
|
148 |
if ((ffs (sp->run_map) - 1) > (15 - thread->sched_priority)) |
if ((ffs (sp->run_map) - 1) > (15 - thread->sched_priority)) |
149 |
return true; |
{ |
150 |
|
spin_unlock (&sp->interlock); |
151 |
|
return true; |
152 |
|
} |
153 |
|
|
154 |
|
spin_unlock (&sp->interlock); |
155 |
return false; |
return false; |
156 |
} |
} |
157 |
|
|