1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-12 09:58:36 +00:00

Slight reorganization of kernel thread/process creation. Instead of using

SYSINIT_KT() etc (which is a static, compile-time procedure), use a
NetBSD-style kthread_create() interface.  kproc_start is still available
as a SYSINIT() hook.  This allowed simplification of chunks of the
sysinit code in the process.  This kthread_create() is our old kproc_start
internals, with the SYSINIT_KT fork hooks grafted in and tweaked to work
the same as the NetBSD one.

One thing I'd like to do shortly is get rid of nfsiod as a user initiated
process.  It makes sense for the nfs client code to create them on the
fly as needed up to a user settable limit.  This means that nfsiod
doesn't need to be in /sbin and is always "available".  This is a fair bit
easier to do outside of the SYSINIT_KT() framework.
This commit is contained in:
Peter Wemm 1999-07-01 13:21:46 +00:00
parent 940b9c82a0
commit 9c8b8baa38
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=48391
17 changed files with 225 additions and 207 deletions

View File

@ -38,7 +38,7 @@
*
* from: @(#)vm_machdep.c 7.3 (Berkeley) 5/13/91
* Utah $Hdr: vm_machdep.c 1.16.1.1 89/06/23$
* $Id: vm_machdep.c,v 1.15 1999/06/08 16:42:19 dt Exp $
* $Id: vm_machdep.c,v 1.16 1999/06/10 20:40:59 dt Exp $
*/
/*
* Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
@ -218,8 +218,8 @@ cpu_fork(p1, p2)
void
cpu_set_fork_handler(p, func, arg)
struct proc *p;
void (*func) __P((const void *));
const void *arg;
void (*func) __P((void *));
void *arg;
{
/*
* Note that the trap frame follows the args, so the function

View File

@ -38,7 +38,7 @@
*
* from: @(#)vm_machdep.c 7.3 (Berkeley) 5/13/91
* Utah $Hdr: vm_machdep.c 1.16.1.1 89/06/23$
* $Id: vm_machdep.c,v 1.121 1999/04/19 14:14:13 peter Exp $
* $Id: vm_machdep.c,v 1.122 1999/06/01 18:19:50 jlemon Exp $
*/
#include "npx.h"
@ -192,8 +192,8 @@ cpu_fork(p1, p2)
void
cpu_set_fork_handler(p, func, arg)
struct proc *p;
void (*func) __P((const void *));
const void *arg;
void (*func) __P((void *));
void *arg;
{
/*
* Note that the trap frame follows the args, so the function

View File

@ -278,6 +278,7 @@ kern/kern_exec.c standard
kern/kern_exit.c standard
kern/kern_fork.c standard
kern/kern_jail.c standard
kern/kern_kthread.c standard
kern/kern_ktrace.c standard
kern/kern_lock.c standard
kern/kern_lockf.c standard

View File

@ -38,7 +38,7 @@
*
* from: @(#)vm_machdep.c 7.3 (Berkeley) 5/13/91
* Utah $Hdr: vm_machdep.c 1.16.1.1 89/06/23$
* $Id: vm_machdep.c,v 1.121 1999/04/19 14:14:13 peter Exp $
* $Id: vm_machdep.c,v 1.122 1999/06/01 18:19:50 jlemon Exp $
*/
#include "npx.h"
@ -192,8 +192,8 @@ cpu_fork(p1, p2)
void
cpu_set_fork_handler(p, func, arg)
struct proc *p;
void (*func) __P((const void *));
const void *arg;
void (*func) __P((void *));
void *arg;
{
/*
* Note that the trap frame follows the args, so the function

View File

@ -39,7 +39,7 @@
* SUCH DAMAGE.
*
* @(#)init_main.c 8.9 (Berkeley) 1/21/94
* $Id: init_main.c,v 1.122 1999/05/11 10:08:10 jb Exp $
* $Id: init_main.c,v 1.123 1999/06/30 15:33:32 peter Exp $
*/
#include "opt_devfs.h"
@ -52,6 +52,7 @@
#include <sys/mount.h>
#include <sys/sysctl.h>
#include <sys/proc.h>
#include <sys/kthread.h>
#include <sys/resourcevar.h>
#include <sys/signalvar.h>
#include <sys/systm.h>
@ -180,7 +181,6 @@ mi_startup(framep)
register struct sysinit **sipp; /* system initialization*/
register struct sysinit **xipp; /* interior loop of sort*/
register struct sysinit *save; /* bubble*/
struct proc *p2;
/*
* Copy the locore.s frame pointer for proc0, this is forked into
@ -220,28 +220,8 @@ mi_startup(framep)
if ((*sipp)->subsystem == SI_SUB_DONE)
continue;
switch( (*sipp)->type) {
case SI_TYPE_DEFAULT:
/* no special processing*/
/* Call function */
(*((*sipp)->func))((*sipp)->udata);
break;
case SI_TYPE_KTHREAD:
/* kernel thread*/
if (fork1(&proc0, RFMEM|RFFDG|RFPROC, &p2))
panic("fork kernel thread");
cpu_set_fork_handler(p2, (*sipp)->func, (*sipp)->udata);
break;
case SI_TYPE_KPROCESS:
if (fork1(&proc0, RFFDG|RFPROC, &p2))
panic("fork kernel process");
cpu_set_fork_handler(p2, (*sipp)->func, (*sipp)->udata);
break;
default:
panic("init_main: unrecognized init type");
}
/* Check off the one we're just done */
(*sipp)->subsystem = SI_SUB_DONE;
@ -261,42 +241,6 @@ mi_startup(framep)
}
/*
* Start a kernel process. This is called after a fork() call in
* mi_startup() in the file kern/init_main.c.
*
* This function is used to start "internal" daemons.
*/
/* ARGSUSED*/
void
kproc_start(udata)
const void *udata;
{
const struct kproc_desc *kp = udata;
struct proc *p = curproc;
#ifdef DIAGNOSTIC
printf("Start pid=%d <%s>\n",p->p_pid, kp->arg0);
#endif
/* save a global descriptor, if desired*/
if( kp->global_procpp != NULL)
*kp->global_procpp = p;
/* this is a non-swapped system process*/
p->p_flag |= P_INMEM | P_SYSTEM;
/* set up arg0 for 'ps', et al*/
strcpy( p->p_comm, kp->arg0);
/* call the processes' main()...*/
(*kp->func)();
/* NOTREACHED */
panic("kproc_start: %s", kp->arg0);
}
/*
***************************************************************************
****
@ -551,29 +495,26 @@ SYSINIT(retrofit, SI_SUB_ROOT_FDTAB, SI_ORDER_FIRST, xxx_vfs_root_fdtab, NULL)
***************************************************************************
*/
static void kthread_init __P((const void *dummy));
SYSINIT_KP(init,SI_SUB_KTHREAD_INIT, SI_ORDER_FIRST, kthread_init, NULL)
extern void prepare_usermode __P((void));
static void start_init __P((struct proc *p));
/* ARGSUSED*/
static void
kthread_init(dummy)
const void *dummy;
{
/* Create process 1 (init(8)). */
start_init(curproc);
prepare_usermode();
static void create_init __P((const void *dummy));
static void start_init __P((void *dummy));
SYSINIT(init,SI_SUB_KTHREAD_INIT, SI_ORDER_FIRST, create_init, NULL)
/*
* This returns to the fork trampoline, then to user mode.
* Like kthread_create(), but runs in it's own address space.
*/
return;
}
static void
create_init(udata)
const void *udata;
{
int error;
error = fork1(&proc0, RFFDG | RFPROC, &initproc);
if (error)
panic("cannot fork init: %d\n", error);
initproc->p_flag |= P_INMEM | P_SYSTEM;
cpu_set_fork_handler(initproc, start_init, NULL);
}
/*
* List of paths to try when searching for "init".
@ -591,16 +532,17 @@ SYSCTL_STRING(_kern, OID_AUTO, init_path, CTLFLAG_RD, init_path, 0, "");
* The program is invoked with one argument containing the boot flags.
*/
static void
start_init(p)
struct proc *p;
start_init(dummy)
void *dummy;
{
vm_offset_t addr;
struct execve_args args;
int options, error;
char *var, *path, *next, *s;
char *ucp, **uap, *arg0, *arg1;
struct proc *p;
initproc = p;
p = curproc;
/*
* Need just enough stack to hold the faked-up "execve()" arguments.
@ -681,11 +623,13 @@ start_init(p)
* Now try to exec the program. If can't for any reason
* other than it doesn't exist, complain.
*
* Otherwise return to mi_startup() which returns to btext
* which completes the system startup.
* Otherwise, return via the fork trampoline all the way
* to user mode as init!
*/
if ((error = execve(p, &args)) == 0)
if ((error = execve(p, &args)) == 0) {
prepare_usermode();
return;
}
if (error != ENOENT)
printf("exec %.*s: error %d\n", (int)(next - path),
path, error);

100
sys/kern/kern_kthread.c Normal file
View File

@ -0,0 +1,100 @@
/*
* Copyright (c) 1999 Peter Wemm <peter@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/proc.h>
#include <sys/kthread.h>
#include <sys/unistd.h>
#include <sys/wait.h>
#include <machine/cpu.h>
#include <machine/stdarg.h>
/*
* Start a kernel process. This is called after a fork() call in
* mi_startup() in the file kern/init_main.c.
*
* This function is used to start "internal" daemons and intended
* to be called from SYSINIT().
*/
void
kproc_start(udata)
const void *udata;
{
const struct kproc_desc *kp = udata;
int error;
error = kthread_create((void (*)(void *))kp->func, NULL,
kp->global_procpp, kp->arg0);
if (error)
panic("kproc_start: %s: error %d", kp->arg0, error);
}
/*
* Create a kernel process/thread/whatever. It shares it's address space
* with proc0 - ie: kernel only.
*/
int
kthread_create(void (*func)(void *), void *arg,
struct proc **newpp, const char *fmt, ...)
{
int error;
va_list ap;
struct proc *p2;
error = fork1(&proc0, RFMEM | RFFDG | RFPROC, &p2);
if (error)
return error;
/* save a global descriptor, if desired */
if (newpp != NULL)
*newpp = p2;
/* this is a non-swapped system process */
p2->p_flag |= P_INMEM | P_SYSTEM | P_NOCLDWAIT;
PHOLD(p2);
/* set up arg0 for 'ps', et al */
va_start(ap, fmt);
vsnprintf(p2->p_comm, sizeof(p2->p_comm), fmt, ap);
va_end(ap);
/* call the processes' main()... */
cpu_set_fork_handler(p2, func, arg);
return 0;
}
void
kthread_exit(int ecode)
{
exit1(curproc, W_EXITCODE(ecode, 0));
}

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: kern_linker.c,v 1.32 1999/05/08 13:01:56 peter Exp $
* $Id: kern_linker.c,v 1.33 1999/06/30 15:33:35 peter Exp $
*/
#include "opt_ddb.h"
@ -96,7 +96,6 @@ linker_file_sysinit(linker_file_t lf)
struct sysinit** sipp;
struct sysinit** xipp;
struct sysinit* save;
struct proc *p2;
const moduledata_t *moddata;
int error;
@ -149,29 +148,8 @@ linker_file_sysinit(linker_file_t lf)
if ((*sipp)->subsystem == SI_SUB_DUMMY)
continue; /* skip dummy task(s)*/
switch ((*sipp)->type) {
case SI_TYPE_DEFAULT:
/* no special processing*/
/* Call function */
(*((*sipp)->func))((*sipp)->udata);
break;
case SI_TYPE_KTHREAD:
/* kernel thread*/
if (fork1(&proc0, RFFDG|RFPROC|RFMEM, &p2))
panic("fork kernel thread");
cpu_set_fork_handler(p2, (*sipp)->func, (*sipp)->udata);
break;
case SI_TYPE_KPROCESS:
/* kernel thread*/
if (fork1(&proc0, RFFDG|RFPROC, &p2))
panic("fork kernel process");
cpu_set_fork_handler(p2, (*sipp)->func, (*sipp)->udata);
break;
default:
panic ("linker_file_sysinit: unrecognized init type");
}
}
}
@ -221,15 +199,8 @@ linker_file_sysuninit(linker_file_t lf)
if ((*sipp)->subsystem == SI_SUB_DUMMY)
continue; /* skip dummy task(s)*/
switch ((*sipp)->type) {
case SI_TYPE_DEFAULT:
/* no special processing*/
/* Call function */
(*((*sipp)->func))((*sipp)->udata);
break;
default:
panic("linker_file_sysuninit: unrecognized uninit type");
}
}
}

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)uipc_mbuf.c 8.2 (Berkeley) 1/4/94
* $Id: uipc_mbuf.c,v 1.38 1999/02/16 10:49:49 dfr Exp $
* $Id: uipc_mbuf.c,v 1.39 1999/04/12 10:07:15 des Exp $
*/
#include <sys/param.h>
@ -178,7 +178,7 @@ static struct kproc_desc mclalloc_kp = {
kproc_mclalloc,
&mclallocproc
};
SYSINIT_KT(mclallocproc, SI_SUB_KTHREAD_UPDATE, SI_ORDER_ANY, kproc_start,
SYSINIT(mclallocproc, SI_SUB_KTHREAD_UPDATE, SI_ORDER_ANY, kproc_start,
&mclalloc_kp);
#endif

View File

@ -13,7 +13,7 @@
* bad that happens because of using this software isn't the responsibility
* of the author. This software is distributed AS-IS.
*
* $Id: vfs_aio.c,v 1.52 1999/06/26 02:46:05 mckusick Exp $
* $Id: vfs_aio.c,v 1.53 1999/06/30 15:33:36 peter Exp $
*/
/*
@ -236,7 +236,7 @@ static int aio_aqueue(struct proc *p, struct aiocb *job, int type) ;
static void aio_physwakeup(struct buf *bp);
static int aio_fphysio(struct proc *p, struct aiocblist *aiocbe, int type);
static int aio_qphysio(struct proc *p, struct aiocblist *iocb);
static void aio_daemon(const void *uproc);
static void aio_daemon(void *uproc);
SYSINIT(aio, SI_SUB_VFS, SI_ORDER_ANY, aio_onceonly, NULL);
@ -598,7 +598,7 @@ aio_process(struct aiocblist *aiocbe)
* but the setup (and address space mgmt) is done in this routine.
*/
static void
aio_daemon(const void *uproc)
aio_daemon(void *uproc)
{
int s;
struct aioproclist *aiop;

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)vfs_subr.c 8.31 (Berkeley) 5/26/95
* $Id: vfs_subr.c,v 1.202 1999/06/16 23:27:32 mckusick Exp $
* $Id: vfs_subr.c,v 1.203 1999/06/26 02:46:10 mckusick Exp $
*/
/*
@ -50,6 +50,7 @@
#include <sys/fcntl.h>
#include <sys/kernel.h>
#include <sys/proc.h>
#include <sys/kthread.h>
#include <sys/malloc.h>
#include <sys/mount.h>
#include <sys/socket.h>
@ -907,12 +908,12 @@ vn_syncer_add_to_worklist(struct vnode *vp, int delay)
struct proc *updateproc;
static void sched_sync __P((void));
static const struct kproc_desc up_kp = {
static struct kproc_desc up_kp = {
"syncer",
sched_sync,
&updateproc
};
SYSINIT_KT(syncer, SI_SUB_KTHREAD_UPDATE, SI_ORDER_FIRST, kproc_start, &up_kp)
SYSINIT(syncer, SI_SUB_KTHREAD_UPDATE, SI_ORDER_FIRST, kproc_start, &up_kp)
/*
* System filesystem synchronizer daemon.

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)vfs_subr.c 8.31 (Berkeley) 5/26/95
* $Id: vfs_subr.c,v 1.202 1999/06/16 23:27:32 mckusick Exp $
* $Id: vfs_subr.c,v 1.203 1999/06/26 02:46:10 mckusick Exp $
*/
/*
@ -50,6 +50,7 @@
#include <sys/fcntl.h>
#include <sys/kernel.h>
#include <sys/proc.h>
#include <sys/kthread.h>
#include <sys/malloc.h>
#include <sys/mount.h>
#include <sys/socket.h>
@ -907,12 +908,12 @@ vn_syncer_add_to_worklist(struct vnode *vp, int delay)
struct proc *updateproc;
static void sched_sync __P((void));
static const struct kproc_desc up_kp = {
static struct kproc_desc up_kp = {
"syncer",
sched_sync,
&updateproc
};
SYSINIT_KT(syncer, SI_SUB_KTHREAD_UPDATE, SI_ORDER_FIRST, kproc_start, &up_kp)
SYSINIT(syncer, SI_SUB_KTHREAD_UPDATE, SI_ORDER_FIRST, kproc_start, &up_kp)
/*
* System filesystem synchronizer daemon.

View File

@ -38,7 +38,7 @@
*
* from: @(#)vm_machdep.c 7.3 (Berkeley) 5/13/91
* Utah $Hdr: vm_machdep.c 1.16.1.1 89/06/23$
* $Id: vm_machdep.c,v 1.15 1999/06/08 16:42:19 dt Exp $
* $Id: vm_machdep.c,v 1.16 1999/06/10 20:40:59 dt Exp $
*/
/*
* Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
@ -218,8 +218,8 @@ cpu_fork(p1, p2)
void
cpu_set_fork_handler(p, func, arg)
struct proc *p;
void (*func) __P((const void *));
const void *arg;
void (*func) __P((void *));
void *arg;
{
/*
* Note that the trap frame follows the args, so the function

View File

@ -38,7 +38,7 @@
*
* from: @(#)vm_machdep.c 7.3 (Berkeley) 5/13/91
* Utah $Hdr: vm_machdep.c 1.16.1.1 89/06/23$
* $Id: vm_machdep.c,v 1.15 1999/06/08 16:42:19 dt Exp $
* $Id: vm_machdep.c,v 1.16 1999/06/10 20:40:59 dt Exp $
*/
/*
* Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
@ -218,8 +218,8 @@ cpu_fork(p1, p2)
void
cpu_set_fork_handler(p, func, arg)
struct proc *p;
void (*func) __P((const void *));
const void *arg;
void (*func) __P((void *));
void *arg;
{
/*
* Note that the trap frame follows the args, so the function

View File

@ -39,7 +39,7 @@
* SUCH DAMAGE.
*
* @(#)kernel.h 8.3 (Berkeley) 1/21/94
* $Id: kernel.h,v 1.54 1999/04/17 08:36:06 peter Exp $
* $Id: kernel.h,v 1.55 1999/05/06 13:42:25 peter Exp $
*/
#ifndef _SYS_KERNEL_H_
@ -161,18 +161,6 @@ enum sysinit_elem_order {
};
/*
* System initialization call types; currently two are supported... one
* to do a simple function call and one to cause a process to be started
* by the kernel on the callers behalf.
*/
typedef enum sysinit_elem_type {
SI_TYPE_DEFAULT = 0x00000000, /* No special processing*/
SI_TYPE_KTHREAD = 0x00000001, /* start kernel thread*/
SI_TYPE_KPROCESS = 0x00000002 /* start kernel process*/
} si_elem_t;
/*
* A system initialization call instance
*
@ -204,7 +192,6 @@ struct sysinit {
unsigned int order; /* init order within subsystem*/
sysinit_cfunc_t func; /* function */
const void *udata; /* multiplexer/argument */
si_elem_t type; /* sysinit_elem_type*/
};
/*
@ -224,13 +211,13 @@ struct sysinit {
subsystem, \
order, \
func, \
ident, \
SI_TYPE_DEFAULT \
ident \
}; \
DATA_SET(sysinit_set,uniquifier ## _sys_init);
#define SYSINIT(uniquifier, subsystem, order, func, ident) \
C_SYSINIT(uniquifier, subsystem, order, (sysinit_cfunc_t)(sysinit_nfunc_t)func, (void *)ident)
C_SYSINIT(uniquifier, subsystem, order, \
(sysinit_cfunc_t)(sysinit_nfunc_t)func, (void *)ident)
/*
* Called on module unload: no special processing
@ -240,51 +227,14 @@ struct sysinit {
subsystem, \
order, \
func, \
ident, \
SI_TYPE_DEFAULT \
ident \
}; \
DATA_SET(sysuninit_set,uniquifier ## _sys_uninit)
#define SYSUNINIT(uniquifier, subsystem, order, func, ident) \
C_SYSUNINIT(uniquifier, subsystem, order, (sysinit_cfunc_t)(sysinit_nfunc_t)func, (void *)ident)
C_SYSUNINIT(uniquifier, subsystem, order, \
(sysinit_cfunc_t)(sysinit_nfunc_t)func, (void *)ident)
/*
* Call 'fork()' before calling '(*func)(ident)';
* for making a kernel 'thread' (or builtin process.)
*/
#define SYSINIT_KT(uniquifier, subsystem, order, func, ident) \
static struct sysinit uniquifier ## _sys_init = { \
subsystem, \
order, \
func, \
ident, \
SI_TYPE_KTHREAD \
}; \
DATA_SET(sysinit_set,uniquifier ## _sys_init);
#define SYSINIT_KP(uniquifier, subsystem, order, func, ident) \
static struct sysinit uniquifier ## _sys_init = { \
subsystem, \
order, \
func, \
ident, \
SI_TYPE_KPROCESS \
}; \
DATA_SET(sysinit_set,uniquifier ## _sys_init);
/*
* A kernel process descriptor; used to start "internal" daemons
*
* Note: global_procpp may be NULL for no global save area
*/
struct kproc_desc {
char *arg0; /* arg 0 (for 'ps' listing)*/
void (*func) __P((void)); /* "main" for kernel process*/
struct proc **global_procpp; /* ptr to proc ptr save area*/
};
void kproc_start __P((const void *udata));
void sysinit_add __P((struct sysinit **set));
/*

50
sys/sys/kthread.h Normal file
View File

@ -0,0 +1,50 @@
/*
* Copyright (c) 1999 Peter Wemm <peter@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#ifndef _SYS_KTHREAD_H_
#define _SYS_KTHREAD_H_
struct proc;
/*
* A kernel process descriptor; used to start "internal" daemons
*
* Note: global_procpp may be NULL for no global save area
*/
struct kproc_desc {
char *arg0; /* arg 0 (for 'ps' listing) */
void (*func) __P((void)); /* "main" for kernel process */
struct proc **global_procpp; /* ptr to proc ptr save area */
};
void kproc_start __P((const void *));
int kthread_create __P((void (*)(void *), void *, struct proc **,
const char *, ...)) __printflike(4, 5);
void kthread_exit __P((int)) __dead2;
#endif

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)proc.h 8.15 (Berkeley) 5/19/95
* $Id: proc.h,v 1.82 1999/06/28 09:14:18 peter Exp $
* $Id: proc.h,v 1.83 1999/06/30 15:33:41 peter Exp $
*/
#ifndef _SYS_PROC_H_
@ -398,8 +398,7 @@ void wakeup_one __P((void *chan));
void cpu_exit __P((struct proc *)) __dead2;
void exit1 __P((struct proc *, int)) __dead2;
void cpu_fork __P((struct proc *, struct proc *));
void cpu_set_fork_handler __P((struct proc *, void (*pc)(const void *),
const void *));
void cpu_set_fork_handler __P((struct proc *, void (*)(void *), void *));
int fork1 __P((struct proc *, int, struct proc **));
int trace_req __P((struct proc *));
void cpu_wait __P((struct proc *));

View File

@ -65,7 +65,7 @@
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*
* $Id: vm_pageout.c,v 1.141 1999/04/23 20:29:57 dt Exp $
* $Id: vm_pageout.c,v 1.142 1999/06/26 14:56:58 peter Exp $
*/
/*
@ -77,6 +77,7 @@
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/proc.h>
#include <sys/kthread.h>
#include <sys/resourcevar.h>
#include <sys/signalvar.h>
#include <sys/vnode.h>
@ -111,7 +112,7 @@ static struct kproc_desc page_kp = {
vm_pageout,
&pageproc
};
SYSINIT_KT(pagedaemon, SI_SUB_KTHREAD_PAGE, SI_ORDER_FIRST, kproc_start, &page_kp)
SYSINIT(pagedaemon, SI_SUB_KTHREAD_PAGE, SI_ORDER_FIRST, kproc_start, &page_kp)
#if !defined(NO_SWAPPING)
/* the kernel process "vm_daemon"*/
@ -123,7 +124,7 @@ static struct kproc_desc vm_kp = {
vm_daemon,
&vmproc
};
SYSINIT_KT(vmdaemon, SI_SUB_KTHREAD_VM, SI_ORDER_FIRST, kproc_start, &vm_kp)
SYSINIT(vmdaemon, SI_SUB_KTHREAD_VM, SI_ORDER_FIRST, kproc_start, &vm_kp)
#endif