Initialize and destroy the struct proc mutex in the proc zone's init and
fini routines instead of in fork() and wait(). This has the nice side benefit that the proc lock of any process on the allproc list is always valid and sched_lock doesn't have to be used to test against PRS_NEW anymore.
This commit is contained in:
parent
8716bb50e3
commit
9e17fca425
@ -685,7 +685,6 @@ loop:
|
|||||||
* release while still running in process context.
|
* release while still running in process context.
|
||||||
*/
|
*/
|
||||||
vm_waitproc(p);
|
vm_waitproc(p);
|
||||||
mtx_destroy(&p->p_mtx);
|
|
||||||
#ifdef MAC
|
#ifdef MAC
|
||||||
mac_destroy_proc(p);
|
mac_destroy_proc(p);
|
||||||
#endif
|
#endif
|
||||||
|
@ -447,6 +447,9 @@ again:
|
|||||||
if (pages != 0)
|
if (pages != 0)
|
||||||
pmap_new_altkstack(td2, pages);
|
pmap_new_altkstack(td2, pages);
|
||||||
|
|
||||||
|
PROC_LOCK(p2);
|
||||||
|
PROC_LOCK(p1);
|
||||||
|
|
||||||
#define RANGEOF(type, start, end) (offsetof(type, end) - offsetof(type, start))
|
#define RANGEOF(type, start, end) (offsetof(type, end) - offsetof(type, start))
|
||||||
|
|
||||||
bzero(&p2->p_startzero,
|
bzero(&p2->p_startzero,
|
||||||
@ -458,10 +461,6 @@ again:
|
|||||||
bzero(&kg2->kg_startzero,
|
bzero(&kg2->kg_startzero,
|
||||||
(unsigned) RANGEOF(struct ksegrp, kg_startzero, kg_endzero));
|
(unsigned) RANGEOF(struct ksegrp, kg_startzero, kg_endzero));
|
||||||
|
|
||||||
mtx_init(&p2->p_mtx, "process lock", NULL, MTX_DEF | MTX_DUPOK);
|
|
||||||
PROC_LOCK(p2);
|
|
||||||
PROC_LOCK(p1);
|
|
||||||
|
|
||||||
bcopy(&p1->p_startcopy, &p2->p_startcopy,
|
bcopy(&p1->p_startcopy, &p2->p_startcopy,
|
||||||
(unsigned) RANGEOF(struct proc, p_startcopy, p_endcopy));
|
(unsigned) RANGEOF(struct proc, p_startcopy, p_endcopy));
|
||||||
bcopy(&td->td_startcopy, &td2->td_startcopy,
|
bcopy(&td->td_startcopy, &td2->td_startcopy,
|
||||||
|
@ -194,6 +194,8 @@ proc_init(void *mem, int size)
|
|||||||
ke = kse_alloc();
|
ke = kse_alloc();
|
||||||
kg = ksegrp_alloc();
|
kg = ksegrp_alloc();
|
||||||
proc_linkup(p, kg, ke, td);
|
proc_linkup(p, kg, ke, td);
|
||||||
|
bzero(&p->p_mtx, sizeof(struct mtx));
|
||||||
|
mtx_init(&p->p_mtx, "process lock", NULL, MTX_DEF | MTX_DUPOK);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -220,6 +222,7 @@ proc_fini(void *mem, int size)
|
|||||||
thread_free(td);
|
thread_free(td);
|
||||||
ksegrp_free(kg);
|
ksegrp_free(kg);
|
||||||
kse_free(ke);
|
kse_free(ke);
|
||||||
|
mtx_destroy(&p->p_mtx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user