Lines Matching +full:proc +full:- +full:id
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
38 #include <sys/proc.h>
69 &max_threads_per_proc, 0, "Limit on threads per proc");
109 if (args->tid != NULL && suword_lwpid(args->tid, td->td_tid)) in thr_create_initthr()
112 return (set_mcontext(td, &args->ctx.uc_mcontext)); in thr_create_initthr()
117 /* ucontext_t *ctx, long *id, int flags */ in sys_thr_create()
122 if ((error = copyin(uap->ctx, &args.ctx, sizeof(args.ctx)))) in sys_thr_create()
124 args.tid = uap->id; in sys_thr_create()
135 if (uap->param_size < 0 || uap->param_size > sizeof(param)) in sys_thr_new()
138 if ((error = copyin(uap->param, ¶m, uap->param_size))) in sys_thr_new()
158 if ((param->child_tid != NULL && in thr_new_initthr()
159 suword_lwpid(param->child_tid, td->td_tid)) || in thr_new_initthr()
160 (param->parent_tid != NULL && in thr_new_initthr()
161 suword_lwpid(param->parent_tid, td->td_tid))) in thr_new_initthr()
165 stack.ss_sp = param->stack_base; in thr_new_initthr()
166 stack.ss_size = param->stack_size; in thr_new_initthr()
168 error = cpu_set_upcall(td, param->start_func, param->arg, &stack); in thr_new_initthr()
172 return (cpu_set_user_tls(td, param->tls_base)); in thr_new_initthr()
182 if (param->rtp != 0) { in kern_thr_new()
183 error = copyin(param->rtp, &rtp, sizeof(struct rtprio)); in kern_thr_new()
196 struct proc *p; in thread_create()
199 p = td->td_proc; in thread_create()
202 switch(rtp->type) { in thread_create()
208 if (rtp->prio > RTP_PRIO_MAX) in thread_create()
212 rtp->prio = 0; in thread_create()
234 bzero(&newtd->td_startzero, in thread_create()
236 bcopy(&td->td_startcopy, &newtd->td_startcopy, in thread_create()
238 newtd->td_proc = td->td_proc; in thread_create()
239 newtd->td_rb_list = newtd->td_rbp_list = newtd->td_rb_inact = 0; in thread_create()
252 p->p_flag |= P_HADTHREADS; in thread_create()
254 bcopy(p->p_comm, newtd->td_name, sizeof(newtd->td_name)); in thread_create()
261 if (p->p_ptevents & PTRACE_LWP) in thread_create()
262 newtd->td_dbgflags |= TDB_BORN; in thread_create()
275 if (rtp != NULL && !(td->td_pri_class == PRI_TIMESHARE && in thread_create()
276 rtp->type == RTP_PRIO_NORMAL)) in thread_create()
298 /* long *id */ in sys_thr_self()
302 error = suword_lwpid(uap->id, (unsigned)td->td_tid); in sys_thr_self()
303 if (error == -1) in sys_thr_self()
316 if ((void *)uap->state != NULL) { in sys_thr_exit()
317 (void)suword_lwpid(uap->state, 1); in sys_thr_exit()
318 (void)kern_umtx_wake(td, uap->state, INT_MAX, 0); in sys_thr_exit()
327 struct proc *p; in kern_thr_exit()
329 p = td->td_proc; in kern_thr_exit()
346 if (p->p_numthreads == p->p_pendingexits + 1) { in kern_thr_exit()
349 * proc. This will actually call _exit(2) in the in kern_thr_exit()
356 if (p->p_sysent->sv_ontdexit != NULL) in kern_thr_exit()
357 p->p_sysent->sv_ontdexit(td); in kern_thr_exit()
359 td->td_dbgflags |= TDB_EXIT; in kern_thr_exit()
360 if (p->p_ptevents & PTRACE_LWP) { in kern_thr_exit()
361 p->p_pendingexits++; in kern_thr_exit()
363 p->p_pendingexits--; in kern_thr_exit()
373 KASSERT(p->p_numthreads > 1, ("too few threads")); in kern_thr_exit()
389 /* long id, int sig */ in sys_thr_kill()
393 struct proc *p; in sys_thr_kill()
396 p = td->td_proc; in sys_thr_kill()
398 ksi.ksi_signo = uap->sig; in sys_thr_kill()
400 ksi.ksi_pid = p->p_pid; in sys_thr_kill()
401 ksi.ksi_uid = td->td_ucred->cr_ruid; in sys_thr_kill()
402 if (uap->id == -1) { in sys_thr_kill()
403 if (uap->sig != 0 && !_SIG_VALID(uap->sig)) { in sys_thr_kill()
411 if (uap->sig == 0) in sys_thr_kill()
413 tdksignal(ttd, uap->sig, &ksi); in sys_thr_kill()
420 ttd = tdfind((lwpid_t)uap->id, p->p_pid); in sys_thr_kill()
423 if (uap->sig == 0) in sys_thr_kill()
425 else if (!_SIG_VALID(uap->sig)) in sys_thr_kill()
428 tdksignal(ttd, uap->sig, &ksi); in sys_thr_kill()
429 PROC_UNLOCK(ttd->td_proc); in sys_thr_kill()
436 /* pid_t pid, long id, int sig */ in sys_thr_kill2()
440 struct proc *p; in sys_thr_kill2()
443 AUDIT_ARG_SIGNUM(uap->sig); in sys_thr_kill2()
446 ksi.ksi_signo = uap->sig; in sys_thr_kill2()
448 ksi.ksi_pid = td->td_proc->p_pid; in sys_thr_kill2()
449 ksi.ksi_uid = td->td_ucred->cr_ruid; in sys_thr_kill2()
450 if (uap->id == -1) { in sys_thr_kill2()
451 if ((p = pfind(uap->pid)) == NULL) in sys_thr_kill2()
454 error = p_cansignal(td, p, uap->sig); in sys_thr_kill2()
459 if (uap->sig != 0 && !_SIG_VALID(uap->sig)) { in sys_thr_kill2()
466 if (uap->sig == 0) in sys_thr_kill2()
468 tdksignal(ttd, uap->sig, &ksi); in sys_thr_kill2()
474 ttd = tdfind((lwpid_t)uap->id, uap->pid); in sys_thr_kill2()
477 p = ttd->td_proc; in sys_thr_kill2()
479 error = p_cansignal(td, p, uap->sig); in sys_thr_kill2()
480 if (uap->sig == 0) in sys_thr_kill2()
482 else if (!_SIG_VALID(uap->sig)) in sys_thr_kill2()
485 tdksignal(ttd, uap->sig, &ksi); in sys_thr_kill2()
499 if (uap->timeout != NULL) { in sys_thr_suspend()
500 error = umtx_copyin_timeout(uap->timeout, &ts); in sys_thr_suspend()
512 struct proc *p = td->td_proc; in kern_thr_suspend()
517 if (td->td_pflags & TDP_WAKEUP) { in kern_thr_suspend()
518 td->td_pflags &= ~TDP_WAKEUP; in kern_thr_suspend()
523 if (tsp->tv_sec == 0 && tsp->tv_nsec == 0) in kern_thr_suspend()
532 if (error == 0 && (td->td_flags & TDF_THRWAKEUP) == 0) in kern_thr_suspend()
533 error = msleep((void *)td, &p->p_mtx, in kern_thr_suspend()
536 if (td->td_flags & TDF_THRWAKEUP) { in kern_thr_suspend()
538 td->td_flags &= ~TDF_THRWAKEUP; in kern_thr_suspend()
555 /* long id */ in sys_thr_wake()
557 struct proc *p; in sys_thr_wake()
560 if (uap->id == td->td_tid) { in sys_thr_wake()
561 td->td_pflags |= TDP_WAKEUP; in sys_thr_wake()
565 p = td->td_proc; in sys_thr_wake()
566 ttd = tdfind((lwpid_t)uap->id, p->p_pid); in sys_thr_wake()
570 ttd->td_flags |= TDF_THRWAKEUP; in sys_thr_wake()
580 struct proc *p; in sys_thr_set_name()
587 if (uap->name != NULL) { in sys_thr_set_name()
588 error = copyinstr(uap->name, name, sizeof(name), NULL); in sys_thr_set_name()
590 error = copyin(uap->name, name, sizeof(name) - 1); in sys_thr_set_name()
591 name[sizeof(name) - 1] = '\0'; in sys_thr_set_name()
596 p = td->td_proc; in sys_thr_set_name()
597 ttd = tdfind((lwpid_t)uap->id, p->p_pid); in sys_thr_set_name()
600 strcpy(ttd->td_name, name); in sys_thr_set_name()
613 kern_thr_alloc(struct proc *p, int pages, struct thread **ntd) in kern_thr_alloc()
617 if (p->p_numthreads >= max_threads_per_proc) { in kern_thr_alloc()