Deleted Added
full compact
kern_intr.c (79003) kern_intr.c (81493)
1/*
2 * Copyright (c) 1997, Stefan Esser <se@freebsd.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 *
1/*
2 * Copyright (c) 1997, Stefan Esser <se@freebsd.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 *
26 * $FreeBSD: head/sys/kern/kern_intr.c 79003 2001-06-30 03:11:26Z jhb $
26 * $FreeBSD: head/sys/kern/kern_intr.c 81493 2001-08-10 22:53:32Z jhb $
27 *
28 */
29
30
31#include <sys/param.h>
32#include <sys/bus.h>
33#include <sys/rtprio.h>
34#include <sys/systm.h>

--- 331 unchanged lines hidden (view full) ---

366 KASSERT(p != NULL, ("ithread %s has no process", ithread->it_name));
367 CTR3(KTR_INTR, __func__ ": pid %d: (%s) need = %d", p->p_pid, p->p_comm,
368 ithread->it_need);
369
370 /*
371 * Set it_need to tell the thread to keep running if it is already
372 * running. Then, grab sched_lock and see if we actually need to
373 * put this thread on the runqueue. If so and the do_switch flag is
27 *
28 */
29
30
31#include <sys/param.h>
32#include <sys/bus.h>
33#include <sys/rtprio.h>
34#include <sys/systm.h>

--- 331 unchanged lines hidden (view full) ---

366 KASSERT(p != NULL, ("ithread %s has no process", ithread->it_name));
367 CTR3(KTR_INTR, __func__ ": pid %d: (%s) need = %d", p->p_pid, p->p_comm,
368 ithread->it_need);
369
370 /*
371 * Set it_need to tell the thread to keep running if it is already
372 * running. Then, grab sched_lock and see if we actually need to
373 * put this thread on the runqueue. If so and the do_switch flag is
374 * true, then switch to the ithread immediately. Otherwise, use
375 * need_resched() to guarantee that this ithread will run before any
374 * true, then switch to the ithread immediately. Otherwise, set the
375 * needresched flag to guarantee that this ithread will run before any
376 * userland processes.
377 */
378 ithread->it_need = 1;
379 mtx_lock_spin(&sched_lock);
380 if (p->p_stat == SWAIT) {
381 CTR1(KTR_INTR, __func__ ": setrunqueue %d", p->p_pid);
382 p->p_stat = SRUN;
383 setrunqueue(p);
384 if (do_switch && curproc->p_stat == SRUN) {
385 if (curproc != PCPU_GET(idleproc))
386 setrunqueue(curproc);
387 curproc->p_stats->p_ru.ru_nivcsw++;
388 mi_switch();
389 } else
376 * userland processes.
377 */
378 ithread->it_need = 1;
379 mtx_lock_spin(&sched_lock);
380 if (p->p_stat == SWAIT) {
381 CTR1(KTR_INTR, __func__ ": setrunqueue %d", p->p_pid);
382 p->p_stat = SRUN;
383 setrunqueue(p);
384 if (do_switch && curproc->p_stat == SRUN) {
385 if (curproc != PCPU_GET(idleproc))
386 setrunqueue(curproc);
387 curproc->p_stats->p_ru.ru_nivcsw++;
388 mi_switch();
389 } else
390 need_resched(curproc);
390 curproc->p_sflag |= PS_NEEDRESCHED;
391 } else {
392 CTR3(KTR_INTR, __func__ ": pid %d: it_need %d, state %d",
393 p->p_pid, ithread->it_need, p->p_stat);
394 }
395 mtx_unlock_spin(&sched_lock);
396
397 return (0);
398}

--- 254 unchanged lines hidden ---
391 } else {
392 CTR3(KTR_INTR, __func__ ": pid %d: it_need %d, state %d",
393 p->p_pid, ithread->it_need, p->p_stat);
394 }
395 mtx_unlock_spin(&sched_lock);
396
397 return (0);
398}

--- 254 unchanged lines hidden ---