FreeBSD kernel kern code
kern_synch.c File Reference
#include <sys/cdefs.h>
#include "opt_kdtrace.h"
#include "opt_ktrace.h"
#include "opt_sched.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/condvar.h>
#include <sys/kdb.h>
#include <sys/kernel.h>
#include <sys/ktr.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/resourcevar.h>
#include <sys/sched.h>
#include <sys/sdt.h>
#include <sys/signalvar.h>
#include <sys/sleepqueue.h>
#include <sys/smp.h>
#include <sys/sx.h>
#include <sys/sysctl.h>
#include <sys/sysproto.h>
#include <sys/vmmeter.h>
#include <machine/cpu.h>
Include dependency graph for kern_synch.c:

Go to the source code of this file.

Macros

#define KTDSTATE(td)
 

Functions

 __FBSDID ("$BSDSUniX$")
 
static void synch_setup (void *dummy)
 
 SYSINIT (synch_setup, SI_SUB_KICK_SCHEDULER, SI_ORDER_FIRST, synch_setup, NULL)
 
 SYSCTL_INT (_kern, OID_AUTO, fscale, CTLFLAG_RD, SYSCTL_NULL_INT_PTR, FSCALE,"")
 
static void loadav (void *arg)
 
 SDT_PROVIDER_DECLARE (sched)
 
 SDT_PROBE_DEFINE (sched,,, preempt)
 
 SDT_PROBE_DEFINE (sched,,, cpucaps__sleep)
 
 SDT_PROBE_DEFINE (sched,,, cpucaps__wakeup)
 
 SDT_PROBE_DEFINE (sched,,, schedctl__nopreempt)
 
 SDT_PROBE_DEFINE (sched,,, schedctl__preempt)
 
 SDT_PROBE_DEFINE (sched,,, schedctl__yield)
 
void sleepinit (void)
 
int _sleep (void *ident, struct lock_object *lock, int priority, const char *wmesg, int timo)
 
int msleep_spin (void *ident, struct mtx *mtx, const char *wmesg, int timo)
 
int pause (const char *wmesg, int timo)
 
void wakeup (void *ident)
 
void wakeup_one (void *ident)
 
static void kdb_switch (void)
 
void mi_switch (int flags, struct thread *newtd)
 
int setrunnable (struct thread *td)
 
int should_yield (void)
 
void maybe_yield (void)
 
void kern_yield (int prio)
 
int sys_yield (struct thread *td, struct yield_args *uap)
 

Variables

int hogticks
 
static int pause_wchan
 
static struct callout loadav_callout
 
struct loadavg averunnable
 
static fixpt_t cexp [3]
 

Macro Definition Documentation

#define KTDSTATE (   td)
Value:
(((td)->td_inhibitors & TDI_SLEEPING) != 0 ? "sleep" : \
((td)->td_inhibitors & TDI_SUSPENDED) != 0 ? "suspended" : \
((td)->td_inhibitors & TDI_SWAPPED) != 0 ? "swapped" : \
((td)->td_inhibitors & TDI_LOCK) != 0 ? "blocked" : \
((td)->td_inhibitors & TDI_IWAIT) != 0 ? "iwait" : "yielding")

Definition at line 76 of file kern_synch.c.

Referenced by mi_switch().

Function Documentation

__FBSDID ( "$BSDSUniX$"  )
int _sleep ( void *  ident,
struct lock_object *  lock,
int  priority,
const char *  wmesg,
int  timo 
)
static void kdb_switch ( void  )
static

Definition at line 410 of file kern_synch.c.

References kdb_backtrace(), kdb_reenter(), and panic().

Referenced by mi_switch().

Here is the call graph for this function:

Here is the caller graph for this function:

void kern_yield ( int  prio)

Definition at line 592 of file kern_synch.c.

References mi_switch(), and sched_prio().

Referenced by __mnt_vnode_next(), __mnt_vnode_next_active(), __mnt_vnode_next_all(), buf_daemon(), maybe_yield(), userland_sysctl(), vlrureclaim(), vn_rdwr_inchunks(), and vnlru_proc().

Here is the call graph for this function:

Here is the caller graph for this function:

static void loadav ( void *  arg)
static

Definition at line 545 of file kern_synch.c.

References averunnable, cexp, hz, loadav_callout, and sched_load().

Referenced by synch_setup().

Here is the call graph for this function:

Here is the caller graph for this function:

void maybe_yield ( void  )

Definition at line 584 of file kern_synch.c.

References kern_yield(), and should_yield().

Referenced by kern_posix_fallocate(), and uiomove_faultflag().

Here is the call graph for this function:

Here is the caller graph for this function:

void mi_switch ( int  flags,
struct thread *  newtd 
)
int msleep_spin ( void *  ident,
struct mtx *  mtx,
const char *  wmesg,
int  timo 
)

Definition at line 265 of file kern_synch.c.

References sleepq_add(), sleepq_lock(), sleepq_release(), sleepq_set_timeout(), sleepq_timedwait(), and sleepq_wait().

Referenced by alq_getn(), alq_shutdown(), alq_writen(), and TQ_SLEEP().

Here is the call graph for this function:

Here is the caller graph for this function:

int pause ( const char *  wmesg,
int  timo 
)

Definition at line 350 of file kern_synch.c.

References hz, pause_wchan, and tick.

Referenced by _intr_drain(), fork1(), ithread_execute_handlers(), mnt_vnode_next_active(), parse_dir_ask(), parse_mount(), schedcpu_thread(), and syscall_thread_drain().

Here is the caller graph for this function:

SDT_PROBE_DEFINE ( sched  ,
preempt   
)
SDT_PROBE_DEFINE ( sched  ,
cpucaps__sleep   
)
SDT_PROBE_DEFINE ( sched  ,
cpucaps__wakeup   
)
SDT_PROBE_DEFINE ( sched  ,
schedctl__nopreempt   
)
SDT_PROBE_DEFINE ( sched  ,
schedctl__preempt   
)
SDT_PROBE_DEFINE ( sched  ,
schedctl__yield   
)
SDT_PROVIDER_DECLARE ( sched  )
int setrunnable ( struct thread *  td)

Definition at line 506 of file kern_synch.c.

References panic(), printf(), and sched_wakeup().

Referenced by sleepq_resume_thread(), sleepq_timeout(), and thread_unsuspend_one().

Here is the call graph for this function:

Here is the caller graph for this function:

int should_yield ( void  )

Definition at line 577 of file kern_synch.c.

References hogticks, and ticks.

Referenced by __mnt_vnode_next(), __mnt_vnode_next_active(), __mnt_vnode_next_all(), maybe_yield(), mnt_vnode_next_active(), vlrureclaim(), and vop_stdallocate().

Here is the caller graph for this function:

void sleepinit ( void  )

Definition at line 124 of file kern_synch.c.

References hogticks, hz, and init_sleepqueues().

Referenced by proc0_init().

Here is the call graph for this function:

Here is the caller graph for this function:

static void synch_setup ( void *  dummy)
static

Definition at line 568 of file kern_synch.c.

References callout_init(), loadav(), and loadav_callout.

Here is the call graph for this function:

int sys_yield ( struct thread *  td,
struct yield_args *  uap 
)

Definition at line 612 of file kern_synch.c.

References mi_switch(), and sched_prio().

Here is the call graph for this function:

SYSCTL_INT ( _kern  ,
OID_AUTO  ,
fscale  ,
CTLFLAG_RD  ,
SYSCTL_NULL_INT_PTR  ,
FSCALE  ,
""   
)
SYSINIT ( synch_setup  ,
SI_SUB_KICK_SCHEDULER  ,
SI_ORDER_FIRST  ,
synch_setup  ,
NULL   
)
void wakeup ( void *  ident)

Definition at line 378 of file kern_synch.c.

References proc0, sleepq_broadcast(), sleepq_lock(), and sleepq_release().

Referenced by addupc_task(), aio_bio_done_notify(), aio_kick(), aio_kick_nowait(), ald_activate(), ald_shutdown(), alq_getn(), alq_writen(), bd_speedup(), bd_wakeup(), bdone(), biodone(), bufcountwakeup(), bufobj_wdrop(), bufspacewakeup(), bunpin(), childproc_jobstate(), closef(), config_intrhook_disestablish(), destroy_devl(), do_dup(), dounmount(), ether_poll_register(), eventhandler_prune_list(), exit1(), foffset_unlock(), getnewvnode_wait(), intr_event_add_handler(), intr_event_execute_handlers(), ithread_loop(), itimer_leave(), kern_close(), kern_msgctl(), kern_msgrcv(), kern_msgsnd(), kern_semctl(), knote_fdclose(), kproc_exit(), kproc_resume(), kproc_suspend(), kproc_suspend_check(), kqueue_release(), kqueue_task(), kqueue_wakeup(), kthread_exit(), kthread_resume(), kthread_suspend_check(), lf_advlockasync(), lf_iteratelocks_vnode(), lf_purgelocks(), lf_wakeup_lock(), numdirtywakeup(), pipe_direct_write(), pipe_read(), pipe_write(), pipeclose(), pipeunlock(), proc_reap(), rangelock_calc_block(), realitexpire(), root_mount_rel(), runningbufwakeup(), semexit_myhook(), shmget_allocate_segment(), sleepq_resume_thread(), softclock_call_cc(), soisconnected(), soisdisconnected(), soisdisconnecting(), soshutdown(), sowakeup(), stopevent(), sys_acct(), sys_semop(), sys_thr_wake(), sysctl_root(), taskqueue_run_locked(), taskqueue_terminate(), tdsendsignal(), tty_makedev(), turnstile_unpend(), umtxq_signal_queue(), umtxq_signal_thread(), vfs_mount_destroy(), vfs_mountroot(), vfs_notify_upper(), vfs_unbusy(), vfs_write_resume_flags(), vn_finished_secondary_write(), vn_finished_write(), and vnlru_proc().

Here is the call graph for this function:

void wakeup_one ( void *  ident)

Definition at line 398 of file kern_synch.c.

References sleepq_lock(), sleepq_release(), and sleepq_signal().

Referenced by _mqueue_recv(), _mqueue_send(), ald_daemon(), alq_flush(), alq_getn(), alq_post_flags(), alq_writen(), loadimage(), soisconnected(), sonewconn(), taskqueue_thread_enqueue(), taskqueue_thread_loop(), and umtxq_unbusy().

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

struct loadavg averunnable
Initial value:
=
{ {0, 0, 0}, FSCALE }

Definition at line 92 of file kern_synch.c.

Referenced by loadav(), schedcpu(), tty_info(), and updatepri().

fixpt_t cexp[3]
static
Initial value:
= {
0.9200444146293232 * FSCALE,
0.9834714538216174 * FSCALE,
0.9944598480048967 * FSCALE,
}

Definition at line 98 of file kern_synch.c.

Referenced by loadav().

int hogticks

Definition at line 87 of file kern_synch.c.

Referenced by sched_initticks(), should_yield(), sleepinit(), and sysctl_kern_quantum().

struct callout loadav_callout
static

Definition at line 90 of file kern_synch.c.

Referenced by loadav(), and synch_setup().

int pause_wchan
static

Definition at line 88 of file kern_synch.c.

Referenced by _sleep(), and pause().