diff options
author | Philip Guenther <guenther@cvs.openbsd.org> | 2017-02-12 04:55:09 +0000 |
---|---|---|
committer | Philip Guenther <guenther@cvs.openbsd.org> | 2017-02-12 04:55:09 +0000 |
commit | 89043ff36c6d6b7d281d035919b813f9866d1e68 (patch) | |
tree | 876e1797e6617d45dc347d704757015e0635dd5b /sys/arch/amd64 | |
parent | 68a5515f6186c6c1d00d6abe9453463fbdc66c99 (diff) |
Split up fork1():
- FORK_THREAD handling is a totally separate function, thread_fork(),
that is only used by sys___tfork() and which loses the flags, func,
arg, and newprocp parameters and gains tcb parameter to guarantee
the new thread's TCB is set before the creating thread returns
- fork1() loses its stack and tidptr parameters
Common bits factor out:
- struct proc allocation and initialization moves to thread_new()
- maxthread handling moves to fork_check_maxthread()
- setting the new thread running moves to fork_thread_start()
The MD cpu_fork() function swaps its unused stacksize parameter for
a tcb parameter.
luna88k testing by aoyama@, alpha testing by dlg@
ok mpi@
Diffstat (limited to 'sys/arch/amd64')
-rw-r--r-- | sys/arch/amd64/amd64/vm_machdep.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/sys/arch/amd64/amd64/vm_machdep.c b/sys/arch/amd64/amd64/vm_machdep.c index 2b402e5ec74..42dc47f92ea 100644 --- a/sys/arch/amd64/amd64/vm_machdep.c +++ b/sys/arch/amd64/amd64/vm_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm_machdep.c,v 1.35 2016/04/03 19:49:35 guenther Exp $ */ +/* $OpenBSD: vm_machdep.c,v 1.36 2017/02/12 04:55:08 guenther Exp $ */ /* $NetBSD: vm_machdep.c,v 1.1 2003/04/26 18:39:33 fvdl Exp $ */ /*- @@ -66,10 +66,10 @@ void setredzone(struct proc *); * Finish a fork operation, with process p2 nearly set up. * Copy and update the kernel stack and pcb, making the child * ready to run, and marking it so that it can return differently - * than the parent. Returns 1 in the child process, 0 in the parent. + * than the parent. */ void -cpu_fork(struct proc *p1, struct proc *p2, void *stack, size_t stacksize, +cpu_fork(struct proc *p1, struct proc *p2, void *stack, void *tcb, void (*func)(void *), void *arg) { struct pcb *pcb = &p2->p_addr->u_pcb; @@ -112,10 +112,12 @@ cpu_fork(struct proc *p1, struct proc *p2, void *stack, size_t stacksize, setredzone(p2); /* - * If specified, give the child a different stack. + * If specified, give the child a different stack and/or TCB */ if (stack != NULL) - tf->tf_rsp = (u_int64_t)stack + stacksize; + tf->tf_rsp = (u_int64_t)stack; + if (tcb != NULL) + pcb->pcb_fsbase = (u_int64_t)tcb; sf = (struct switchframe *)tf - 1; sf->sf_r12 = (u_int64_t)func; |