FreeBSD kernel kern code
kern_thr.c File Reference
#include <sys/cdefs.h>
#include "opt_posix.h"
#include "opt_hwpmc_hooks.h"
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/priv.h>
#include <sys/proc.h>
#include <sys/posix4.h>
#include <sys/ptrace.h>
#include <sys/racct.h>
#include <sys/resourcevar.h>
#include <sys/rwlock.h>
#include <sys/sched.h>
#include <sys/sysctl.h>
#include <sys/smp.h>
#include <sys/syscallsubr.h>
#include <sys/sysent.h>
#include <sys/systm.h>
#include <sys/sysproto.h>
#include <sys/signalvar.h>
#include <sys/ucontext.h>
#include <sys/thr.h>
#include <sys/rtprio.h>
#include <sys/umtxvar.h>
#include <sys/limits.h>
#include <machine/frame.h>
#include <security/audit/audit.h>
Include dependency graph for kern_thr.c:

Go to the source code of this file.

Data Structures

struct  thr_create_initthr_args
 

Macros

#define suword_lwpid   suword
 

Functions

 __FBSDID ("$FreeBSD$")
 
static SYSCTL_NODE (_kern, OID_AUTO, threads, CTLFLAG_RW|CTLFLAG_MPSAFE, 0, "thread allocation")
 
 SYSCTL_INT (_kern_threads, OID_AUTO, max_threads_per_proc, CTLFLAG_RW, &max_threads_per_proc, 0, "Limit on threads per proc")
 
 SYSCTL_INT (_kern_threads, OID_AUTO, max_threads_hits, CTLFLAG_RD, &max_threads_hits, 0, "kern.threads.max_threads_per_proc hit count")
 
static int thr_create_initthr (struct thread *td, void *thunk)
 
int sys_thr_create (struct thread *td, struct thr_create_args *uap)
 
int sys_thr_new (struct thread *td, struct thr_new_args *uap)
 
static int thr_new_initthr (struct thread *td, void *thunk)
 
int kern_thr_new (struct thread *td, struct thr_param *param)
 
int thread_create (struct thread *td, struct rtprio *rtp, int(*initialize_thread)(struct thread *, void *), void *thunk)
 
int sys_thr_self (struct thread *td, struct thr_self_args *uap)
 
int sys_thr_exit (struct thread *td, struct thr_exit_args *uap)
 
int kern_thr_exit (struct thread *td)
 
int sys_thr_kill (struct thread *td, struct thr_kill_args *uap)
 
int sys_thr_kill2 (struct thread *td, struct thr_kill2_args *uap)
 
int sys_thr_suspend (struct thread *td, struct thr_suspend_args *uap)
 
int kern_thr_suspend (struct thread *td, struct timespec *tsp)
 
int sys_thr_wake (struct thread *td, struct thr_wake_args *uap)
 
int sys_thr_set_name (struct thread *td, struct thr_set_name_args *uap)
 
int kern_thr_alloc (struct proc *p, int pages, struct thread **ntd)
 

Variables

int max_threads_per_proc = 1500
 
static int max_threads_hits
 

Macro Definition Documentation

◆ suword_lwpid

#define suword_lwpid   suword

Definition at line 93 of file kern_thr.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ kern_thr_alloc()

int kern_thr_alloc ( struct proc *  p,
int  pages,
struct thread **  ntd 
)

Definition at line 613 of file kern_thr.c.

References max_threads_hits, max_threads_per_proc, and thread_alloc().

Referenced by thread_create().

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

◆ kern_thr_exit()

int kern_thr_exit ( struct thread *  td)

Definition at line 325 of file kern_thr.c.

References ptracestop(), tdsigcleanup(), thread_exit(), thread_stopped(), and tidhash_remove().

Referenced by sys_thr_exit(), and thread_suspend_check().

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

◆ kern_thr_new()

int kern_thr_new ( struct thread *  td,
struct thr_param *  param 
)

Definition at line 176 of file kern_thr.c.

References thr_new_initthr(), and thread_create().

Referenced by sys_thr_new().

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

◆ kern_thr_suspend()

int kern_thr_suspend ( struct thread *  td,
struct timespec *  tsp 
)

Definition at line 510 of file kern_thr.c.

References tvtohz().

Referenced by sys_thr_suspend().

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

◆ sys_thr_create()

int sys_thr_create ( struct thread *  td,
struct thr_create_args *  uap 
)

Definition at line 119 of file kern_thr.c.

References thr_create_initthr_args::ctx, thr_create_initthr(), thread_create(), and thr_create_initthr_args::tid.

Here is the call graph for this function:

◆ sys_thr_exit()

int sys_thr_exit ( struct thread *  td,
struct thr_exit_args *  uap 
)

Definition at line 309 of file kern_thr.c.

References kern_thr_exit(), kern_umtx_wake(), suword_lwpid, and umtx_thread_exit().

Here is the call graph for this function:

◆ sys_thr_kill()

int sys_thr_kill ( struct thread *  td,
struct thr_kill_args *  uap 
)

Definition at line 388 of file kern_thr.c.

References tdfind(), and tdksignal().

Here is the call graph for this function:

◆ sys_thr_kill2()

int sys_thr_kill2 ( struct thread *  td,
struct thr_kill2_args *  uap 
)

Definition at line 435 of file kern_thr.c.

References p_cansignal(), pfind(), tdfind(), and tdksignal().

Here is the call graph for this function:

◆ sys_thr_new()

int sys_thr_new ( struct thread *  td,
struct thr_new_args *  uap 
)

Definition at line 132 of file kern_thr.c.

References kern_thr_new().

Here is the call graph for this function:

◆ sys_thr_self()

int sys_thr_self ( struct thread *  td,
struct thr_self_args *  uap 
)

Definition at line 297 of file kern_thr.c.

References suword_lwpid.

◆ sys_thr_set_name()

int sys_thr_set_name ( struct thread *  td,
struct thr_set_name_args *  uap 
)

Definition at line 578 of file kern_thr.c.

References name, and tdfind().

Here is the call graph for this function:

◆ sys_thr_suspend()

int sys_thr_suspend ( struct thread *  td,
struct thr_suspend_args *  uap 
)

Definition at line 492 of file kern_thr.c.

References kern_thr_suspend(), ts, and umtx_copyin_timeout().

Here is the call graph for this function:

◆ sys_thr_wake()

int sys_thr_wake ( struct thread *  td,
struct thr_wake_args *  uap 
)

Definition at line 554 of file kern_thr.c.

References tdfind(), and wakeup().

Here is the call graph for this function:

◆ SYSCTL_INT() [1/2]

SYSCTL_INT ( _kern_threads  ,
OID_AUTO  ,
max_threads_hits  ,
CTLFLAG_RD  ,
max_threads_hits,
,
"kern.threads.max_threads_per_proc hit count  
)

◆ SYSCTL_INT() [2/2]

SYSCTL_INT ( _kern_threads  ,
OID_AUTO  ,
max_threads_per_proc  ,
CTLFLAG_RW  ,
max_threads_per_proc,
,
"Limit on threads per proc"   
)

◆ SYSCTL_NODE()

static SYSCTL_NODE ( _kern  ,
OID_AUTO  ,
threads  ,
CTLFLAG_RW|  CTLFLAG_MPSAFE,
,
"thread allocation"   
)
static

◆ thr_create_initthr()

static int thr_create_initthr ( struct thread *  td,
void *  thunk 
)
static

Definition at line 106 of file kern_thr.c.

References thr_create_initthr_args::ctx, suword_lwpid, and thr_create_initthr_args::tid.

Referenced by sys_thr_create().

Here is the caller graph for this function:

◆ thr_new_initthr()

static int thr_new_initthr ( struct thread *  td,
void *  thunk 
)
static

Definition at line 147 of file kern_thr.c.

References suword_lwpid.

Referenced by kern_thr_new().

Here is the caller graph for this function:

◆ thread_create()

int thread_create ( struct thread *  td,
struct rtprio *  rtp,
int(*)(struct thread *, void *)  initialize_thread,
void *  thunk 
)

Definition at line 192 of file kern_thr.c.

References kern_thr_alloc(), priv_check(), rtp_to_pri(), sched_add(), sched_fork_thread(), thread_cow_free(), thread_cow_get(), thread_free(), thread_link(), and tidhash_add().

Referenced by kern_thr_new(), and sys_thr_create().

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

Variable Documentation

◆ max_threads_hits

int max_threads_hits
static

Definition at line 74 of file kern_thr.c.

Referenced by kern_thr_alloc().

◆ max_threads_per_proc

int max_threads_per_proc = 1500

Definition at line 70 of file kern_thr.c.

Referenced by kern_thr_alloc(), and threadinit().