Deleted Added
full compact
kern_intr.c (131473) kern_intr.c (131481)
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

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

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
27#include <sys/cdefs.h>
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

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

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
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/kern/kern_intr.c 131473 2004-07-02 19:09:50Z jhb $");
28__FBSDID("$FreeBSD: head/sys/kern/kern_intr.c 131481 2004-07-02 20:21:44Z jhb $");
29
30#include "opt_ddb.h"
31
32#include <sys/param.h>
33#include <sys/bus.h>
34#include <sys/conf.h>
35#include <sys/rtprio.h>
36#include <sys/systm.h>

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

360 msleep(handler, &ithread->it_lock, PUSER, "itrmh", 0);
361 ithread_update(ithread);
362 mtx_unlock(&ithread->it_lock);
363 free(handler, M_ITHREAD);
364 return (0);
365}
366
367int
29
30#include "opt_ddb.h"
31
32#include <sys/param.h>
33#include <sys/bus.h>
34#include <sys/conf.h>
35#include <sys/rtprio.h>
36#include <sys/systm.h>

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

360 msleep(handler, &ithread->it_lock, PUSER, "itrmh", 0);
361 ithread_update(ithread);
362 mtx_unlock(&ithread->it_lock);
363 free(handler, M_ITHREAD);
364 return (0);
365}
366
367int
368ithread_schedule(struct ithd *ithread, int do_switch)
368ithread_schedule(struct ithd *ithread)
369{
370 struct int_entropy entropy;
371 struct thread *td;
372 struct thread *ctd;
373 struct proc *p;
374
375 /*
376 * If no ithread or no handlers, then we have a stray interrupt.

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

394 p = td->td_proc;
395 KASSERT(p != NULL, ("ithread %s has no process", ithread->it_name));
396 CTR4(KTR_INTR, "%s: pid %d: (%s) need = %d",
397 __func__, p->p_pid, p->p_comm, ithread->it_need);
398
399 /*
400 * Set it_need to tell the thread to keep running if it is already
401 * running. Then, grab sched_lock and see if we actually need to
369{
370 struct int_entropy entropy;
371 struct thread *td;
372 struct thread *ctd;
373 struct proc *p;
374
375 /*
376 * If no ithread or no handlers, then we have a stray interrupt.

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

394 p = td->td_proc;
395 KASSERT(p != NULL, ("ithread %s has no process", ithread->it_name));
396 CTR4(KTR_INTR, "%s: pid %d: (%s) need = %d",
397 __func__, p->p_pid, p->p_comm, ithread->it_need);
398
399 /*
400 * Set it_need to tell the thread to keep running if it is already
401 * running. Then, grab sched_lock and see if we actually need to
402 * put this thread on the runqueue. If so and the do_switch flag is
403 * true and it is safe to switch, then switch to the ithread
404 * immediately. Otherwise, set the needresched flag to guarantee
405 * that this ithread will run before any userland processes.
402 * put this thread on the runqueue.
406 */
407 ithread->it_need = 1;
408 mtx_lock_spin(&sched_lock);
409 if (TD_AWAITING_INTR(td)) {
410 CTR2(KTR_INTR, "%s: setrunqueue %d", __func__, p->p_pid);
411 TD_CLR_IWAIT(td);
412 setrunqueue(td);
403 */
404 ithread->it_need = 1;
405 mtx_lock_spin(&sched_lock);
406 if (TD_AWAITING_INTR(td)) {
407 CTR2(KTR_INTR, "%s: setrunqueue %d", __func__, p->p_pid);
408 TD_CLR_IWAIT(td);
409 setrunqueue(td);
413 if (do_switch &&
414 (ctd->td_critnest == 1) ) {
415 KASSERT((TD_IS_RUNNING(ctd)),
416 ("ithread_schedule: Bad state for curthread."));
417 if (ctd->td_flags & TDF_IDLETD)
418 ctd->td_state = TDS_CAN_RUN; /* XXXKSE */
419 mi_switch(SW_INVOL, NULL);
420 } else {
421 curthread->td_flags |= TDF_NEEDRESCHED;
422 }
423 } else {
424 CTR4(KTR_INTR, "%s: pid %d: it_need %d, state %d",
425 __func__, p->p_pid, ithread->it_need, td->td_state);
426 }
427 mtx_unlock_spin(&sched_lock);
428
429 return (0);
430}

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

475
476 /*
477 * Set ih_need for this handler so that if the ithread is already
478 * running it will execute this handler on the next pass. Otherwise,
479 * it will execute it the next time it runs.
480 */
481 atomic_store_rel_int(&ih->ih_need, 1);
482 if (!(flags & SWI_DELAY)) {
410 } else {
411 CTR4(KTR_INTR, "%s: pid %d: it_need %d, state %d",
412 __func__, p->p_pid, ithread->it_need, td->td_state);
413 }
414 mtx_unlock_spin(&sched_lock);
415
416 return (0);
417}

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

462
463 /*
464 * Set ih_need for this handler so that if the ithread is already
465 * running it will execute this handler on the next pass. Otherwise,
466 * it will execute it the next time it runs.
467 */
468 atomic_store_rel_int(&ih->ih_need, 1);
469 if (!(flags & SWI_DELAY)) {
483 error = ithread_schedule(it, !cold && !dumping);
470 error = ithread_schedule(it);
484 KASSERT(error == 0, ("stray software interrupt"));
485 }
486}
487
488/*
489 * This is the main code for interrupt threads.
490 */
491static void

--- 343 unchanged lines hidden ---
471 KASSERT(error == 0, ("stray software interrupt"));
472 }
473}
474
475/*
476 * This is the main code for interrupt threads.
477 */
478static void

--- 343 unchanged lines hidden ---