We have had support for running the kernel daemons as threads for

quite a while, but forgot to do so.  For now, this code supports
most daemons  running as kernel threads in UP kernels, and as
full processes in SMP.  We will soon be able to run them as
threads in SMP, but not yet.
This commit is contained in:
dyson 1997-12-12 04:00:59 +00:00
parent ebe8635b58
commit a68f4a7087
5 changed files with 44 additions and 12 deletions

View File

@ -39,7 +39,7 @@
* SUCH DAMAGE.
*
* @(#)init_main.c 8.9 (Berkeley) 1/21/94
* $Id: init_main.c,v 1.76 1997/11/25 07:07:41 julian Exp $
* $Id: init_main.c,v 1.77 1997/12/06 04:11:09 sef Exp $
*/
#include "opt_devfs.h"
@ -59,6 +59,7 @@
#include <sys/reboot.h>
#include <sys/sysproto.h>
#include <sys/vmmeter.h>
#include <sys/unistd.h>
#include <machine/cpu.h>
@ -194,6 +195,7 @@ main(framep)
* which will not return.
*/
for( sipp = (struct sysinit **)sysinit_set.ls_items; *sipp; sipp++) {
if( (*sipp)->subsystem == SI_SUB_DUMMY)
continue; /* skip dummy task(s)*/
@ -204,8 +206,17 @@ main(framep)
break;
case SI_TYPE_KTHREAD:
#if !defined(SMP)
/* kernel thread*/
if (fork(&proc0, NULL))
if (fork1(&proc0, RFMEM|RFFDG|RFPROC))
panic("fork kernel thread");
cpu_set_fork_handler(pfind(proc0.p_retval[0]),
(*sipp)->func, (*sipp)->udata);
break;
#endif
case SI_TYPE_KPROCESS:
if (fork1(&proc0, RFFDG|RFPROC))
panic("fork kernel process");
cpu_set_fork_handler(pfind(proc0.p_retval[0]),
(*sipp)->func, (*sipp)->udata);
@ -507,7 +518,7 @@ SYSINIT(retrofit, SI_SUB_ROOT_FDTAB, SI_ORDER_FIRST, xxx_vfs_root_fdtab, NULL)
*/
static void kthread_init __P((void *dummy));
SYSINIT_KT(init,SI_SUB_KTHREAD_INIT, SI_ORDER_FIRST, kthread_init, NULL)
SYSINIT_KP(init,SI_SUB_KTHREAD_INIT, SI_ORDER_FIRST, kthread_init, NULL)
extern void prepare_usermode __P((void));

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)kern_fork.c 8.6 (Berkeley) 4/8/94
* $Id: kern_fork.c,v 1.48 1997/11/06 19:29:09 phk Exp $
* $Id: kern_fork.c,v 1.49 1997/11/20 16:36:17 bde Exp $
*/
#include "opt_ktrace.h"
@ -68,8 +68,6 @@ static int fast_vfork = 1;
#endif
SYSCTL_INT(_kern, OID_AUTO, fast_vfork, CTLFLAG_RW, &fast_vfork, 0, "");
static int fork1 __P((struct proc *p, int flags));
/*
* These are the stuctures used to create a callout list for things to do
* when forking a process
@ -121,7 +119,7 @@ rfork(p, uap)
int nprocs = 1; /* process 0 */
static int nextpid = 0;
static int
int
fork1(p1, flags)
register struct proc *p1;
int flags;

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.3 1997/11/06 19:29:10 phk Exp $
* $Id: kern_linker.c,v 1.4 1997/11/20 20:07:45 bde Exp $
*/
#include <sys/param.h>
@ -37,6 +37,7 @@
#include <machine/cpu.h>
#include <sys/module.h>
#include <sys/linker.h>
#include <sys/unistd.h>
linker_file_t linker_current_file;
@ -129,8 +130,18 @@ linker_file_sysinit(linker_file_t lf)
break;
case SI_TYPE_KTHREAD:
#if !defined(SMP)
/* kernel thread*/
if (fork(&proc0, NULL))
if (fork1(&proc0, RFFDG|RFPROC|RFMEM))
panic("fork kernel thread");
cpu_set_fork_handler(pfind(proc0.p_retval[0]),
(*sipp)->func, (*sipp)->udata);
break;
#endif
case SI_TYPE_KPROCESS:
/* kernel thread*/
if (fork1(&proc0, RFFDG|RFPROC))
panic("fork kernel process");
cpu_set_fork_handler(pfind(proc0.p_retval[0]),
(*sipp)->func, (*sipp)->udata);

View File

@ -39,7 +39,7 @@
* SUCH DAMAGE.
*
* @(#)kernel.h 8.3 (Berkeley) 1/21/94
* $Id: kernel.h,v 1.34 1997/09/21 22:09:11 gibbs Exp $
* $Id: kernel.h,v 1.35 1997/11/18 07:23:40 bde Exp $
*/
#ifndef _SYS_KERNEL_H_
@ -200,7 +200,8 @@ enum sysinit_elem_order {
*/
typedef enum sysinit_elem_type {
SI_TYPE_DEFAULT = 0x00000000, /* No special processing*/
SI_TYPE_KTHREAD = 0x00000001 /* start kernel thread*/
SI_TYPE_KTHREAD = 0x00000001, /* start kernel thread*/
SI_TYPE_KPROCESS = 0x00000002 /* start kernel process*/
} si_elem_t;
@ -245,6 +246,16 @@ struct sysinit {
}; \
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

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)proc.h 8.15 (Berkeley) 5/19/95
* $Id: proc.h,v 1.49 1997/11/25 07:07:48 julian Exp $
* $Id: proc.h,v 1.50 1997/12/06 04:11:14 sef Exp $
*/
#ifndef _SYS_PROC_H_
@ -338,6 +338,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 *));
int fork1 __P((struct proc *, int));
int trace_req __P((struct proc *));
void cpu_wait __P((struct proc *));
int cpu_coredump __P((struct proc *, struct vnode *, struct ucred *));