1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-15 10:17:20 +00:00

- Split the run queue and sleep queue linkage, so that a process

may block on a mutex while on the sleep queue without corrupting
it.
- Move dropping of Giant to after the acquire of sched_lock.

Tested by:	John Hay <jhay@icomtek.csir.co.za>
		jhb
This commit is contained in:
Jake Burkholder 2000-11-17 18:09:18 +00:00
parent 236a1916b4
commit 7da6f97772
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=68862
12 changed files with 22 additions and 18 deletions

View File

@ -120,8 +120,8 @@ userret(p, pc, oticks, have_giant)
* indicated by our priority.
*/
s = splstatclock();
DROP_GIANT_NOSWITCH();
mtx_enter(&sched_lock, MTX_SPIN);
DROP_GIANT_NOSWITCH();
setrunqueue(p);
p->p_stats->p_ru.ru_nivcsw++;
mi_switch();

View File

@ -192,8 +192,8 @@ userret(p, frame, oticks, have_giant)
* our priority.
*/
s = splhigh();
DROP_GIANT_NOSWITCH();
mtx_enter(&sched_lock, MTX_SPIN);
DROP_GIANT_NOSWITCH();
setrunqueue(p);
p->p_stats->p_ru.ru_nivcsw++;
mi_switch();

View File

@ -192,8 +192,8 @@ userret(p, frame, oticks, have_giant)
* our priority.
*/
s = splhigh();
DROP_GIANT_NOSWITCH();
mtx_enter(&sched_lock, MTX_SPIN);
DROP_GIANT_NOSWITCH();
setrunqueue(p);
p->p_stats->p_ru.ru_nivcsw++;
mi_switch();

View File

@ -102,8 +102,8 @@ userret(register struct proc *p, u_int64_t pc, u_quad_t oticks, int have_giant)
* indicated by our priority.
*/
s = splstatclock();
DROP_GIANT_NOSWITCH();
mtx_enter(&sched_lock, MTX_SPIN);
DROP_GIANT_NOSWITCH();
setrunqueue(p);
p->p_stats->p_ru.ru_nivcsw++;
mi_switch();

View File

@ -718,6 +718,7 @@ static char *dup_list[] = {
};
static char *sleep_list[] = {
"Giant",
NULL
};

View File

@ -1283,8 +1283,8 @@ issignal(p)
psignal(p->p_pptr, SIGCHLD);
do {
stop(p);
DROP_GIANT_NOSWITCH();
mtx_enter(&sched_lock, MTX_SPIN);
DROP_GIANT_NOSWITCH();
mi_switch();
mtx_exit(&sched_lock, MTX_SPIN);
PICKUP_GIANT();
@ -1356,8 +1356,8 @@ issignal(p)
stop(p);
if ((p->p_pptr->p_procsig->ps_flag & PS_NOCLDSTOP) == 0)
psignal(p->p_pptr, SIGCHLD);
DROP_GIANT_NOSWITCH();
mtx_enter(&sched_lock, MTX_SPIN);
DROP_GIANT_NOSWITCH();
mi_switch();
mtx_exit(&sched_lock, MTX_SPIN);
PICKUP_GIANT();

View File

@ -377,8 +377,8 @@ uio_yield()
p = curproc;
s = splhigh();
DROP_GIANT_NOSWITCH();
mtx_enter(&sched_lock, MTX_SPIN);
DROP_GIANT_NOSWITCH();
p->p_priority = p->p_usrpri;
setrunqueue(p);
p->p_stats->p_ru.ru_nivcsw++;

View File

@ -420,9 +420,9 @@ msleep(ident, mtx, priority, wmesg, timo)
if (p && KTRPOINT(p, KTR_CSW))
ktrcsw(p->p_tracep, 1, 0);
#endif
DROP_GIANT_NOSWITCH();
WITNESS_SLEEP(0, mtx);
mtx_enter(&sched_lock, MTX_SPIN);
DROP_GIANT_NOSWITCH();
if (mtx != NULL) {
mtx_assert(mtx, MA_OWNED | MA_NOTRECURSED);
@ -461,7 +461,7 @@ msleep(ident, mtx, priority, wmesg, timo)
p->p_nativepri = p->p_priority;
CTR4(KTR_PROC, "msleep: proc %p (pid %d, %s), schedlock %p",
p, p->p_pid, p->p_comm, (void *) sched_lock.mtx_lock);
TAILQ_INSERT_TAIL(&slpque[LOOKUP(ident)], p, p_procq);
TAILQ_INSERT_TAIL(&slpque[LOOKUP(ident)], p, p_slpq);
if (timo)
thandle = timeout(endtsleep, (void *)p, timo);
/*
@ -583,7 +583,7 @@ asleep(void *ident, int priority, const char *wmesg, int timo)
p->p_slptime = 0;
p->p_asleep.as_priority = priority;
p->p_asleep.as_timo = timo;
TAILQ_INSERT_TAIL(&slpque[LOOKUP(ident)], p, p_procq);
TAILQ_INSERT_TAIL(&slpque[LOOKUP(ident)], p, p_slpq);
}
mtx_exit(&sched_lock, MTX_SPIN);
@ -612,9 +612,9 @@ mawait(struct mtx *mtx, int priority, int timo)
int s;
WITNESS_SAVE_DECL(mtx);
DROP_GIANT_NOSWITCH();
WITNESS_SLEEP(0, mtx);
mtx_enter(&sched_lock, MTX_SPIN);
DROP_GIANT_NOSWITCH();
if (mtx != NULL) {
mtx_assert(mtx, MA_OWNED | MA_NOTRECURSED);
WITNESS_SAVE(mtx, mtx);
@ -778,7 +778,7 @@ unsleep(p)
s = splhigh();
mtx_enter(&sched_lock, MTX_SPIN);
if (p->p_wchan) {
TAILQ_REMOVE(&slpque[LOOKUP(p->p_wchan)], p, p_procq);
TAILQ_REMOVE(&slpque[LOOKUP(p->p_wchan)], p, p_slpq);
p->p_wchan = 0;
}
mtx_exit(&sched_lock, MTX_SPIN);
@ -800,9 +800,9 @@ wakeup(ident)
mtx_enter(&sched_lock, MTX_SPIN);
qp = &slpque[LOOKUP(ident)];
restart:
TAILQ_FOREACH(p, qp, p_procq) {
TAILQ_FOREACH(p, qp, p_slpq) {
if (p->p_wchan == ident) {
TAILQ_REMOVE(qp, p, p_procq);
TAILQ_REMOVE(qp, p, p_slpq);
p->p_wchan = 0;
if (p->p_stat == SSLEEP) {
/* OPTIMIZED EXPANSION OF setrunnable(p); */
@ -846,9 +846,9 @@ wakeup_one(ident)
mtx_enter(&sched_lock, MTX_SPIN);
qp = &slpque[LOOKUP(ident)];
TAILQ_FOREACH(p, qp, p_procq) {
TAILQ_FOREACH(p, qp, p_slpq) {
if (p->p_wchan == ident) {
TAILQ_REMOVE(qp, p, p_procq);
TAILQ_REMOVE(qp, p, p_slpq);
p->p_wchan = 0;
if (p->p_stat == SSLEEP) {
/* OPTIMIZED EXPANSION OF setrunnable(p); */

View File

@ -192,8 +192,8 @@ userret(p, frame, oticks, have_giant)
* our priority.
*/
s = splhigh();
DROP_GIANT_NOSWITCH();
mtx_enter(&sched_lock, MTX_SPIN);
DROP_GIANT_NOSWITCH();
setrunqueue(p);
p->p_stats->p_ru.ru_nivcsw++;
mi_switch();

View File

@ -718,6 +718,7 @@ static char *dup_list[] = {
};
static char *sleep_list[] = {
"Giant",
NULL
};

View File

@ -718,6 +718,7 @@ static char *dup_list[] = {
};
static char *sleep_list[] = {
"Giant",
NULL
};

View File

@ -127,7 +127,8 @@ struct mtx;
struct ithd;
struct proc {
TAILQ_ENTRY(proc) p_procq; /* run/sleep queue. */
TAILQ_ENTRY(proc) p_procq; /* run/mutex queue. */
TAILQ_ENTRY(proc) p_slpq; /* sleep queue. */
LIST_ENTRY(proc) p_list; /* List of all processes. */
/* substructures: */