Add thread_reap_barrier()
Reviewed by: hselasky,markj Sponsored by: Mellanox Technologies/NVidia Networking MFC after: 1 week Differential revision: https://reviews.freebsd.org/D30468
This commit is contained in:
parent
3a68546d23
commit
f62c7e54e9
@ -709,6 +709,38 @@ thread_reap_callout_cb(void *arg __unused)
|
|||||||
thread_reap_callout_cb, NULL);
|
thread_reap_callout_cb, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Calling this function guarantees that any thread that exited before
|
||||||
|
* the call is reaped when the function returns. By 'exited' we mean
|
||||||
|
* a thread removed from the process linkage with thread_unlink().
|
||||||
|
* Practically this means that caller must lock/unlock corresponding
|
||||||
|
* process lock before the call, to synchronize with thread_exit().
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
thread_reap_barrier(void)
|
||||||
|
{
|
||||||
|
struct thread *td;
|
||||||
|
struct task *t;
|
||||||
|
|
||||||
|
td = curthread;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* First do context switches to each CPU to ensure that all
|
||||||
|
* PCPU pc_deadthreads are moved to zombie list.
|
||||||
|
*/
|
||||||
|
quiesce_all_cpus("", PDROP);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Second, fire the task in the same thread as normal
|
||||||
|
* thread_reap() is done, to serialize reaping.
|
||||||
|
*/
|
||||||
|
t = malloc(sizeof(*t), M_TEMP, M_WAITOK);
|
||||||
|
TASK_INIT(t, 0, thread_reap_task_cb, t);
|
||||||
|
taskqueue_enqueue(taskqueue_thread, t);
|
||||||
|
taskqueue_drain(taskqueue_thread, t);
|
||||||
|
free(t, M_TEMP);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Allocate a thread.
|
* Allocate a thread.
|
||||||
*/
|
*/
|
||||||
|
@ -1189,6 +1189,7 @@ int thread_create(struct thread *td, struct rtprio *rtp,
|
|||||||
void thread_exit(void) __dead2;
|
void thread_exit(void) __dead2;
|
||||||
void thread_free(struct thread *td);
|
void thread_free(struct thread *td);
|
||||||
void thread_link(struct thread *td, struct proc *p);
|
void thread_link(struct thread *td, struct proc *p);
|
||||||
|
void thread_reap_barrier(void);
|
||||||
int thread_single(struct proc *p, int how);
|
int thread_single(struct proc *p, int how);
|
||||||
void thread_single_end(struct proc *p, int how);
|
void thread_single_end(struct proc *p, int how);
|
||||||
void thread_stash(struct thread *td);
|
void thread_stash(struct thread *td);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user