summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_kthread.c
diff options
context:
space:
mode:
authorjasone <jasone@FreeBSD.org>2000-09-07 01:33:02 +0000
committerjasone <jasone@FreeBSD.org>2000-09-07 01:33:02 +0000
commit769e0f974d8929599ba599ac496510fffc90ff34 (patch)
tree9387522900085835de81e7830e570ef3f6b3ea80 /sys/kern/kern_kthread.c
parentacf1927de02afda4855ec278b1128fd9446405ea (diff)
downloadFreeBSD-src-769e0f974d8929599ba599ac496510fffc90ff34.zip
FreeBSD-src-769e0f974d8929599ba599ac496510fffc90ff34.tar.gz
Major update to the way synchronization is done in the kernel. Highlights
include: * Mutual exclusion is used instead of spl*(). See mutex(9). (Note: The alpha port is still in transition and currently uses both.) * Per-CPU idle processes. * Interrupts are run in their own separate kernel threads and can be preempted (i386 only). Partially contributed by: BSDi (BSD/OS) Submissions by (at least): cp, dfr, dillon, grog, jake, jhb, sheldonh
Diffstat (limited to 'sys/kern/kern_kthread.c')
-rw-r--r--sys/kern/kern_kthread.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/sys/kern/kern_kthread.c b/sys/kern/kern_kthread.c
index 6373750..e684b78 100644
--- a/sys/kern/kern_kthread.c
+++ b/sys/kern/kern_kthread.c
@@ -52,24 +52,33 @@ kproc_start(udata)
int error;
error = kthread_create((void (*)(void *))kp->func, NULL,
- kp->global_procpp, kp->arg0);
+ kp->global_procpp, 0, 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
+ * Create a kernel process/thread/whatever. It shares its address space
* with proc0 - ie: kernel only.
+ *
+ * func is the function to start.
+ * arg is the parameter to pass to function on first startup.
+ * newpp is the return value pointing to the thread's struct proc.
+ * flags are flags to fork1 (in unistd.h)
+ * fmt and following will be *printf'd into (*newpp)->p_comm (for ps, etc.).
*/
int
kthread_create(void (*func)(void *), void *arg,
- struct proc **newpp, const char *fmt, ...)
+ struct proc **newpp, int flags, const char *fmt, ...)
{
int error;
va_list ap;
struct proc *p2;
- error = fork1(&proc0, RFMEM | RFFDG | RFPROC, &p2);
+ if (!proc0.p_stats /* || proc0.p_stats->p_start.tv_sec == 0 */)
+ panic("kthread_create called too soon");
+
+ error = fork1(&proc0, RFMEM | RFFDG | RFPROC | flags, &p2);
if (error)
return error;
OpenPOWER on IntegriCloud