58 |
|
|
59 |
/* 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. */ |
60 |
|
|
61 |
|
spin_lock (&sp->interlock); |
62 |
if (! sp->run_map) |
if (! sp->run_map) |
63 |
return 0; |
{ |
64 |
|
spin_unlock (&sp->interlock); |
65 |
|
return 0; |
66 |
|
} |
67 |
|
|
68 |
retry_scan: |
retry_scan: |
69 |
target = 0; |
target = 0; |
98 |
ASSERT (whichq >= 0 && whichq <= 15); |
ASSERT (whichq >= 0 && whichq <= 15); |
99 |
queue_remove (&sp->run_queues [whichq], target, struct thread *, runq); |
queue_remove (&sp->run_queues [whichq], target, struct thread *, runq); |
100 |
empty_p = queue_empty (&sp->run_queues [whichq]); |
empty_p = queue_empty (&sp->run_queues [whichq]); |
101 |
|
target->runq_list = 0; |
102 |
|
|
103 |
--sp->run_count; |
--sp->run_count; |
104 |
sp->run_map &= ~((!! empty_p) << whichq); |
sp->run_map &= ~((!! empty_p) << whichq); |
105 |
|
spin_unlock (&sp->interlock); |
106 |
|
|
107 |
return target; |
return target; |
108 |
} |
} |
116 |
{ |
{ |
117 |
int whichq; |
int whichq; |
118 |
|
|
119 |
|
ASSERT (thread->runq_list == 0); |
120 |
|
|
121 |
/* Insert thread into scheduling policy's run queue and update RUN_MAP. */ |
/* Insert thread into scheduling policy's run queue and update RUN_MAP. */ |
122 |
|
|
123 |
|
spin_lock (&sp->interlock); |
124 |
|
|
125 |
whichq = (15 - thread->sched_priority); |
whichq = (15 - thread->sched_priority); |
126 |
queue_enter (&sp->run_queues [whichq], thread, struct thread *, runq); |
queue_enter (&sp->run_queues [whichq], thread, struct thread *, runq); |
127 |
thread->sched_credits = thread->sched_priority; |
thread->sched_credits = thread->sched_priority; |
128 |
|
thread->runq_list = &sp->run_queues [whichq]; |
129 |
|
|
130 |
++sp->run_count; |
++sp->run_count; |
131 |
sp->run_map |= (1 << whichq); |
sp->run_map |= (1 << whichq); |
132 |
|
|
133 |
|
spin_unlock (&sp->interlock); |
134 |
|
|
135 |
/* Check if we should preempt the current running thread. */ |
/* Check if we should preempt the current running thread. */ |
136 |
|
|
152 |
|
|
153 |
/* Insert thread into scheduling policy's run queue and update RUN_MAP. */ |
/* Insert thread into scheduling policy's run queue and update RUN_MAP. */ |
154 |
|
|
155 |
|
spin_lock (&sp->interlock); |
156 |
whichq = thread->sched_priority; |
whichq = thread->sched_priority; |
157 |
queue_remove (&sp->run_queues [whichq], thread, struct thread *, runq); |
queue_remove (&sp->run_queues [whichq], thread, struct thread *, runq); |
158 |
|
|
159 |
--sp->run_count; |
--sp->run_count; |
160 |
sp->run_map &= ~((!! sp->run_count) << whichq); |
sp->run_map &= ~((!! sp->run_count) << whichq); |
161 |
|
spin_unlock (&sp->interlock); |
162 |
} |
} |
163 |
|
|
164 |
/* Scheduling decisions at periodic clock tick. Returns true if we should |
/* Scheduling decisions at periodic clock tick. Returns true if we should |