FreeBSD kernel kern code
sched_4bsd.c File Reference
#include <sys/cdefs.h>
#include "opt_hwpmc_hooks.h"
#include "opt_sched.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/cpuset.h>
#include <sys/kernel.h>
#include <sys/ktr.h>
#include <sys/lock.h>
#include <sys/kthread.h>
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/resourcevar.h>
#include <sys/sched.h>
#include <sys/sdt.h>
#include <sys/smp.h>
#include <sys/sysctl.h>
#include <sys/sx.h>
#include <sys/turnstile.h>
#include <sys/umtxvar.h>
#include <machine/pcb.h>
#include <machine/smp.h>
Include dependency graph for sched_4bsd.c:

Go to the source code of this file.

Data Structures

struct  td_sched
 
struct  pcpuidlestat
 

Macros

#define ESTCPULIM(e)
 
#define INVERSE_ESTCPU_WEIGHT   8 /* 1 / (priorities per estcpu level). */
 
#define NICE_WEIGHT   1 /* Priorities per nice level. */
 
#define TS_NAME_LEN   (MAXCOMLEN + sizeof(" td ") + sizeof(__XSTRING(UINT_MAX)))
 
#define TDF_DIDRUN   TDF_SCHED0 /* thread actually ran. */
 
#define TDF_BOUND   TDF_SCHED1 /* Bound to one CPU. */
 
#define TDF_SLICEEND   TDF_SCHED2 /* Thread time slice is over. */
 
#define TSF_AFFINITY   0x0001 /* Has a non-"full" CPU set. */
 
#define SKE_RUNQ_PCPU(ts)    ((ts)->ts_runq != 0 && (ts)->ts_runq != &runq)
 
#define THREAD_CAN_SCHED(td, cpu)    CPU_ISSET((cpu), &(td)->td_cpuset->cs_mask)
 
#define loadfactor(loadav)   (2 * (loadav))
 
#define decay_cpu(loadfac, cpu)   (((loadfac) * (cpu)) / ((loadfac) + FSCALE))
 
#define CCPU_SHIFT   11
 

Functions

 __FBSDID ("$FreeBSD$")
 
 _Static_assert (sizeof(struct thread)+sizeof(struct td_sched)<=sizeof(struct thread0_storage), "increase struct thread0_storage.t0st_sched size")
 
static void setup_runqs (void)
 
static void schedcpu (void)
 
static void schedcpu_thread (void)
 
static void sched_priority (struct thread *td, u_char prio)
 
static void sched_setup (void *dummy)
 
static void maybe_resched (struct thread *td)
 
static void updatepri (struct thread *td)
 
static void resetpriority (struct thread *td)
 
static void resetpriority_thread (struct thread *td)
 
 SYSINIT (schedcpu, SI_SUB_LAST, SI_ORDER_FIRST, kproc_start, &sched_kp)
 
 SYSINIT (sched_setup, SI_SUB_RUN_QUEUE, SI_ORDER_FIRST, sched_setup, NULL)
 
static void sched_initticks (void *dummy)
 
 SYSINIT (sched_initticks, SI_SUB_CLOCKS, SI_ORDER_THIRD, sched_initticks, NULL)
 
 DPCPU_DEFINE_STATIC (struct pcpuidlestat, idlestat)
 
static int sysctl_kern_quantum (SYSCTL_HANDLER_ARGS)
 
 SYSCTL_NODE (_kern, OID_AUTO, sched, CTLFLAG_RD|CTLFLAG_MPSAFE, 0, "Scheduler")
 
 SYSCTL_STRING (_kern_sched, OID_AUTO, name, CTLFLAG_RD, "4BSD", 0, "Scheduler name")
 
 SYSCTL_PROC (_kern_sched, OID_AUTO, quantum, CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_MPSAFE, NULL, 0, sysctl_kern_quantum, "I", "Quantum for timeshare threads in microseconds")
 
 SYSCTL_INT (_kern_sched, OID_AUTO, slice, CTLFLAG_RW, &sched_slice, 0, "Quantum for timeshare threads in stathz ticks")
 
 SDT_PROVIDER_DEFINE (sched)
 
 SDT_PROBE_DEFINE3 (sched,,, change__pri, "struct thread *", "struct proc *", "uint8_t")
 
 SDT_PROBE_DEFINE3 (sched,,, dequeue, "struct thread *", "struct proc *", "void *")
 
 SDT_PROBE_DEFINE4 (sched,,, enqueue, "struct thread *", "struct proc *", "void *", "int")
 
 SDT_PROBE_DEFINE4 (sched,,, lend__pri, "struct thread *", "struct proc *", "uint8_t", "struct thread *")
 
 SDT_PROBE_DEFINE2 (sched,,, load__change, "int", "int")
 
 SDT_PROBE_DEFINE2 (sched,,, off__cpu, "struct thread *", "struct proc *")
 
 SDT_PROBE_DEFINE (sched,,, on__cpu)
 
 SDT_PROBE_DEFINE (sched,,, remain__cpu)
 
 SDT_PROBE_DEFINE2 (sched,,, surrender, "struct thread *", "struct proc *")
 
static __inline void sched_load_add (void)
 
static __inline void sched_load_rem (void)
 
int maybe_preempt (struct thread *td)
 
 SYSCTL_UINT (_kern, OID_AUTO, ccpu, CTLFLAG_RD, &ccpu, 0, "Decay factor used for updating %CPU")
 
void schedinit (void)
 
void schedinit_ap (void)
 
int sched_runnable (void)
 
int sched_rr_interval (void)
 
static void sched_clock_tick (struct thread *td)
 
void sched_clock (struct thread *td, int cnt)
 
void sched_exit (struct proc *p, struct thread *td)
 
void sched_exit_thread (struct thread *td, struct thread *child)
 
void sched_fork (struct thread *td, struct thread *childtd)
 
void sched_fork_thread (struct thread *td, struct thread *childtd)
 
void sched_nice (struct proc *p, int nice)
 
void sched_class (struct thread *td, int class)
 
void sched_lend_prio (struct thread *td, u_char prio)
 
void sched_unlend_prio (struct thread *td, u_char prio)
 
void sched_prio (struct thread *td, u_char prio)
 
void sched_user_prio (struct thread *td, u_char prio)
 
void sched_lend_user_prio (struct thread *td, u_char prio)
 
void sched_lend_user_prio_cond (struct thread *td, u_char prio)
 
void sched_sleep (struct thread *td, int pri)
 
void sched_switch (struct thread *td, int flags)
 
void sched_wakeup (struct thread *td, int srqflags)
 
void sched_add (struct thread *td, int flags)
 
void sched_rem (struct thread *td)
 
struct thread * sched_choose (void)
 
void sched_preempt (struct thread *td)
 
void sched_userret_slowpath (struct thread *td)
 
void sched_bind (struct thread *td, int cpu)
 
void sched_unbind (struct thread *td)
 
int sched_is_bound (struct thread *td)
 
void sched_relinquish (struct thread *td)
 
int sched_load (void)
 
int sched_sizeof_proc (void)
 
int sched_sizeof_thread (void)
 
fixpt_t sched_pctcpu (struct thread *td)
 
u_int sched_estcpu (struct thread *td)
 
void sched_idletd (void *dummy)
 
static void sched_throw_tail (struct thread *td)
 
void sched_ap_entry (void)
 
void sched_throw (struct thread *td)
 
void sched_fork_exit (struct thread *td)
 
char * sched_tdname (struct thread *td)
 
void sched_affinity (struct thread *td)
 

Variables

static struct mtx sched_lock
 
static int realstathz = 127
 
static int sched_tdcnt
 
static int sched_slice = 12
 
static struct kproc_desc sched_kp
 
static struct runq runq
 
static fixpt_t ccpu = 0.95122942450071400909 * FSCALE
 

Macro Definition Documentation

◆ CCPU_SHIFT

#define CCPU_SHIFT   11

Definition at line 455 of file sched_4bsd.c.

◆ decay_cpu

#define decay_cpu (   loadfac,
  cpu 
)    (((loadfac) * (cpu)) / ((loadfac) + FSCALE))

Definition at line 436 of file sched_4bsd.c.

◆ ESTCPULIM

#define ESTCPULIM (   e)
Value:
min((e), INVERSE_ESTCPU_WEIGHT * (NICE_WEIGHT * (PRIO_MAX - PRIO_MIN) - \
RQ_PPQ) + INVERSE_ESTCPU_WEIGHT - 1)
#define NICE_WEIGHT
Definition: sched_4bsd.c:85
#define INVERSE_ESTCPU_WEIGHT
Definition: sched_4bsd.c:83

Definition at line 77 of file sched_4bsd.c.

◆ INVERSE_ESTCPU_WEIGHT

#define INVERSE_ESTCPU_WEIGHT   8 /* 1 / (priorities per estcpu level). */

Definition at line 83 of file sched_4bsd.c.

◆ loadfactor

#define loadfactor (   loadav)    (2 * (loadav))

Definition at line 435 of file sched_4bsd.c.

◆ NICE_WEIGHT

#define NICE_WEIGHT   1 /* Priorities per nice level. */

Definition at line 85 of file sched_4bsd.c.

◆ SKE_RUNQ_PCPU

#define SKE_RUNQ_PCPU (   ts)     ((ts)->ts_runq != 0 && (ts)->ts_runq != &runq)

Definition at line 116 of file sched_4bsd.c.

◆ TDF_BOUND

#define TDF_BOUND   TDF_SCHED1 /* Bound to one CPU. */

Definition at line 110 of file sched_4bsd.c.

◆ TDF_DIDRUN

#define TDF_DIDRUN   TDF_SCHED0 /* thread actually ran. */

Definition at line 109 of file sched_4bsd.c.

◆ TDF_SLICEEND

#define TDF_SLICEEND   TDF_SCHED2 /* Thread time slice is over. */

Definition at line 111 of file sched_4bsd.c.

◆ THREAD_CAN_SCHED

#define THREAD_CAN_SCHED (   td,
  cpu 
)     CPU_ISSET((cpu), &(td)->td_cpuset->cs_mask)

Definition at line 119 of file sched_4bsd.c.

◆ TS_NAME_LEN

#define TS_NAME_LEN   (MAXCOMLEN + sizeof(" td ") + sizeof(__XSTRING(UINT_MAX)))

Definition at line 87 of file sched_4bsd.c.

◆ TSF_AFFINITY

#define TSF_AFFINITY   0x0001 /* Has a non-"full" CPU set. */

Definition at line 114 of file sched_4bsd.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ _Static_assert()

_Static_assert ( sizeof(struct thread)+sizeof(struct td_sched)<=sizeof(struct thread0_storage)  ,
"increase struct thread0_storage.t0st_sched size"   
)

◆ DPCPU_DEFINE_STATIC()

DPCPU_DEFINE_STATIC ( struct pcpuidlestat  ,
idlestat   
)

◆ maybe_preempt()

int maybe_preempt ( struct thread *  td)

Definition at line 320 of file sched_4bsd.c.

Referenced by sched_add().

Here is the caller graph for this function:

◆ maybe_resched()

static void maybe_resched ( struct thread *  td)
static

Definition at line 305 of file sched_4bsd.c.

Referenced by resetpriority_thread(), and sched_add().

Here is the caller graph for this function:

◆ resetpriority()

static void resetpriority ( struct thread *  td)
static

Definition at line 604 of file sched_4bsd.c.

References INVERSE_ESTCPU_WEIGHT, NICE_WEIGHT, and sched_user_prio().

Referenced by sched_clock_tick(), sched_nice(), sched_wakeup(), and schedcpu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resetpriority_thread()

static void resetpriority_thread ( struct thread *  td)
static

Definition at line 623 of file sched_4bsd.c.

References maybe_resched(), and sched_prio().

Referenced by sched_clock_tick(), sched_nice(), and schedcpu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sched_add()

◆ sched_affinity()

void sched_affinity ( struct thread *  td)

Definition at line 1762 of file sched_4bsd.c.

References runq, sched_add(), sched_rem(), TDF_BOUND, THREAD_CAN_SCHED, ts, and TSF_AFFINITY.

Referenced by cpuset_update_thread().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sched_ap_entry()

void sched_ap_entry ( void  )

Definition at line 1678 of file sched_4bsd.c.

References cpu_ticks, sched_lock, sched_throw_tail(), and ticks.

Here is the call graph for this function:

◆ sched_bind()

void sched_bind ( struct thread *  td,
int  cpu 
)

Definition at line 1531 of file sched_4bsd.c.

References mi_switch(), TDF_BOUND, and ts.

Referenced by cf_set_method(), epoch_block_handler_preempt(), epoch_drain_callbacks(), epoch_wait_preempt(), kern_reboot(), quiesce_cpus(), and taskqgroup_binder().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sched_choose()

struct thread * sched_choose ( void  )

Definition at line 1463 of file sched_4bsd.c.

References runq, runq_choose(), runq_choose_fuzz(), runq_remove(), sched_lock, and TDF_DIDRUN.

Referenced by choosethread(), and choosethread_panic().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sched_class()

void sched_class ( struct thread *  td,
int  class 
)

Definition at line 829 of file sched_4bsd.c.

Referenced by idle_setup(), ithread_create(), rtp_to_pri(), and start_softclock().

Here is the caller graph for this function:

◆ sched_clock()

void sched_clock ( struct thread *  td,
int  cnt 
)

Definition at line 751 of file sched_4bsd.c.

References sched_clock_tick().

Referenced by statclock().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sched_clock_tick()

static void sched_clock_tick ( struct thread *  td)
static

Definition at line 721 of file sched_4bsd.c.

References ESTCPULIM, pcpuidlestat::idlecalls, INVERSE_ESTCPU_WEIGHT, pcpuidlestat::oldidlecalls, resetpriority(), resetpriority_thread(), sched_slice, TDF_SLICEEND, and ts.

Referenced by sched_clock().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sched_estcpu()

u_int sched_estcpu ( struct thread *  td)

Definition at line 1636 of file sched_4bsd.c.

References td_sched::ts_estcpu.

Referenced by fill_kinfo_aggregate(), and fill_kinfo_thread().

Here is the caller graph for this function:

◆ sched_exit()

void sched_exit ( struct proc *  p,
struct thread *  td 
)

Definition at line 762 of file sched_4bsd.c.

References sched_exit_thread(), and sched_tdname().

Referenced by exit1().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sched_exit_thread()

void sched_exit_thread ( struct thread *  td,
struct thread *  child 
)

Definition at line 773 of file sched_4bsd.c.

References child, ESTCPULIM, sched_load_rem(), sched_tdname(), and td_sched::ts_estcpu.

Referenced by sched_exit(), and thread_exit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sched_fork()

void sched_fork ( struct thread *  td,
struct thread *  childtd 
)

Definition at line 789 of file sched_4bsd.c.

References sched_fork_thread().

Referenced by do_fork().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sched_fork_exit()

void sched_fork_exit ( struct thread *  td)

Definition at line 1716 of file sched_4bsd.c.

References sched_lock, and sched_tdname().

Referenced by fork_exit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sched_fork_thread()

void sched_fork_thread ( struct thread *  td,
struct thread *  childtd 
)

Definition at line 795 of file sched_4bsd.c.

References cpuset_ref(), sched_lock, ts, td_sched::ts_estcpu, td_sched::ts_flags, and TSF_AFFINITY.

Referenced by kthread_add(), sched_fork(), and thread_create().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sched_idletd()

void sched_idletd ( void *  dummy)

Definition at line 1646 of file sched_4bsd.c.

References Giant, pcpuidlestat::idlecalls, mi_switch(), pcpuidlestat::oldidlecalls, sched_lock, and sched_runnable().

Referenced by idle_setup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sched_initticks()

static void sched_initticks ( void *  dummy)
static

Definition at line 652 of file sched_4bsd.c.

References hogticks, hz, realstathz, sched_slice, and stathz.

◆ sched_is_bound()

int sched_is_bound ( struct thread *  td)

Definition at line 1560 of file sched_4bsd.c.

References TDF_BOUND.

Referenced by epoch_drain_callbacks(), and epoch_wait_preempt().

Here is the caller graph for this function:

◆ sched_lend_prio()

void sched_lend_prio ( struct thread *  td,
u_char  prio 
)

Definition at line 868 of file sched_4bsd.c.

References sched_priority().

Referenced by propagate_priority(), sched_unlend_prio(), and turnstile_claim().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sched_lend_user_prio()

void sched_lend_user_prio ( struct thread *  td,
u_char  prio 
)

Definition at line 939 of file sched_4bsd.c.

References sched_prio().

Referenced by do_lock_pp(), do_unlock_pp(), sched_lend_user_prio_cond(), umtx_pi_claim(), umtx_pi_drop(), umtx_propagate_priority(), and umtx_repropagate_priority().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sched_lend_user_prio_cond()

void sched_lend_user_prio_cond ( struct thread *  td,
u_char  prio 
)

Definition at line 955 of file sched_4bsd.c.

References sched_lend_user_prio().

Referenced by umtx_thread_cleanup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sched_load()

int sched_load ( void  )

Definition at line 1574 of file sched_4bsd.c.

References sched_tdcnt.

Referenced by loadav().

Here is the caller graph for this function:

◆ sched_load_add()

static __inline void sched_load_add ( void  )
static

Definition at line 284 of file sched_4bsd.c.

References sched_tdcnt.

Referenced by sched_add(), and sched_setup().

Here is the caller graph for this function:

◆ sched_load_rem()

static __inline void sched_load_rem ( void  )
static

Definition at line 293 of file sched_4bsd.c.

References sched_tdcnt.

Referenced by sched_exit_thread(), sched_rem(), and sched_switch().

Here is the caller graph for this function:

◆ sched_nice()

void sched_nice ( struct proc *  p,
int  nice 
)

Definition at line 814 of file sched_4bsd.c.

References resetpriority(), and resetpriority_thread().

Referenced by donice().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sched_pctcpu()

fixpt_t sched_pctcpu ( struct thread *  td)

Definition at line 1592 of file sched_4bsd.c.

References ts.

Referenced by fill_kinfo_aggregate(), fill_kinfo_thread(), proc_sum(), thread_compare(), and tty_info().

Here is the caller graph for this function:

◆ sched_preempt()

void sched_preempt ( struct thread *  td)

Definition at line 1508 of file sched_4bsd.c.

References mi_switch().

Here is the call graph for this function:

◆ sched_prio()

◆ sched_priority()

static void sched_priority ( struct thread *  td,
u_char  prio 
)
static

Definition at line 839 of file sched_4bsd.c.

References sched_add(), sched_rem(), and sched_tdname().

Referenced by sched_lend_prio(), and sched_prio().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sched_relinquish()

void sched_relinquish ( struct thread *  td)

Definition at line 1567 of file sched_4bsd.c.

References mi_switch().

Referenced by ksched_yield(), and thread_single().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sched_rem()

void sched_rem ( struct thread *  td)

Definition at line 1433 of file sched_4bsd.c.

References runq, runq_remove(), sched_load_rem(), sched_lock, sched_tdname(), and ts.

Referenced by sched_affinity(), and sched_priority().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sched_rr_interval()

int sched_rr_interval ( void  )

Definition at line 699 of file sched_4bsd.c.

References hz, realstathz, and sched_slice.

Referenced by ksched_attach().

Here is the caller graph for this function:

◆ sched_runnable()

int sched_runnable ( void  )

Definition at line 689 of file sched_4bsd.c.

References runq, and runq_check().

Referenced by sched_idletd().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sched_setup()

static void sched_setup ( void *  dummy)
static

Definition at line 639 of file sched_4bsd.c.

References sched_load_add(), and setup_runqs().

Here is the call graph for this function:

◆ sched_sizeof_proc()

int sched_sizeof_proc ( void  )

Definition at line 1580 of file sched_4bsd.c.

Referenced by procinit().

Here is the caller graph for this function:

◆ sched_sizeof_thread()

int sched_sizeof_thread ( void  )

Definition at line 1586 of file sched_4bsd.c.

Referenced by threadinit().

Here is the caller graph for this function:

◆ sched_sleep()

void sched_sleep ( struct thread *  td,
int  pri 
)

Definition at line 973 of file sched_4bsd.c.

References sched_prio(), and ticks.

Referenced by sleepq_switch(), thread_suspend_one(), and thread_suspend_switch().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sched_switch()

void sched_switch ( struct thread *  td,
int  flags 
)

Definition at line 986 of file sched_4bsd.c.

References choosethread(), flags, mtx, sched_add(), sched_load_rem(), sched_lock, sched_tdname(), TDF_SLICEEND, thread_lock_block(), and ts.

Referenced by mi_switch().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sched_tdname()

char * sched_tdname ( struct thread *  td)

Definition at line 1735 of file sched_4bsd.c.

References snprintf(), and ts.

Referenced by __mtx_lock_sleep(), __rw_rlock_hard(), __rw_wlock_hard(), _sx_slock_hard(), _sx_xlock_hard(), sched_add(), sched_exit(), sched_exit_thread(), sched_fork_exit(), sched_priority(), sched_rem(), sched_switch(), and statclock().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sched_throw()

void sched_throw ( struct thread *  td)

Definition at line 1702 of file sched_4bsd.c.

References sched_lock, and sched_throw_tail().

Referenced by thread_exit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sched_throw_tail()

static void sched_throw_tail ( struct thread *  td)
static

Definition at line 1666 of file sched_4bsd.c.

References choosethread(), and sched_lock.

Referenced by sched_ap_entry(), and sched_throw().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sched_unbind()

void sched_unbind ( struct thread *  td)

Definition at line 1552 of file sched_4bsd.c.

Referenced by cf_set_method(), epoch_drain_callbacks(), epoch_wait_preempt(), and quiesce_cpus().

Here is the caller graph for this function:

◆ sched_unlend_prio()

void sched_unlend_prio ( struct thread *  td,
u_char  prio 
)

Definition at line 884 of file sched_4bsd.c.

References sched_lend_prio(), and sched_prio().

Referenced by turnstile_disown(), and turnstile_unpend().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sched_user_prio()

void sched_user_prio ( struct thread *  td,
u_char  prio 
)

Definition at line 928 of file sched_4bsd.c.

Referenced by kproc_create(), resetpriority(), and rtp_to_pri().

Here is the caller graph for this function:

◆ sched_userret_slowpath()

void sched_userret_slowpath ( struct thread *  td)

Definition at line 1521 of file sched_4bsd.c.

◆ sched_wakeup()

void sched_wakeup ( struct thread *  td,
int  srqflags 
)

Definition at line 1118 of file sched_4bsd.c.

References resetpriority(), sched_add(), sched_slice, ts, and updatepri().

Referenced by setrunnable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ schedcpu()

static void schedcpu ( void  )
static

Definition at line 463 of file sched_4bsd.c.

References allproc_lock, averunnable, ccpu, CCPU_SHIFT, decay_cpu, loadfactor, realstathz, resetpriority(), resetpriority_thread(), TDF_DIDRUN, ts, and updatepri().

Referenced by schedcpu_thread().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ schedcpu_thread()

static void schedcpu_thread ( void  )
static

Definition at line 564 of file sched_4bsd.c.

References hz, and schedcpu().

Here is the call graph for this function:

◆ schedinit()

void schedinit ( void  )

Definition at line 670 of file sched_4bsd.c.

References sched_lock, and sched_slice.

Referenced by proc0_init().

Here is the caller graph for this function:

◆ schedinit_ap()

void schedinit_ap ( void  )

Definition at line 682 of file sched_4bsd.c.

◆ SDT_PROBE_DEFINE() [1/2]

SDT_PROBE_DEFINE ( sched  ,
on__cpu   
)

◆ SDT_PROBE_DEFINE() [2/2]

SDT_PROBE_DEFINE ( sched  ,
remain__cpu   
)

◆ SDT_PROBE_DEFINE2() [1/3]

SDT_PROBE_DEFINE2 ( sched  ,
load__change  ,
"int"  ,
"int"   
)

◆ SDT_PROBE_DEFINE2() [2/3]

SDT_PROBE_DEFINE2 ( sched  ,
off__cpu  ,
"struct thread *"  ,
"struct proc *"   
)

◆ SDT_PROBE_DEFINE2() [3/3]

SDT_PROBE_DEFINE2 ( sched  ,
surrender  ,
"struct thread *"  ,
"struct proc *"   
)

◆ SDT_PROBE_DEFINE3() [1/2]

SDT_PROBE_DEFINE3 ( sched  ,
change__pri  ,
"struct thread *"  ,
"struct proc *"  ,
"uint8_t"   
)

◆ SDT_PROBE_DEFINE3() [2/2]

SDT_PROBE_DEFINE3 ( sched  ,
dequeue  ,
"struct thread *"  ,
"struct proc *"  ,
"void *"   
)

◆ SDT_PROBE_DEFINE4() [1/2]

SDT_PROBE_DEFINE4 ( sched  ,
enqueue  ,
"struct thread *"  ,
"struct proc *"  ,
"void *"  ,
"int"   
)

◆ SDT_PROBE_DEFINE4() [2/2]

SDT_PROBE_DEFINE4 ( sched  ,
lend__pri  ,
"struct thread *"  ,
"struct proc *"  ,
"uint8_t"  ,
"struct thread *"   
)

◆ SDT_PROVIDER_DEFINE()

SDT_PROVIDER_DEFINE ( sched  )

◆ setup_runqs()

static void setup_runqs ( void  )
static

Definition at line 182 of file sched_4bsd.c.

References runq, and runq_init().

Referenced by sched_setup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SYSCTL_INT()

SYSCTL_INT ( _kern_sched  ,
OID_AUTO  ,
slice  ,
CTLFLAG_RW  ,
sched_slice,
,
"Quantum for timeshare threads in stathz ticks  
)

◆ sysctl_kern_quantum()

static int sysctl_kern_quantum ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 195 of file sched_4bsd.c.

References hogticks, hz, realstathz, sched_slice, and sysctl_handle_int().

Here is the call graph for this function:

◆ SYSCTL_NODE()

SYSCTL_NODE ( _kern  ,
OID_AUTO  ,
sched  ,
CTLFLAG_RD|  CTLFLAG_MPSAFE,
,
"Scheduler"   
)

◆ SYSCTL_PROC()

SYSCTL_PROC ( _kern_sched  ,
OID_AUTO  ,
quantum  ,
CTLTYPE_INT|CTLFLAG_RW|  CTLFLAG_MPSAFE,
NULL  ,
,
sysctl_kern_quantum  ,
"I"  ,
"Quantum for timeshare threads in microseconds"   
)

◆ SYSCTL_STRING()

SYSCTL_STRING ( _kern_sched  ,
OID_AUTO  ,
name  ,
CTLFLAG_RD  ,
"4BSD"  ,
,
"Scheduler name  
)

◆ SYSCTL_UINT()

SYSCTL_UINT ( _kern  ,
OID_AUTO  ,
ccpu  ,
CTLFLAG_RD  ,
ccpu,
,
"Decay factor used for updating %CPU"   
)

◆ SYSINIT() [1/3]

SYSINIT ( sched_initticks  ,
SI_SUB_CLOCKS  ,
SI_ORDER_THIRD  ,
sched_initticks  ,
NULL   
)

◆ SYSINIT() [2/3]

SYSINIT ( sched_setup  ,
SI_SUB_RUN_QUEUE  ,
SI_ORDER_FIRST  ,
sched_setup  ,
NULL   
)

◆ SYSINIT() [3/3]

SYSINIT ( schedcpu  ,
SI_SUB_LAST  ,
SI_ORDER_FIRST  ,
kproc_start  ,
sched_kp 
)

◆ updatepri()

static void updatepri ( struct thread *  td)
static

Definition at line 579 of file sched_4bsd.c.

References averunnable, decay_cpu, loadfactor, and ts.

Referenced by sched_wakeup(), and schedcpu().

Here is the caller graph for this function:

Variable Documentation

◆ ccpu

fixpt_t ccpu = 0.95122942450071400909 * FSCALE
static

Definition at line 439 of file sched_4bsd.c.

Referenced by schedcpu().

◆ realstathz

int realstathz = 127
static

Definition at line 128 of file sched_4bsd.c.

Referenced by sched_initticks(), sched_rr_interval(), schedcpu(), and sysctl_kern_quantum().

◆ runq

struct runq runq
static

◆ sched_kp

struct kproc_desc sched_kp
static
Initial value:
= {
"schedcpu",
NULL
}
static void schedcpu_thread(void)
Definition: sched_4bsd.c:564

Definition at line 147 of file sched_4bsd.c.

◆ sched_lock

◆ sched_slice

int sched_slice = 12
static

◆ sched_tdcnt

int sched_tdcnt
static

Definition at line 129 of file sched_4bsd.c.

Referenced by sched_load(), sched_load_add(), and sched_load_rem().