Deleted Added
full compact
subr_sleepqueue.c (172155) subr_sleepqueue.c (173600)
1/*-
2 * Copyright (c) 2004 John Baldwin <jhb@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

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

55 * must consistently use the same lock to synchronize with a wait channel,
56 * though this check is currently only a warning for sleep/wakeup due to
57 * pre-existing abuse of that API. The same lock must also be held when
58 * awakening threads, though that is currently only enforced for condition
59 * variables.
60 */
61
62#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2004 John Baldwin <jhb@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

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

55 * must consistently use the same lock to synchronize with a wait channel,
56 * though this check is currently only a warning for sleep/wakeup due to
57 * pre-existing abuse of that API. The same lock must also be held when
58 * awakening threads, though that is currently only enforced for condition
59 * variables.
60 */
61
62#include <sys/cdefs.h>
63__FBSDID("$FreeBSD: head/sys/kern/subr_sleepqueue.c 172155 2007-09-13 09:12:36Z attilio $");
63__FBSDID("$FreeBSD: head/sys/kern/subr_sleepqueue.c 173600 2007-11-14 06:21:24Z julian $");
64
65#include "opt_sleepqueue_profiling.h"
66#include "opt_ddb.h"
67#include "opt_sched.h"
68
69#include <sys/param.h>
70#include <sys/systm.h>
71#include <sys/lock.h>

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

454
455 MPASS(td->td_sleepqueue == NULL);
456 sched_sleep(td);
457 TD_SET_SLEEPING(td);
458 SCHED_STAT_INC(switch_sleepq);
459 mi_switch(SW_VOL, NULL);
460 KASSERT(TD_IS_RUNNING(td), ("running but not TDS_RUNNING"));
461 CTR3(KTR_PROC, "sleepq resume: thread %p (pid %ld, %s)",
64
65#include "opt_sleepqueue_profiling.h"
66#include "opt_ddb.h"
67#include "opt_sched.h"
68
69#include <sys/param.h>
70#include <sys/systm.h>
71#include <sys/lock.h>

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

454
455 MPASS(td->td_sleepqueue == NULL);
456 sched_sleep(td);
457 TD_SET_SLEEPING(td);
458 SCHED_STAT_INC(switch_sleepq);
459 mi_switch(SW_VOL, NULL);
460 KASSERT(TD_IS_RUNNING(td), ("running but not TDS_RUNNING"));
461 CTR3(KTR_PROC, "sleepq resume: thread %p (pid %ld, %s)",
462 (void *)td, (long)td->td_proc->p_pid, (void *)td->td_proc->p_comm);
462 (void *)td, (long)td->td_proc->p_pid, (void *)td->td_name);
463}
464
465/*
466 * Check to see if we timed out.
467 */
468static int
469sleepq_check_timeout(void)
470{

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

645 /*
646 * Note that thread td might not be sleeping if it is running
647 * sleepq_catch_signals() on another CPU or is blocked on
648 * its proc lock to check signals. It doesn't hurt to clear
649 * the sleeping flag if it isn't set though, so we just always
650 * do it. However, we can't assert that it is set.
651 */
652 CTR3(KTR_PROC, "sleepq_wakeup: thread %p (pid %ld, %s)",
463}
464
465/*
466 * Check to see if we timed out.
467 */
468static int
469sleepq_check_timeout(void)
470{

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

645 /*
646 * Note that thread td might not be sleeping if it is running
647 * sleepq_catch_signals() on another CPU or is blocked on
648 * its proc lock to check signals. It doesn't hurt to clear
649 * the sleeping flag if it isn't set though, so we just always
650 * do it. However, we can't assert that it is set.
651 */
652 CTR3(KTR_PROC, "sleepq_wakeup: thread %p (pid %ld, %s)",
653 (void *)td, (long)td->td_proc->p_pid, td->td_proc->p_comm);
653 (void *)td, (long)td->td_proc->p_pid, td->td_name);
654 TD_CLR_SLEEPING(td);
655
656 /* Adjust priority if requested. */
657 MPASS(pri == -1 || (pri >= PRI_MIN && pri <= PRI_MAX));
658 if (pri != -1 && td->td_priority > pri)
659 sched_prio(td, pri);
660 setrunnable(td);
661}

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

767{
768 struct sleepqueue_chain *sc;
769 struct sleepqueue *sq;
770 struct thread *td;
771 void *wchan;
772
773 td = arg;
774 CTR3(KTR_PROC, "sleepq_timeout: thread %p (pid %ld, %s)",
654 TD_CLR_SLEEPING(td);
655
656 /* Adjust priority if requested. */
657 MPASS(pri == -1 || (pri >= PRI_MIN && pri <= PRI_MAX));
658 if (pri != -1 && td->td_priority > pri)
659 sched_prio(td, pri);
660 setrunnable(td);
661}

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

767{
768 struct sleepqueue_chain *sc;
769 struct sleepqueue *sq;
770 struct thread *td;
771 void *wchan;
772
773 td = arg;
774 CTR3(KTR_PROC, "sleepq_timeout: thread %p (pid %ld, %s)",
775 (void *)td, (long)td->td_proc->p_pid, (void *)td->td_proc->p_comm);
775 (void *)td, (long)td->td_proc->p_pid, (void *)td->td_name);
776
777 /*
778 * First, see if the thread is asleep and get the wait channel if
779 * it is.
780 */
781 thread_lock(td);
782 if (TD_IS_SLEEPING(td) && TD_ON_SLEEPQ(td)) {
783 wchan = td->td_wchan;

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

875 /*
876 * If the TDF_TIMEOUT flag is set, just leave. A
877 * timeout is scheduled anyhow.
878 */
879 if (td->td_flags & TDF_TIMEOUT)
880 return;
881
882 CTR3(KTR_PROC, "sleepq_abort: thread %p (pid %ld, %s)",
776
777 /*
778 * First, see if the thread is asleep and get the wait channel if
779 * it is.
780 */
781 thread_lock(td);
782 if (TD_IS_SLEEPING(td) && TD_ON_SLEEPQ(td)) {
783 wchan = td->td_wchan;

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

875 /*
876 * If the TDF_TIMEOUT flag is set, just leave. A
877 * timeout is scheduled anyhow.
878 */
879 if (td->td_flags & TDF_TIMEOUT)
880 return;
881
882 CTR3(KTR_PROC, "sleepq_abort: thread %p (pid %ld, %s)",
883 (void *)td, (long)td->td_proc->p_pid, (void *)td->td_proc->p_comm);
883 (void *)td, (long)td->td_proc->p_pid, (void *)td->td_name);
884 td->td_intrval = intrval;
885 td->td_flags |= TDF_SLEEPABORT;
886 /*
887 * If the thread has not slept yet it will find the signal in
888 * sleepq_catch_signals() and call sleepq_resume_thread. Otherwise
889 * we have to do it here.
890 */
891 if (!TD_IS_SLEEPING(td))

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

952 if (TAILQ_EMPTY(&sq->sq_blocked[i]))
953 db_printf("\tempty\n");
954 else
955 TAILQ_FOREACH(td, &sq->sq_blocked[0],
956 td_slpq) {
957 db_printf("\t%p (tid %d, pid %d, \"%s\")\n", td,
958 td->td_tid, td->td_proc->p_pid,
959 td->td_name[i] != '\0' ? td->td_name :
884 td->td_intrval = intrval;
885 td->td_flags |= TDF_SLEEPABORT;
886 /*
887 * If the thread has not slept yet it will find the signal in
888 * sleepq_catch_signals() and call sleepq_resume_thread. Otherwise
889 * we have to do it here.
890 */
891 if (!TD_IS_SLEEPING(td))

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

952 if (TAILQ_EMPTY(&sq->sq_blocked[i]))
953 db_printf("\tempty\n");
954 else
955 TAILQ_FOREACH(td, &sq->sq_blocked[0],
956 td_slpq) {
957 db_printf("\t%p (tid %d, pid %d, \"%s\")\n", td,
958 td->td_tid, td->td_proc->p_pid,
959 td->td_name[i] != '\0' ? td->td_name :
960 td->td_proc->p_comm);
960 td->td_name);
961 }
962 }
963}
964
965/* Alias 'show sleepqueue' to 'show sleepq'. */
966DB_SET(sleepqueue, db_show_sleepqueue, db_show_cmd_set, 0, NULL);
967#endif
961 }
962 }
963}
964
965/* Alias 'show sleepqueue' to 'show sleepq'. */
966DB_SET(sleepqueue, db_show_sleepqueue, db_show_cmd_set, 0, NULL);
967#endif