P_HASSIBLING() using this count.
OK mvs@ mpi@
-/* $OpenBSD: kern_exit.c,v 1.210 2022/12/29 01:36:36 guenther Exp $ */
+/* $OpenBSD: kern_exit.c,v 1.211 2023/04/25 18:14:06 claudio Exp $ */
/* $NetBSD: kern_exit.c,v 1.39 1996/04/22 01:38:25 christos Exp $ */
/*
SCHED_LOCK(s);
TAILQ_REMOVE(&pr->ps_threads, p, p_thr_link);
SCHED_UNLOCK(s);
+
if ((p->p_flag & P_THREAD) == 0) {
/* main thread gotta wait because it has the pid, et al */
- while (pr->ps_refcnt > 1)
+ while (pr->ps_threadcnt > 1)
tsleep_nsec(&pr->ps_threads, PWAIT, "thrdeath", INFSLP);
if (pr->ps_flags & PS_PROFIL)
stopprofclock(pr);
/* just a thread? detach it from its process */
if (p->p_flag & P_THREAD) {
/* scheduler_wait_hook(pr->ps_mainproc, p); XXX */
- if (--pr->ps_refcnt == 1)
+ if (--pr->ps_threadcnt == 1)
wakeup(&pr->ps_threads);
- KASSERT(pr->ps_refcnt > 0);
+ KASSERT(pr->ps_threadcnt > 0);
}
/* Release the thread's read reference of resource limit structure. */
if (otvp)
vrele(otvp);
- KASSERT(pr->ps_refcnt == 1);
+ KASSERT(pr->ps_threadcnt == 1);
if (pr->ps_ptstat != NULL)
free(pr->ps_ptstat, M_SUBPROC, sizeof(*pr->ps_ptstat));
pool_put(&rusage_pool, pr->ps_ru);
-/* $OpenBSD: kern_fork.c,v 1.246 2023/02/10 14:34:17 visa Exp $ */
+/* $OpenBSD: kern_fork.c,v 1.247 2023/04/25 18:14:06 claudio Exp $ */
/* $NetBSD: kern_fork.c,v 1.29 1996/02/09 18:59:34 christos Exp $ */
/*
pr->ps_mainproc = p;
TAILQ_INIT(&pr->ps_threads);
TAILQ_INSERT_TAIL(&pr->ps_threads, p, p_thr_link);
- pr->ps_refcnt = 1;
+ pr->ps_threadcnt = 1;
p->p_p = pr;
/* give the process the same creds as the initial thread */
/* other links */
p->p_p = pr;
- pr->ps_refcnt++;
+ pr->ps_threadcnt++;
/* local copies */
p->p_fd = pr->ps_fd;
SCHED_LOCK(s);
TAILQ_INSERT_TAIL(&pr->ps_threads, p, p_thr_link);
+
/*
* if somebody else wants to take us to single threaded mode,
* count ourselves in.
-/* $OpenBSD: proc.h,v 1.339 2023/01/16 07:09:11 guenther Exp $ */
+/* $OpenBSD: proc.h,v 1.340 2023/04/25 18:14:06 claudio Exp $ */
/* $NetBSD: proc.h,v 1.44 1996/04/22 01:23:21 christos Exp $ */
/*-
#define BOGO_PC (u_long)-1
/* End area that is copied on creation. */
-#define ps_endcopy ps_refcnt
- int ps_refcnt; /* Number of references. */
+#define ps_endcopy ps_threadcnt
+ u_int ps_threadcnt; /* Number of threads. */
struct timespec ps_start; /* starting uptime. */
struct timeout ps_realit_to; /* [m] ITIMER_REAL timeout */
#define SONPROC 7 /* Thread is currently on a CPU. */
#define P_ZOMBIE(p) ((p)->p_stat == SDEAD)
-#define P_HASSIBLING(p) (TAILQ_FIRST(&(p)->p_p->ps_threads) != (p) || \
- TAILQ_NEXT((p), p_thr_link) != NULL)
+#define P_HASSIBLING(p) ((p)->p_p->ps_threadcnt > 1)
/*
* These flags are per-thread and kept in p_flag