12.07.2015 Views

INTRO (9) NetBSD Kernel Developer's Manual INTRO (9) NAME ...

INTRO (9) NetBSD Kernel Developer's Manual INTRO (9) NAME ...

INTRO (9) NetBSD Kernel Developer's Manual INTRO (9) NAME ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

KTHREAD (9) <strong>NetBSD</strong> <strong>Kernel</strong> Developer’s <strong>Manual</strong> KTHREAD (9)<strong>NAME</strong>kthread_create, kthread_destroy, kthread_exit —kernel threadsSYNOPSIS#include intkthread_create(pri_t pri , int flags , struct cpu_info ∗ci ,void (∗func)(void ∗) , void ∗arg , lwp_t ∗∗newlp , const char ∗fmt , ...);voidkthread_destroy(lwp_t ∗l);voidkthread_exit(int ecode);DESCRIPTION<strong>Kernel</strong> threads are light-weight processes which execute entirely within the kernel.Any process can request the creation of a new kernel thread. <strong>Kernel</strong> threads are not swapped out duringmemory congestion. The VM space and limits are shared with proc0 (usually swapper).FUNCTIONSkthread_create(pri , flags , ci , func , arg , newlp , fmt , ...)Create a kernel thread. The arguments are as follows.priflagscifuncargnewplfmtPriority level for the thread. If no priority level isdesired specify PRI_NONE, causingkthread_create() to select the default priority level.Flags that can be logically ORed together to alter the thread’s behaviour.KTHREAD_IDLE: causes the thread to be created in the LSIDL (idle) state. Bydefault, the threads are created in the LSRUN (runnable) state, meaning they willbegin execution shortly after creation.KTHREAD_MPSAFE: Specifies that the thread does its own locking and so is multiprocessorsafe. If not specified, the global kernel lock will be held whenever thethread is running (unless explicitly dropped by the thread).KTHREAD_INTR: Specifies that the thread services device interrupts. This flag isintended for kernel internal use and should not normally be specified.If non-NULL, the thread will be created bound to the CPU specified by ci, meaningthat it will only ever execute on that CPU. By default, the threads are free to executeon any CPU in the system.Afunction to be called when the thread begins executing. This function must notreturn. If the thread runs to completion, it must call kthread_exit() to properlyterminate itself.An argument to be passed to func(). May be NULL if not required.Apointer to receive the new lwp structure for the kernel thread. May be NULL if notrequired.Astring containing format information used to display the kernel thread name. Mustnot be NULL.<strong>NetBSD</strong> 3.0 November 22, 2007 1

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!