Call sched_prio() to immediately change the priority of the thread in
response to an rtprio_thread() call, when the priority is different than the old priority, and either the old or the new priority class is not RTP_PRIO_NORMAL (timeshare). The reasoning for the second half of the test is that if it's a change in timeshare priority, then the scheduler is going to adjust that priority in a way that completely wipes out the requested change anyway, so what's the point? (If that's not true, then allowing a thread to change its own timeshare priority would subvert the scheduler's adjustments and let a cpu-bound thread monopolize the cpu; if allowed at all, that should require priveleges.) On the other hand, if either the old or new priority class is not timeshare, then the scheduler doesn't make automatic adjustments, so we should honor the request and make the priority change right away. The reason the old class gets caught up in this is the very reason for this change: when thread A changes the priority of its child thread B from idle back to timeshare, thread B never actually gets moved to a timeshare-range run queue unless there are some idle cycles available to allow it to first get scheduled again as an idle thread. Reviewed by: jhb@
This commit is contained in:
parent
e9a6213037
commit
9a2bff7ca6
@ -469,8 +469,7 @@ sys_rtprio(td, uap)
|
||||
int
|
||||
rtp_to_pri(struct rtprio *rtp, struct thread *td)
|
||||
{
|
||||
u_char newpri;
|
||||
u_char oldpri;
|
||||
u_char newpri, oldclass, oldpri;
|
||||
|
||||
switch (RTP_PRIO_BASE(rtp->type)) {
|
||||
case RTP_PRIO_REALTIME:
|
||||
@ -493,11 +492,12 @@ rtp_to_pri(struct rtprio *rtp, struct thread *td)
|
||||
}
|
||||
|
||||
thread_lock(td);
|
||||
oldclass = td->td_pri_class;
|
||||
sched_class(td, rtp->type); /* XXX fix */
|
||||
oldpri = td->td_user_pri;
|
||||
sched_user_prio(td, newpri);
|
||||
if (td->td_user_pri != oldpri && (td == curthread ||
|
||||
td->td_priority == oldpri || td->td_user_pri <= PRI_MAX_REALTIME))
|
||||
if (td->td_user_pri != oldpri && (oldclass != RTP_PRIO_NORMAL ||
|
||||
td->td_pri_class != RTP_PRIO_NORMAL))
|
||||
sched_prio(td, td->td_user_pri);
|
||||
if (TD_ON_UPILOCK(td) && oldpri != newpri) {
|
||||
critical_enter();
|
||||
|
Loading…
Reference in New Issue
Block a user