-/* $OpenBSD: drm_linux.c,v 1.111 2024/03/20 02:42:17 jsg Exp $ */
+/* $OpenBSD: drm_linux.c,v 1.112 2024/03/30 13:33:20 mpi Exp $ */
/*
* Copyright (c) 2013 Jonathan Gray <jsg@openbsd.org>
* Copyright (c) 2015, 2016 Mark Kettenis <kettenis@openbsd.org>
int s, rv;
SCHED_LOCK(s);
- rv = wakeup_proc(p, NULL, 0);
+ rv = wakeup_proc(p, 0);
SCHED_UNLOCK(s);
return rv;
}
-/* $OpenBSD: kern_sig.c,v 1.322 2024/02/25 00:07:13 deraadt Exp $ */
+/* $OpenBSD: kern_sig.c,v 1.323 2024/03/30 13:33:20 mpi Exp $ */
/* $NetBSD: kern_sig.c,v 1.54 1996/04/22 01:38:32 christos Exp $ */
/*
if (p->p_usrpri > PUSER)
p->p_usrpri = PUSER;
run:
+ unsleep(p);
setrunnable(p);
out:
/* finally adjust siglist */
if (q->p_flag & P_WEXIT) {
if (mode == SINGLE_EXIT) {
if (q->p_stat == SSTOP) {
+ unsleep(q);
setrunnable(q);
atomic_inc_int(&pr->ps_singlecount);
}
break;
}
/* need to unwind or exit, so wake it */
+ unsleep(q);
setrunnable(q);
}
atomic_inc_int(&pr->ps_singlecount);
break;
case SSTOP:
if (mode == SINGLE_EXIT) {
+ unsleep(q);
setrunnable(q);
atomic_inc_int(&pr->ps_singlecount);
}
-/* $OpenBSD: kern_synch.c,v 1.200 2023/09/13 14:25:49 claudio Exp $ */
+/* $OpenBSD: kern_synch.c,v 1.201 2024/03/30 13:33:20 mpi Exp $ */
/* $NetBSD: kern_synch.c,v 1.37 1996/04/22 01:38:37 christos Exp $ */
/*
}
int
-wakeup_proc(struct proc *p, const volatile void *chan, int flags)
+wakeup_proc(struct proc *p, int flags)
{
int awakened = 0;
SCHED_ASSERT_LOCKED();
- if (p->p_wchan != NULL &&
- ((chan == NULL) || (p->p_wchan == chan))) {
+ if (p->p_wchan != NULL) {
awakened = 1;
if (flags)
atomic_setbits_int(&p->p_flag, flags);
- if (p->p_stat == SSLEEP)
- setrunnable(p);
- else if (p->p_stat == SSTOP)
- unsleep(p);
#ifdef DIAGNOSTIC
- else
- panic("wakeup: p_stat is %d", (int)p->p_stat);
+ if (p->p_stat != SSLEEP && p->p_stat != SSTOP)
+ panic("thread %d p_stat is %d", p->p_tid, p->p_stat);
#endif
+ unsleep(p);
+ if (p->p_stat == SSLEEP)
+ setrunnable(p);
}
return awakened;
int s;
SCHED_LOCK(s);
- wakeup_proc(p, NULL, P_TIMEOUT);
+ wakeup_proc(p, P_TIMEOUT);
SCHED_UNLOCK(s);
}
void
wakeup_n(const volatile void *ident, int n)
{
- struct slpque *qp;
+ struct slpque *qp, wakeq;
struct proc *p;
struct proc *pnext;
int s;
+ TAILQ_INIT(&wakeq);
+
SCHED_LOCK(s);
qp = &slpque[LOOKUP(ident)];
for (p = TAILQ_FIRST(qp); p != NULL && n != 0; p = pnext) {
pnext = TAILQ_NEXT(p, p_runq);
#ifdef DIAGNOSTIC
if (p->p_stat != SSLEEP && p->p_stat != SSTOP)
- panic("wakeup: p_stat is %d", (int)p->p_stat);
+ panic("thread %d p_stat is %d", p->p_tid, p->p_stat);
#endif
- if (wakeup_proc(p, ident, 0))
+ KASSERT(p->p_wchan != NULL);
+ if (p->p_wchan == ident) {
+ TAILQ_REMOVE(qp, p, p_runq);
+ p->p_wchan = NULL;
+ TAILQ_INSERT_TAIL(&wakeq, p, p_runq);
--n;
+ }
+ }
+ while ((p = TAILQ_FIRST(&wakeq))) {
+ TAILQ_REMOVE(&wakeq, p, p_runq);
+ TRACEPOINT(sched, unsleep, p->p_tid + THREAD_PID_OFFSET,
+ p->p_p->ps_pid);
+ if (p->p_stat == SSLEEP)
+ setrunnable(p);
}
SCHED_UNLOCK(s);
}
-/* $OpenBSD: sched_bsd.c,v 1.90 2024/01/24 19:23:38 cheloha Exp $ */
+/* $OpenBSD: sched_bsd.c,v 1.91 2024/03/30 13:33:20 mpi Exp $ */
/* $NetBSD: kern_synch.c,v 1.37 1996/04/22 01:38:37 christos Exp $ */
/*-
if ((pr->ps_flags & PS_TRACED) != 0 && pr->ps_xsig != 0)
atomic_setbits_int(&p->p_siglist, sigmask(pr->ps_xsig));
prio = p->p_usrpri;
- unsleep(p);
setrunqueue(NULL, p, prio);
break;
case SSLEEP:
prio = p->p_slppri;
- unsleep(p); /* e.g. when sending signals */
/* if not yet asleep, don't add to runqueue */
if (ISSET(p->p_flag, P_WSLEEP))
-/* $OpenBSD: sys_process.c,v 1.95 2023/11/21 14:00:13 bluhm Exp $ */
+/* $OpenBSD: sys_process.c,v 1.96 2024/03/30 13:33:20 mpi Exp $ */
/* $NetBSD: sys_process.c,v 1.55 1996/05/15 06:17:47 tls Exp $ */
/*-
if (t->p_stat == SSTOP) {
tr->ps_xsig = data;
SCHED_LOCK(s);
+ unsleep(t);
setrunnable(t);
SCHED_UNLOCK(s);
} else {
-/* $OpenBSD: proc.h,v 1.356 2024/02/03 18:51:58 beck Exp $ */
+/* $OpenBSD: proc.h,v 1.357 2024/03/30 13:33:21 mpi Exp $ */
/* $NetBSD: proc.h,v 1.44 1996/04/22 01:23:21 christos Exp $ */
/*-
void setpriority(struct proc *, uint32_t, uint8_t);
void setrunnable(struct proc *);
void endtsleep(void *);
-int wakeup_proc(struct proc *, const volatile void *, int);
+int wakeup_proc(struct proc *, int);
void unsleep(struct proc *);
void reaper(void *);
__dead void exit1(struct proc *, int, int, int);