kern_kthread.c (64529) | kern_kthread.c (65557) |
---|---|
1/* 2 * Copyright (c) 1999 Peter Wemm <peter@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * | 1/* 2 * Copyright (c) 1999 Peter Wemm <peter@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * |
26 * $FreeBSD: head/sys/kern/kern_kthread.c 64529 2000-08-11 09:05:12Z peter $ | 26 * $FreeBSD: head/sys/kern/kern_kthread.c 65557 2000-09-07 01:33:02Z jasone $ |
27 */ 28 29#include <sys/param.h> 30#include <sys/systm.h> 31#include <sys/proc.h> 32#include <sys/kthread.h> 33#include <sys/resourcevar.h> 34#include <sys/signalvar.h> --- 12 unchanged lines hidden (view full) --- 47void 48kproc_start(udata) 49 const void *udata; 50{ 51 const struct kproc_desc *kp = udata; 52 int error; 53 54 error = kthread_create((void (*)(void *))kp->func, NULL, | 27 */ 28 29#include <sys/param.h> 30#include <sys/systm.h> 31#include <sys/proc.h> 32#include <sys/kthread.h> 33#include <sys/resourcevar.h> 34#include <sys/signalvar.h> --- 12 unchanged lines hidden (view full) --- 47void 48kproc_start(udata) 49 const void *udata; 50{ 51 const struct kproc_desc *kp = udata; 52 int error; 53 54 error = kthread_create((void (*)(void *))kp->func, NULL, |
55 kp->global_procpp, kp->arg0); | 55 kp->global_procpp, 0, kp->arg0); |
56 if (error) 57 panic("kproc_start: %s: error %d", kp->arg0, error); 58} 59 60/* | 56 if (error) 57 panic("kproc_start: %s: error %d", kp->arg0, error); 58} 59 60/* |
61 * Create a kernel process/thread/whatever. It shares it's address space | 61 * Create a kernel process/thread/whatever. It shares its address space |
62 * with proc0 - ie: kernel only. | 62 * with proc0 - ie: kernel only. |
63 * 64 * func is the function to start. 65 * arg is the parameter to pass to function on first startup. 66 * newpp is the return value pointing to the thread's struct proc. 67 * flags are flags to fork1 (in unistd.h) 68 * fmt and following will be *printf'd into (*newpp)->p_comm (for ps, etc.). |
|
63 */ 64int 65kthread_create(void (*func)(void *), void *arg, | 69 */ 70int 71kthread_create(void (*func)(void *), void *arg, |
66 struct proc **newpp, const char *fmt, ...) | 72 struct proc **newpp, int flags, const char *fmt, ...) |
67{ 68 int error; 69 va_list ap; 70 struct proc *p2; 71 | 73{ 74 int error; 75 va_list ap; 76 struct proc *p2; 77 |
72 error = fork1(&proc0, RFMEM | RFFDG | RFPROC, &p2); | 78 if (!proc0.p_stats /* || proc0.p_stats->p_start.tv_sec == 0 */) 79 panic("kthread_create called too soon"); 80 81 error = fork1(&proc0, RFMEM | RFFDG | RFPROC | flags, &p2); |
73 if (error) 74 return error; 75 76 /* save a global descriptor, if desired */ 77 if (newpp != NULL) 78 *newpp = p2; 79 80 /* this is a non-swapped system process */ --- 60 unchanged lines hidden --- | 82 if (error) 83 return error; 84 85 /* save a global descriptor, if desired */ 86 if (newpp != NULL) 87 *newpp = p2; 88 89 /* this is a non-swapped system process */ --- 60 unchanged lines hidden --- |