Changeset View
Changeset View
Standalone View
Standalone View
head/sys/kern/kern_umtx.c
Show First 20 Lines • Show All 440 Lines • ▼ Show 20 Lines | #ifdef UMTX_PROFILING | ||||
umtxq_chains[i][j].max_length = 0; | umtxq_chains[i][j].max_length = 0; | ||||
#endif | #endif | ||||
} | } | ||||
} | } | ||||
#ifdef UMTX_PROFILING | #ifdef UMTX_PROFILING | ||||
umtx_init_profiling(); | umtx_init_profiling(); | ||||
#endif | #endif | ||||
mtx_init(&umtx_lock, "umtx lock", NULL, MTX_DEF); | mtx_init(&umtx_lock, "umtx lock", NULL, MTX_DEF); | ||||
EVENTHANDLER_REGISTER(process_exec, umtx_exec_hook, NULL, | |||||
EVENTHANDLER_PRI_ANY); | |||||
umtx_shm_init(); | umtx_shm_init(); | ||||
} | } | ||||
struct umtx_q * | struct umtx_q * | ||||
umtxq_alloc(void) | umtxq_alloc(void) | ||||
{ | { | ||||
struct umtx_q *uq; | struct umtx_q *uq; | ||||
▲ Show 20 Lines • Show All 3,892 Lines • ▼ Show 20 Lines | umtx_thread_alloc(struct thread *td) | ||||
KASSERT(uq->uq_pi_blocked == NULL, ("uq_pi_blocked != NULL")); | KASSERT(uq->uq_pi_blocked == NULL, ("uq_pi_blocked != NULL")); | ||||
KASSERT(TAILQ_EMPTY(&uq->uq_pi_contested), ("uq_pi_contested is not empty")); | KASSERT(TAILQ_EMPTY(&uq->uq_pi_contested), ("uq_pi_contested is not empty")); | ||||
} | } | ||||
/* | /* | ||||
* exec() hook. | * exec() hook. | ||||
* | * | ||||
* Clear robust lists for all process' threads, not delaying the | * Clear robust lists for all process' threads, not delaying the | ||||
* cleanup to thread_exit hook, since the relevant address space is | * cleanup to thread exit, since the relevant address space is | ||||
* destroyed right now. | * destroyed right now. | ||||
*/ | */ | ||||
static void | void | ||||
umtx_exec_hook(void *arg __unused, struct proc *p, | umtx_exec(struct proc *p) | ||||
struct image_params *imgp __unused) | |||||
{ | { | ||||
struct thread *td; | struct thread *td; | ||||
KASSERT(p == curproc, ("need curproc")); | KASSERT(p == curproc, ("need curproc")); | ||||
KASSERT((p->p_flag & P_HADTHREADS) == 0 || | KASSERT((p->p_flag & P_HADTHREADS) == 0 || | ||||
(p->p_flag & P_STOPPED_SINGLE) != 0, | (p->p_flag & P_STOPPED_SINGLE) != 0, | ||||
("curproc must be single-threaded")); | ("curproc must be single-threaded")); | ||||
/* | /* | ||||
* There is no need to lock the list as only this thread can be | * There is no need to lock the list as only this thread can be | ||||
* running. | * running. | ||||
*/ | */ | ||||
FOREACH_THREAD_IN_PROC(p, td) { | FOREACH_THREAD_IN_PROC(p, td) { | ||||
KASSERT(td == curthread || | KASSERT(td == curthread || | ||||
((td->td_flags & TDF_BOUNDARY) != 0 && TD_IS_SUSPENDED(td)), | ((td->td_flags & TDF_BOUNDARY) != 0 && TD_IS_SUSPENDED(td)), | ||||
("running thread %p %p", p, td)); | ("running thread %p %p", p, td)); | ||||
umtx_thread_cleanup(td); | umtx_thread_cleanup(td); | ||||
td->td_rb_list = td->td_rbp_list = td->td_rb_inact = 0; | td->td_rb_list = td->td_rbp_list = td->td_rb_inact = 0; | ||||
} | } | ||||
} | } | ||||
/* | /* | ||||
* thread_exit() hook. | * thread exit hook. | ||||
*/ | */ | ||||
void | void | ||||
umtx_thread_exit(struct thread *td) | umtx_thread_exit(struct thread *td) | ||||
{ | { | ||||
umtx_thread_cleanup(td); | umtx_thread_cleanup(td); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 139 Lines • Show Last 20 Lines |