From 2f26f4c66cff3d9a4d6414e5a44dd072c448ea17 Mon Sep 17 00:00:00 2001 From: David Xu Date: Tue, 11 Jul 2006 06:01:14 +0000 Subject: [PATCH] For SCHED_OTHER, we always inherit current thread's interactive priority unless current thread is realtime thread, in such case, we set a new zero priority for it, notice we don't have per-thread nice, the priority passed by userland is ignored here. --- sys/kern/kern_thr.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/sys/kern/kern_thr.c b/sys/kern/kern_thr.c index fab27be1a9c5..8110aa234bd8 100644 --- a/sys/kern/kern_thr.c +++ b/sys/kern/kern_thr.c @@ -217,23 +217,27 @@ create_thread(struct thread *td, mcontext_t *ctx, case SCHED_FIFO: rtp.type = PRI_FIFO; rtp.prio = sched->param.sched_priority; + rtp_to_pri(&rtp, newkg); + sched_prio(newtd, newkg->kg_user_pri); break; case SCHED_RR: rtp.type = PRI_REALTIME; rtp.prio = sched->param.sched_priority; + rtp_to_pri(&rtp, newkg); + sched_prio(newtd, newkg->kg_user_pri); break; case SCHED_OTHER: - rtp.type = PRI_TIMESHARE; - if (curthread->td_ksegrp->kg_pri_class == PRI_TIMESHARE) - rtp.prio = curthread->td_ksegrp->kg_user_pri; - else + if (curthread->td_ksegrp->kg_pri_class != + PRI_TIMESHARE) { + rtp.type = PRI_TIMESHARE; rtp.prio = 0; + rtp_to_pri(&rtp, newkg); + sched_prio(newtd, newkg->kg_user_pri); + } break; default: panic("sched policy"); } - rtp_to_pri(&rtp, newkg); - sched_prio(newtd, newkg->kg_user_pri); } TD_SET_CAN_RUN(newtd); /* if ((flags & THR_SUSPENDED) == 0) */