Changeset View
Changeset View
Standalone View
Standalone View
head/sys/kern/sched_4bsd.c
Show First 20 Lines • Show All 700 Lines • ▼ Show 20 Lines | |||||
* cpu usage estimator ramps up quite quickly when the process is | * cpu usage estimator ramps up quite quickly when the process is | ||||
* running (linearly), and decays away exponentially, at a rate which | * running (linearly), and decays away exponentially, at a rate which | ||||
* is proportionally slower when the system is busy. The basic | * is proportionally slower when the system is busy. The basic | ||||
* principle is that the system will 90% forget that the process used | * principle is that the system will 90% forget that the process used | ||||
* a lot of CPU time in 5 * loadav seconds. This causes the system to | * a lot of CPU time in 5 * loadav seconds. This causes the system to | ||||
* favor processes which haven't run much recently, and to round-robin | * favor processes which haven't run much recently, and to round-robin | ||||
* among other processes. | * among other processes. | ||||
*/ | */ | ||||
void | static void | ||||
sched_clock(struct thread *td) | sched_clock_tick(struct thread *td) | ||||
{ | { | ||||
struct pcpuidlestat *stat; | struct pcpuidlestat *stat; | ||||
struct td_sched *ts; | struct td_sched *ts; | ||||
THREAD_LOCK_ASSERT(td, MA_OWNED); | THREAD_LOCK_ASSERT(td, MA_OWNED); | ||||
ts = td_get_sched(td); | ts = td_get_sched(td); | ||||
ts->ts_cpticks++; | ts->ts_cpticks++; | ||||
Show All 10 Lines | sched_clock_tick(struct thread *td) | ||||
if (!TD_IS_IDLETHREAD(td) && --ts->ts_slice <= 0) { | if (!TD_IS_IDLETHREAD(td) && --ts->ts_slice <= 0) { | ||||
ts->ts_slice = sched_slice; | ts->ts_slice = sched_slice; | ||||
td->td_flags |= TDF_NEEDRESCHED | TDF_SLICEEND; | td->td_flags |= TDF_NEEDRESCHED | TDF_SLICEEND; | ||||
} | } | ||||
stat = DPCPU_PTR(idlestat); | stat = DPCPU_PTR(idlestat); | ||||
stat->oldidlecalls = stat->idlecalls; | stat->oldidlecalls = stat->idlecalls; | ||||
stat->idlecalls = 0; | stat->idlecalls = 0; | ||||
} | |||||
void | |||||
sched_clock(struct thread *td, int cnt) | |||||
{ | |||||
for ( ; cnt > 0; cnt--) | |||||
sched_clock_tick(td); | |||||
} | } | ||||
/* | /* | ||||
* Charge child's scheduling CPU usage to parent. | * Charge child's scheduling CPU usage to parent. | ||||
*/ | */ | ||||
void | void | ||||
sched_exit(struct proc *p, struct thread *td) | sched_exit(struct proc *p, struct thread *td) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 1,045 Lines • Show Last 20 Lines |