\hypertarget{subr__sleepqueue_8c_source}{}\doxysection{subr\+\_\+sleepqueue.\+c}
\label{subr__sleepqueue_8c_source}\index{kern/subr\_sleepqueue.c@{kern/subr\_sleepqueue.c}}
\mbox{\hyperlink{subr__sleepqueue_8c}{Go to the documentation of this file.}}
\begin{DoxyCode}{0}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00001}00001 \textcolor{comment}{/*-\/}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00002}00002 \textcolor{comment}{ * SPDX-\/License-\/Identifier: BSD-\/2-\/Clause-\/FreeBSD}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00003}00003 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00004}00004 \textcolor{comment}{ * Copyright (c) 2004 John Baldwin <jhb@FreeBSD.org>}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00005}00005 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00006}00006 \textcolor{comment}{ * Redistribution and use in source and binary forms, with or without}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00007}00007 \textcolor{comment}{ * modification, are permitted provided that the following conditions}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00008}00008 \textcolor{comment}{ * are met:}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00009}00009 \textcolor{comment}{ * 1. Redistributions of source code must retain the above copyright}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00010}00010 \textcolor{comment}{ *    notice, this list of conditions and the following disclaimer.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00011}00011 \textcolor{comment}{ * 2. Redistributions in binary form must reproduce the above copyright}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00012}00012 \textcolor{comment}{ *    notice, this list of conditions and the following disclaimer in the}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00013}00013 \textcolor{comment}{ *    documentation and/or other materials provided with the distribution.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00014}00014 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00015}00015 \textcolor{comment}{ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00016}00016 \textcolor{comment}{ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00017}00017 \textcolor{comment}{ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00018}00018 \textcolor{comment}{ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00019}00019 \textcolor{comment}{ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00020}00020 \textcolor{comment}{ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00021}00021 \textcolor{comment}{ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00022}00022 \textcolor{comment}{ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00023}00023 \textcolor{comment}{ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00024}00024 \textcolor{comment}{ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00025}00025 \textcolor{comment}{ * SUCH DAMAGE.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00026}00026 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00027}00027 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00028}00028 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00029}00029 \textcolor{comment}{ * Implementation of sleep queues used to hold queue of threads blocked on}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00030}00030 \textcolor{comment}{ * a wait channel.  Sleep queues are different from turnstiles in that wait}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00031}00031 \textcolor{comment}{ * channels are not owned by anyone, so there is no priority propagation.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00032}00032 \textcolor{comment}{ * Sleep queues can also provide a timeout and can also be interrupted by}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00033}00033 \textcolor{comment}{ * signals.  That said, there are several similarities between the turnstile}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00034}00034 \textcolor{comment}{ * and sleep queue implementations.  (Note: turnstiles were implemented}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00035}00035 \textcolor{comment}{ * first.)  For example, both use a hash table of the same size where each}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00036}00036 \textcolor{comment}{ * bucket is referred to as a "{}chain"{} that contains both a spin lock and}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00037}00037 \textcolor{comment}{ * a linked list of queues.  An individual queue is located by using a hash}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00038}00038 \textcolor{comment}{ * to pick a chain, locking the chain, and then walking the chain searching}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00039}00039 \textcolor{comment}{ * for the queue.  This means that a wait channel object does not need to}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00040}00040 \textcolor{comment}{ * embed its queue head just as locks do not embed their turnstile queue}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00041}00041 \textcolor{comment}{ * head.  Threads also carry around a sleep queue that they lend to the}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00042}00042 \textcolor{comment}{ * wait channel when blocking.  Just as in turnstiles, the queue includes}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00043}00043 \textcolor{comment}{ * a free list of the sleep queues of other threads blocked on the same}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00044}00044 \textcolor{comment}{ * wait channel in the case of multiple waiters.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00045}00045 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00046}00046 \textcolor{comment}{ * Some additional functionality provided by sleep queues include the}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00047}00047 \textcolor{comment}{ * ability to set a timeout.  The timeout is managed using a per-\/thread}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00048}00048 \textcolor{comment}{ * callout that resumes a thread if it is asleep.  A thread may also}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00049}00049 \textcolor{comment}{ * catch signals while it is asleep (aka an interruptible sleep).  The}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00050}00050 \textcolor{comment}{ * signal code uses sleepq\_abort() to interrupt a sleeping thread.  Finally,}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00051}00051 \textcolor{comment}{ * sleep queues also provide some extra assertions.  One is not allowed to}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00052}00052 \textcolor{comment}{ * mix the sleep/wakeup and cv APIs for a given wait channel.  Also, one}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00053}00053 \textcolor{comment}{ * must consistently use the same lock to synchronize with a wait channel,}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00054}00054 \textcolor{comment}{ * though this check is currently only a warning for sleep/wakeup due to}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00055}00055 \textcolor{comment}{ * pre-\/existing abuse of that API.  The same lock must also be held when}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00056}00056 \textcolor{comment}{ * awakening threads, though that is currently only enforced for condition}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00057}00057 \textcolor{comment}{ * variables.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00058}00058 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00059}00059 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00060}00060 \textcolor{preprocessor}{\#include <sys/cdefs.h>}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00061}\mbox{\hyperlink{subr__sleepqueue_8c_a8c3ef283470a68cd30afe9b8a72cb60f}{00061}} \mbox{\hyperlink{subr__sleepqueue_8c_a8c3ef283470a68cd30afe9b8a72cb60f}{\_\_FBSDID}}(\textcolor{stringliteral}{"{}\$FreeBSD\$"{}});}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00062}00062 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00063}00063 \textcolor{preprocessor}{\#include "{}opt\_sleepqueue\_profiling.h"{}}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00064}00064 \textcolor{preprocessor}{\#include "{}opt\_ddb.h"{}}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00065}00065 \textcolor{preprocessor}{\#include "{}opt\_sched.h"{}}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00066}00066 \textcolor{preprocessor}{\#include "{}opt\_stack.h"{}}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00067}00067 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00068}00068 \textcolor{preprocessor}{\#include <sys/param.h>}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00069}00069 \textcolor{preprocessor}{\#include <sys/systm.h>}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00070}00070 \textcolor{preprocessor}{\#include <sys/lock.h>}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00071}00071 \textcolor{preprocessor}{\#include <sys/kernel.h>}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00072}00072 \textcolor{preprocessor}{\#include <sys/ktr.h>}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00073}00073 \textcolor{preprocessor}{\#include <sys/mutex.h>}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00074}00074 \textcolor{preprocessor}{\#include <sys/proc.h>}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00075}00075 \textcolor{preprocessor}{\#include <sys/sbuf.h>}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00076}00076 \textcolor{preprocessor}{\#include <sys/sched.h>}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00077}00077 \textcolor{preprocessor}{\#include <sys/sdt.h>}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00078}00078 \textcolor{preprocessor}{\#include <sys/signalvar.h>}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00079}00079 \textcolor{preprocessor}{\#include <sys/sleepqueue.h>}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00080}00080 \textcolor{preprocessor}{\#include <sys/stack.h>}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00081}00081 \textcolor{preprocessor}{\#include <sys/sysctl.h>}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00082}00082 \textcolor{preprocessor}{\#include <sys/time.h>}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00083}00083 \textcolor{preprocessor}{\#ifdef EPOCH\_TRACE}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00084}00084 \textcolor{preprocessor}{\#include <sys/epoch.h>}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00085}00085 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00086}00086 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00087}00087 \textcolor{preprocessor}{\#include <machine/atomic.h>}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00088}00088 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00089}00089 \textcolor{preprocessor}{\#include <vm/uma.h>}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00090}00090 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00091}00091 \textcolor{preprocessor}{\#ifdef DDB}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00092}00092 \textcolor{preprocessor}{\#include <ddb/ddb.h>}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00093}00093 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00094}00094 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00095}00095 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00096}00096 \textcolor{comment}{ * Constants for the hash table of sleep queue chains.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00097}00097 \textcolor{comment}{ * SC\_TABLESIZE must be a power of two for SC\_MASK to work properly.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00098}00098 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00099}00099 \textcolor{preprocessor}{\#ifndef SC\_TABLESIZE}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00100}\mbox{\hyperlink{subr__sleepqueue_8c_a9c9580acd9e79bc40e085bdf500210a4}{00100}} \textcolor{preprocessor}{\#define SC\_TABLESIZE    256}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00101}00101 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00102}\mbox{\hyperlink{subr__sleepqueue_8c_a714d98275691a7809b4102bf12f8986d}{00102}} \mbox{\hyperlink{subr__sleepqueue_8c_a9464b2e1b3e128b2bcf0d92b6529d799}{CTASSERT}}(powerof2(\mbox{\hyperlink{subr__sleepqueue_8c_a9c9580acd9e79bc40e085bdf500210a4}{SC\_TABLESIZE}}));}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00103}\mbox{\hyperlink{subr__sleepqueue_8c_a07ad4d8122995e60d77eb208da08dbee}{00103}} \textcolor{preprocessor}{\#define SC\_MASK         (SC\_TABLESIZE -\/ 1)}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00104}\mbox{\hyperlink{subr__sleepqueue_8c_a7e02b98bc0f594b44ac24cb9972bc37c}{00104}} \textcolor{preprocessor}{\#define SC\_SHIFT        8}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00105}\mbox{\hyperlink{subr__sleepqueue_8c_a8af60d8683dfa6e26b85c861652fee0d}{00105}} \textcolor{preprocessor}{\#define SC\_HASH(wc)     ((((uintptr\_t)(wc) >> SC\_SHIFT) \string^ (uintptr\_t)(wc)) \& \(\backslash\)}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00106}00106 \textcolor{preprocessor}{                            SC\_MASK)}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00107}\mbox{\hyperlink{subr__sleepqueue_8c_aed1c1c8de67981699a715d02955c624c}{00107}} \textcolor{preprocessor}{\#define SC\_LOOKUP(wc)   \&sleepq\_chains[SC\_HASH(wc)]}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00108}\mbox{\hyperlink{subr__sleepqueue_8c_a51b446e9977c5c46691e73f05d9b9308}{00108}} \textcolor{preprocessor}{\#define NR\_SLEEPQS      2}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00109}00109 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00110}00110 \textcolor{comment}{ * There are two different lists of sleep queues.  Both lists are connected}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00111}00111 \textcolor{comment}{ * via the sq\_hash entries.  The first list is the sleep queue chain list}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00112}00112 \textcolor{comment}{ * that a sleep queue is on when it is attached to a wait channel.  The}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00113}00113 \textcolor{comment}{ * second list is the free list hung off of a sleep queue that is attached}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00114}00114 \textcolor{comment}{ * to a wait channel.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00115}00115 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00116}00116 \textcolor{comment}{ * Each sleep queue also contains the wait channel it is attached to, the}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00117}00117 \textcolor{comment}{ * list of threads blocked on that wait channel, flags specific to the}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00118}00118 \textcolor{comment}{ * wait channel, and the lock used to synchronize with a wait channel.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00119}00119 \textcolor{comment}{ * The flags are used to catch mismatches between the various consumers}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00120}00120 \textcolor{comment}{ * of the sleep queue API (e.g. sleep/wakeup and condition variables).}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00121}00121 \textcolor{comment}{ * The lock pointer is only used when invariants are enabled for various}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00122}00122 \textcolor{comment}{ * debugging checks.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00123}00123 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00124}00124 \textcolor{comment}{ * Locking key:}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00125}00125 \textcolor{comment}{ *  c -\/ sleep queue chain lock}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00126}00126 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00127}\mbox{\hyperlink{structsleepqueue}{00127}} \textcolor{keyword}{struct }\mbox{\hyperlink{structsleepqueue}{sleepqueue}} \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00128}\mbox{\hyperlink{structsleepqueue_a8afd5c01f6e71471d36a7270ff07ebe8}{00128}}         \textcolor{keyword}{struct }threadqueue \mbox{\hyperlink{structsleepqueue_a8afd5c01f6e71471d36a7270ff07ebe8}{sq\_blocked}}[\mbox{\hyperlink{subr__sleepqueue_8c_a51b446e9977c5c46691e73f05d9b9308}{NR\_SLEEPQS}}]; \textcolor{comment}{/* (c) Blocked threads. */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00129}\mbox{\hyperlink{structsleepqueue_a439a41f50ae79d9f7b33e2d0a1f468dd}{00129}}         u\_int \mbox{\hyperlink{structsleepqueue_a439a41f50ae79d9f7b33e2d0a1f468dd}{sq\_blockedcnt}}[\mbox{\hyperlink{subr__sleepqueue_8c_a51b446e9977c5c46691e73f05d9b9308}{NR\_SLEEPQS}}]; \textcolor{comment}{/* (c) N. of blocked threads. */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00130}00130         LIST\_ENTRY(\mbox{\hyperlink{structsleepqueue}{sleepqueue}}) sq\_hash;               \textcolor{comment}{/* (c) Chain and free list. */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00131}00131         \mbox{\hyperlink{kern__alq_8c_afc8bb74c7e13909590e320029ed68586}{LIST\_HEAD}}(, \mbox{\hyperlink{structsleepqueue}{sleepqueue}}) sq\_free;     \textcolor{comment}{/* (c) Free queues. */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00132}00132         \textcolor{keyword}{const} \textcolor{keywordtype}{void}      *sq\_wchan;              \textcolor{comment}{/* (c) Wait channel. */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00133}00133         \textcolor{keywordtype}{int}     sq\_type;                        \textcolor{comment}{/* (c) Queue type. */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00134}00134 \textcolor{preprocessor}{\#ifdef INVARIANTS}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00135}00135         \textcolor{keyword}{struct }lock\_object *sq\_lock;            \textcolor{comment}{/* (c) Associated lock. */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00136}00136 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00137}00137 \};}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00138}00138 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00139}\mbox{\hyperlink{structsleepqueue__chain}{00139}} \textcolor{keyword}{struct }\mbox{\hyperlink{structsleepqueue__chain}{sleepqueue\_chain}} \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00140}00140         \mbox{\hyperlink{kern__alq_8c_afc8bb74c7e13909590e320029ed68586}{LIST\_HEAD}}(, \mbox{\hyperlink{structsleepqueue}{sleepqueue}}) sc\_queues;   \textcolor{comment}{/* List of sleep queues. */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00141}00141         \textcolor{keyword}{struct }\mbox{\hyperlink{uipc__ktls_8c_a7b5de10a04be6deb16c42cef5da02110}{mtx}} sc\_lock;                  \textcolor{comment}{/* Spin lock for this chain. */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00142}00142 \textcolor{preprocessor}{\#ifdef SLEEPQUEUE\_PROFILING}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00143}00143         u\_int   sc\_depth;                       \textcolor{comment}{/* Length of sc\_queues. */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00144}00144         u\_int   sc\_max\_depth;                   \textcolor{comment}{/* Max length of sc\_queues. */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00145}00145 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00146}00146 \} \mbox{\hyperlink{subr__sleepqueue_8c_a714d98275691a7809b4102bf12f8986d}{\_\_aligned}}(CACHE\_LINE\_SIZE);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00147}00147 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00148}00148 \textcolor{preprocessor}{\#ifdef SLEEPQUEUE\_PROFILING}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00149}00149 \textcolor{keyword}{static} \mbox{\hyperlink{imgact__binmisc_8c_a745707e006bc5c9b6f81b78dfc5caadd}{SYSCTL\_NODE}}(\_debug, OID\_AUTO, sleepq, CTLFLAG\_RD | CTLFLAG\_MPSAFE, 0,}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00150}00150     \textcolor{stringliteral}{"{}sleepq profiling"{}});}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00151}00151 \textcolor{keyword}{static} \mbox{\hyperlink{imgact__binmisc_8c_a745707e006bc5c9b6f81b78dfc5caadd}{SYSCTL\_NODE}}(\_debug\_sleepq, OID\_AUTO, chains,}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00152}00152     CTLFLAG\_RD | CTLFLAG\_MPSAFE, 0,}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00153}00153     \textcolor{stringliteral}{"{}sleepq chain stats"{}});}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00154}00154 \textcolor{keyword}{static} u\_int sleepq\_max\_depth;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00155}00155 \mbox{\hyperlink{kern__clocksource_8c_a92b16020e9fe9c2ecfc23fa193b1d587}{SYSCTL\_UINT}}(\_debug\_sleepq, OID\_AUTO, max\_depth, CTLFLAG\_RD, \&sleepq\_max\_depth,}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00156}00156     0, \textcolor{stringliteral}{"{}maxmimum depth achieved of a single chain"{}});}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00157}00157 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00158}00158 \textcolor{keyword}{static} \textcolor{keywordtype}{void}     sleepq\_profile(\textcolor{keyword}{const} \textcolor{keywordtype}{char} *wmesg);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00159}00159 \textcolor{keyword}{static} \textcolor{keywordtype}{int}      prof\_enabled;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00160}00160 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00161}\mbox{\hyperlink{subr__sleepqueue_8c_a85cd25b29ad496ce638931fa7a460b10}{00161}} \textcolor{keyword}{static} \textcolor{keyword}{struct }\mbox{\hyperlink{structsleepqueue__chain}{sleepqueue\_chain}} \mbox{\hyperlink{subr__sleepqueue_8c_a85cd25b29ad496ce638931fa7a460b10}{sleepq\_chains}}[\mbox{\hyperlink{subr__sleepqueue_8c_a9c9580acd9e79bc40e085bdf500210a4}{SC\_TABLESIZE}}];}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00162}\mbox{\hyperlink{subr__sleepqueue_8c_abd12c2a61ac409e10977e78d64cddd09}{00162}} \textcolor{keyword}{static} uma\_zone\_t \mbox{\hyperlink{subr__sleepqueue_8c_abd12c2a61ac409e10977e78d64cddd09}{sleepq\_zone}};}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00163}00163 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00164}00164 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00165}00165 \textcolor{comment}{ * Prototypes for non-\/exported routines.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00166}00166 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00167}00167 \textcolor{keyword}{static} \textcolor{keywordtype}{int}      \mbox{\hyperlink{subr__sleepqueue_8c_a2cfaa28e3f75239b8fff05d69007990a}{sleepq\_catch\_signals}}(\textcolor{keyword}{const} \textcolor{keywordtype}{void} *wchan, \textcolor{keywordtype}{int} pri);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00168}00168 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keywordtype}{int} \mbox{\hyperlink{subr__sleepqueue_8c_a269f92a3ed92698b160244cf98d51b7a}{sleepq\_check\_signals}}(\textcolor{keywordtype}{void});}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00169}00169 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keywordtype}{int} \mbox{\hyperlink{subr__sleepqueue_8c_ae920e6e5394b64d8369c276a12b98f49}{sleepq\_check\_timeout}}(\textcolor{keywordtype}{void});}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00170}00170 \textcolor{preprocessor}{\#ifdef INVARIANTS}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00171}00171 \textcolor{keyword}{static} \textcolor{keywordtype}{void}     sleepq\_dtor(\textcolor{keywordtype}{void} *mem, \textcolor{keywordtype}{int} size, \textcolor{keywordtype}{void} *arg);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00172}00172 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00173}00173 \textcolor{keyword}{static} \textcolor{keywordtype}{int}      \mbox{\hyperlink{subr__sleepqueue_8c_a9b199d5393b0ef0e727057462ebde268}{sleepq\_init}}(\textcolor{keywordtype}{void} *mem, \textcolor{keywordtype}{int} size, \textcolor{keywordtype}{int} \mbox{\hyperlink{subr__stats_8c_a1e87af3c18a2fd36c61faf89949bdc3f}{flags}});}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00174}00174 \textcolor{keyword}{static} \textcolor{keywordtype}{int}      \mbox{\hyperlink{subr__sleepqueue_8c_a0b87894a4dc0cc1bd1957bd9e13cd5bc}{sleepq\_resume\_thread}}(\textcolor{keyword}{struct} \mbox{\hyperlink{structsleepqueue}{sleepqueue}} *sq, \textcolor{keyword}{struct} thread *td,}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00175}00175                     \textcolor{keywordtype}{int} pri, \textcolor{keywordtype}{int} srqflags);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00176}00176 \textcolor{keyword}{static} \textcolor{keywordtype}{void}     \mbox{\hyperlink{subr__sleepqueue_8c_aea091c09cc6a4ecd5b801506cd25c262}{sleepq\_remove\_thread}}(\textcolor{keyword}{struct} \mbox{\hyperlink{structsleepqueue}{sleepqueue}} *sq, \textcolor{keyword}{struct} thread *td);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00177}00177 \textcolor{keyword}{static} \textcolor{keywordtype}{void}     \mbox{\hyperlink{subr__sleepqueue_8c_ad0589d2a980cb7a3cc5c1ba8c83b5b7f}{sleepq\_switch}}(\textcolor{keyword}{const} \textcolor{keywordtype}{void} *wchan, \textcolor{keywordtype}{int} pri);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00178}00178 \textcolor{keyword}{static} \textcolor{keywordtype}{void}     \mbox{\hyperlink{subr__sleepqueue_8c_abfa8981c0b0687d63b3285dc80d3330d}{sleepq\_timeout}}(\textcolor{keywordtype}{void} *arg);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00179}00179 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00180}\mbox{\hyperlink{subr__sleepqueue_8c_af2cab93abc00b4f268a69e7eb2880a35}{00180}} \mbox{\hyperlink{subr__sleepqueue_8c_af2cab93abc00b4f268a69e7eb2880a35}{SDT\_PROBE\_DECLARE}}(sched, , , sleep);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00181}\mbox{\hyperlink{subr__sleepqueue_8c_a5d2e66474b3b3b13bc7c428f0ae18028}{00181}} \mbox{\hyperlink{subr__sleepqueue_8c_af2cab93abc00b4f268a69e7eb2880a35}{SDT\_PROBE\_DECLARE}}(sched, , , \mbox{\hyperlink{kern__synch_8c_ab5e31e48f559b1015c09a61a83c59f19}{wakeup}});}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00182}00182 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00183}00183 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00184}00184 \textcolor{comment}{ * Initialize SLEEPQUEUE\_PROFILING specific sysctl nodes.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00185}00185 \textcolor{comment}{ * Note that it must happen after sleepinit() has been fully executed, so}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00186}00186 \textcolor{comment}{ * it must happen after SI\_SUB\_KMEM SYSINIT() subsystem setup.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00187}00187 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00188}00188 \textcolor{preprocessor}{\#ifdef SLEEPQUEUE\_PROFILING}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00189}00189 \textcolor{keyword}{static} \textcolor{keywordtype}{void}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00190}00190 init\_sleepqueue\_profiling(\textcolor{keywordtype}{void})}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00191}00191 \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00192}00192         \textcolor{keywordtype}{char} chain\_name[10];}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00193}00193         \textcolor{keyword}{struct }sysctl\_oid *chain\_oid;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00194}00194         u\_int i;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00195}00195 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00196}00196         \textcolor{keywordflow}{for} (i = 0; i < \mbox{\hyperlink{subr__sleepqueue_8c_a9c9580acd9e79bc40e085bdf500210a4}{SC\_TABLESIZE}}; i++) \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00197}00197                 \mbox{\hyperlink{subr__prf_8c_ad76145a6edfc98981ded8815a760e0cd}{snprintf}}(chain\_name, \textcolor{keyword}{sizeof}(chain\_name), \textcolor{stringliteral}{"{}\%u"{}}, i);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00198}00198                 chain\_oid = SYSCTL\_ADD\_NODE(NULL,}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00199}00199                     SYSCTL\_STATIC\_CHILDREN(\_debug\_sleepq\_chains), OID\_AUTO,}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00200}00200                     chain\_name, CTLFLAG\_RD | CTLFLAG\_MPSAFE, NULL,}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00201}00201                     \textcolor{stringliteral}{"{}sleepq chain stats"{}});}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00202}00202                 SYSCTL\_ADD\_UINT(NULL, SYSCTL\_CHILDREN(chain\_oid), OID\_AUTO,}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00203}00203                     \textcolor{stringliteral}{"{}depth"{}}, CTLFLAG\_RD, \&\mbox{\hyperlink{subr__sleepqueue_8c_a85cd25b29ad496ce638931fa7a460b10}{sleepq\_chains}}[i].sc\_depth, 0, NULL);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00204}00204                 SYSCTL\_ADD\_UINT(NULL, SYSCTL\_CHILDREN(chain\_oid), OID\_AUTO,}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00205}00205                     \textcolor{stringliteral}{"{}max\_depth"{}}, CTLFLAG\_RD, \&\mbox{\hyperlink{subr__sleepqueue_8c_a85cd25b29ad496ce638931fa7a460b10}{sleepq\_chains}}[i].sc\_max\_depth, 0,}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00206}00206                     NULL);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00207}00207         \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00208}00208 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00209}00209 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00210}00210 \mbox{\hyperlink{imgact__binmisc_8c_abc1dc67f05489fd38eedd6305f96954a}{SYSINIT}}(sleepqueue\_profiling, SI\_SUB\_LOCK, SI\_ORDER\_ANY,}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00211}00211     init\_sleepqueue\_profiling, NULL);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00212}00212 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00213}00213 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00214}00214 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00215}00215 \textcolor{comment}{ * Early initialization of sleep queues that is called from the sleepinit()}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00216}00216 \textcolor{comment}{ * SYSINIT.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00217}00217 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00218}00218 \textcolor{keywordtype}{void}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00219}\mbox{\hyperlink{subr__sleepqueue_8c_a0dfb0987efc8c7e78216a2afd05637b7}{00219}} \mbox{\hyperlink{subr__sleepqueue_8c_a0dfb0987efc8c7e78216a2afd05637b7}{init\_sleepqueues}}(\textcolor{keywordtype}{void})}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00220}00220 \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00221}00221         \textcolor{keywordtype}{int} i;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00222}00222 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00223}00223         \textcolor{keywordflow}{for} (i = 0; i < \mbox{\hyperlink{subr__sleepqueue_8c_a9c9580acd9e79bc40e085bdf500210a4}{SC\_TABLESIZE}}; i++) \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00224}00224                 LIST\_INIT(\&\mbox{\hyperlink{subr__sleepqueue_8c_a85cd25b29ad496ce638931fa7a460b10}{sleepq\_chains}}[i].sc\_queues);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00225}00225                 mtx\_init(\&\mbox{\hyperlink{subr__sleepqueue_8c_a85cd25b29ad496ce638931fa7a460b10}{sleepq\_chains}}[i].sc\_lock, \textcolor{stringliteral}{"{}sleepq chain"{}}, NULL,}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00226}00226                     MTX\_SPIN);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00227}00227         \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00228}00228         \mbox{\hyperlink{subr__sleepqueue_8c_abd12c2a61ac409e10977e78d64cddd09}{sleepq\_zone}} = uma\_zcreate(\textcolor{stringliteral}{"{}SLEEPQUEUE"{}}, \textcolor{keyword}{sizeof}(\textcolor{keyword}{struct} \mbox{\hyperlink{structsleepqueue}{sleepqueue}}),}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00229}00229 \#ifdef INVARIANTS}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00230}00230             NULL, sleepq\_dtor, \mbox{\hyperlink{subr__sleepqueue_8c_a9b199d5393b0ef0e727057462ebde268}{sleepq\_init}}, NULL, UMA\_ALIGN\_CACHE, 0);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00231}00231 \textcolor{preprocessor}{\#else}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00232}00232             NULL, NULL, \mbox{\hyperlink{subr__sleepqueue_8c_a9b199d5393b0ef0e727057462ebde268}{sleepq\_init}}, NULL, UMA\_ALIGN\_CACHE, 0);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00233}00233 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00234}00234 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00235}00235         thread0.td\_sleepqueue = \mbox{\hyperlink{subr__sleepqueue_8c_a8860ac2c996c3339588498882d5687d1}{sleepq\_alloc}}();}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00236}00236 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00237}00237 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00238}00238 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00239}00239 \textcolor{comment}{ * Get a sleep queue for a new thread.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00240}00240 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00241}00241 \textcolor{keyword}{struct }\mbox{\hyperlink{structsleepqueue}{sleepqueue}} *}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00242}\mbox{\hyperlink{subr__sleepqueue_8c_a8860ac2c996c3339588498882d5687d1}{00242}} \mbox{\hyperlink{subr__sleepqueue_8c_a8860ac2c996c3339588498882d5687d1}{sleepq\_alloc}}(\textcolor{keywordtype}{void})}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00243}00243 \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00244}00244 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00245}00245         \textcolor{keywordflow}{return} (uma\_zalloc(\mbox{\hyperlink{subr__sleepqueue_8c_abd12c2a61ac409e10977e78d64cddd09}{sleepq\_zone}}, M\_WAITOK));}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00246}00246 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00247}00247 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00248}00248 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00249}00249 \textcolor{comment}{ * Free a sleep queue when a thread is destroyed.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00250}00250 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00251}00251 \textcolor{keywordtype}{void}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00252}\mbox{\hyperlink{subr__sleepqueue_8c_aeee1149e03f9e5460173921327f77a1a}{00252}} \mbox{\hyperlink{subr__sleepqueue_8c_aeee1149e03f9e5460173921327f77a1a}{sleepq\_free}}(\textcolor{keyword}{struct} \mbox{\hyperlink{structsleepqueue}{sleepqueue}} *sq)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00253}00253 \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00254}00254 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00255}00255         uma\_zfree(\mbox{\hyperlink{subr__sleepqueue_8c_abd12c2a61ac409e10977e78d64cddd09}{sleepq\_zone}}, sq);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00256}00256 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00257}00257 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00258}00258 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00259}00259 \textcolor{comment}{ * Lock the sleep queue chain associated with the specified wait channel.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00260}00260 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00261}00261 \textcolor{keywordtype}{void}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00262}\mbox{\hyperlink{subr__sleepqueue_8c_ae0a612e63d885f5b440f1c0e84652baf}{00262}} \mbox{\hyperlink{subr__sleepqueue_8c_ae0a612e63d885f5b440f1c0e84652baf}{sleepq\_lock}}(\textcolor{keyword}{const} \textcolor{keywordtype}{void} *wchan)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00263}00263 \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00264}00264         \textcolor{keyword}{struct }\mbox{\hyperlink{structsleepqueue__chain}{sleepqueue\_chain}} *sc;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00265}00265 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00266}00266         sc = \mbox{\hyperlink{subr__sleepqueue_8c_aed1c1c8de67981699a715d02955c624c}{SC\_LOOKUP}}(wchan);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00267}00267         mtx\_lock\_spin(\&sc-\/>sc\_lock);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00268}00268 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00269}00269 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00270}00270 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00271}00271 \textcolor{comment}{ * Look up the sleep queue associated with a given wait channel in the hash}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00272}00272 \textcolor{comment}{ * table locking the associated sleep queue chain.  If no queue is found in}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00273}00273 \textcolor{comment}{ * the table, NULL is returned.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00274}00274 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00275}00275 \textcolor{keyword}{struct }\mbox{\hyperlink{structsleepqueue}{sleepqueue}} *}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00276}\mbox{\hyperlink{subr__sleepqueue_8c_a0e37b7bc6c43d74e8073e92130d15864}{00276}} \mbox{\hyperlink{subr__sleepqueue_8c_a0e37b7bc6c43d74e8073e92130d15864}{sleepq\_lookup}}(\textcolor{keyword}{const} \textcolor{keywordtype}{void} *wchan)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00277}00277 \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00278}00278         \textcolor{keyword}{struct }\mbox{\hyperlink{structsleepqueue__chain}{sleepqueue\_chain}} *sc;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00279}00279         \textcolor{keyword}{struct }\mbox{\hyperlink{structsleepqueue}{sleepqueue}} *sq;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00280}00280 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00281}00281         KASSERT(wchan != NULL, (\textcolor{stringliteral}{"{}\%s: invalid NULL wait channel"{}}, \_\_func\_\_));}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00282}00282         sc = \mbox{\hyperlink{subr__sleepqueue_8c_aed1c1c8de67981699a715d02955c624c}{SC\_LOOKUP}}(wchan);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00283}00283         mtx\_assert(\&sc-\/>sc\_lock, MA\_OWNED);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00284}00284         LIST\_FOREACH(sq, \&sc-\/>sc\_queues, sq\_hash)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00285}00285                 \textcolor{keywordflow}{if} (sq-\/>sq\_wchan == wchan)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00286}00286                         \textcolor{keywordflow}{return} (sq);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00287}00287         \textcolor{keywordflow}{return} (NULL);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00288}00288 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00289}00289 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00290}00290 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00291}00291 \textcolor{comment}{ * Unlock the sleep queue chain associated with a given wait channel.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00292}00292 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00293}00293 \textcolor{keywordtype}{void}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00294}\mbox{\hyperlink{subr__sleepqueue_8c_a0157460dbeca34582ee4d5890b74fa15}{00294}} \mbox{\hyperlink{subr__sleepqueue_8c_a0157460dbeca34582ee4d5890b74fa15}{sleepq\_release}}(\textcolor{keyword}{const} \textcolor{keywordtype}{void} *wchan)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00295}00295 \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00296}00296         \textcolor{keyword}{struct }\mbox{\hyperlink{structsleepqueue__chain}{sleepqueue\_chain}} *sc;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00297}00297 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00298}00298         sc = \mbox{\hyperlink{subr__sleepqueue_8c_aed1c1c8de67981699a715d02955c624c}{SC\_LOOKUP}}(wchan);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00299}00299         mtx\_unlock\_spin(\&sc-\/>sc\_lock);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00300}00300 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00301}00301 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00302}00302 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00303}00303 \textcolor{comment}{ * Places the current thread on the sleep queue for the specified wait}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00304}00304 \textcolor{comment}{ * channel.  If INVARIANTS is enabled, then it associates the passed in}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00305}00305 \textcolor{comment}{ * lock with the sleepq to make sure it is held when that sleep queue is}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00306}00306 \textcolor{comment}{ * woken up.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00307}00307 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00308}00308 \textcolor{keywordtype}{void}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00309}\mbox{\hyperlink{subr__sleepqueue_8c_aa2822b5d83f7fb459964aa82b02b8701}{00309}} \mbox{\hyperlink{subr__sleepqueue_8c_aa2822b5d83f7fb459964aa82b02b8701}{sleepq\_add}}(\textcolor{keyword}{const} \textcolor{keywordtype}{void} *wchan, \textcolor{keyword}{struct} lock\_object *lock, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *wmesg,}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00310}00310     \textcolor{keywordtype}{int} \mbox{\hyperlink{subr__stats_8c_a1e87af3c18a2fd36c61faf89949bdc3f}{flags}}, \textcolor{keywordtype}{int} queue)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00311}00311 \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00312}00312         \textcolor{keyword}{struct }\mbox{\hyperlink{structsleepqueue__chain}{sleepqueue\_chain}} *sc;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00313}00313         \textcolor{keyword}{struct }\mbox{\hyperlink{structsleepqueue}{sleepqueue}} *sq;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00314}00314         \textcolor{keyword}{struct }thread *td;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00315}00315 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00316}00316         td = curthread;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00317}00317         sc = \mbox{\hyperlink{subr__sleepqueue_8c_aed1c1c8de67981699a715d02955c624c}{SC\_LOOKUP}}(wchan);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00318}00318         mtx\_assert(\&sc-\/>sc\_lock, MA\_OWNED);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00319}00319         MPASS(td-\/>td\_sleepqueue != NULL);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00320}00320         MPASS(wchan != NULL);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00321}00321         MPASS((queue >= 0) \&\& (queue < \mbox{\hyperlink{subr__sleepqueue_8c_a51b446e9977c5c46691e73f05d9b9308}{NR\_SLEEPQS}}));}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00322}00322 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00323}00323         \textcolor{comment}{/* If this thread is not allowed to sleep, die a horrible death. */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00324}00324         \textcolor{keywordflow}{if} (\_\_predict\_false(!THREAD\_CAN\_SLEEP())) \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00325}00325 \textcolor{preprocessor}{\#ifdef EPOCH\_TRACE}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00326}00326                 epoch\_trace\_list(curthread);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00327}00327 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00328}00328                 KASSERT(0,}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00329}00329                     (\textcolor{stringliteral}{"{}\%s: td \%p to sleep on wchan \%p with sleeping prohibited"{}},}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00330}00330                     \_\_func\_\_, td, wchan));}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00331}00331         \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00332}00332 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00333}00333         \textcolor{comment}{/* Look up the sleep queue associated with the wait channel 'wchan'. */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00334}00334         sq = \mbox{\hyperlink{subr__sleepqueue_8c_a0e37b7bc6c43d74e8073e92130d15864}{sleepq\_lookup}}(wchan);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00335}00335 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00336}00336         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00337}00337 \textcolor{comment}{         * If the wait channel does not already have a sleep queue, use}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00338}00338 \textcolor{comment}{         * this thread's sleep queue.  Otherwise, insert the current thread}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00339}00339 \textcolor{comment}{         * into the sleep queue already in use by this wait channel.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00340}00340 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00341}00341         \textcolor{keywordflow}{if} (sq == NULL) \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00342}00342 \textcolor{preprocessor}{\#ifdef INVARIANTS}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00343}00343                 \textcolor{keywordtype}{int} i;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00344}00344 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00345}00345                 sq = td-\/>td\_sleepqueue;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00346}00346                 \textcolor{keywordflow}{for} (i = 0; i < \mbox{\hyperlink{subr__sleepqueue_8c_a51b446e9977c5c46691e73f05d9b9308}{NR\_SLEEPQS}}; i++) \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00347}00347                         KASSERT(TAILQ\_EMPTY(\&sq-\/>\mbox{\hyperlink{structsleepqueue_a8afd5c01f6e71471d36a7270ff07ebe8}{sq\_blocked}}[i]),}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00348}00348                             (\textcolor{stringliteral}{"{}thread's sleep queue \%d is not empty"{}}, i));}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00349}00349                         KASSERT(sq-\/>\mbox{\hyperlink{structsleepqueue_a439a41f50ae79d9f7b33e2d0a1f468dd}{sq\_blockedcnt}}[i] == 0,}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00350}00350                             (\textcolor{stringliteral}{"{}thread's sleep queue \%d count mismatches"{}}, i));}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00351}00351                 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00352}00352                 KASSERT(LIST\_EMPTY(\&sq-\/>sq\_free),}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00353}00353                     (\textcolor{stringliteral}{"{}thread's sleep queue has a non-\/empty free list"{}}));}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00354}00354                 KASSERT(sq-\/>sq\_wchan == NULL, (\textcolor{stringliteral}{"{}stale sq\_wchan pointer"{}}));}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00355}00355                 sq-\/>sq\_lock = lock;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00356}00356 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00357}00357 \textcolor{preprocessor}{\#ifdef SLEEPQUEUE\_PROFILING}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00358}00358                 sc-\/>sc\_depth++;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00359}00359                 \textcolor{keywordflow}{if} (sc-\/>sc\_depth > sc-\/>sc\_max\_depth) \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00360}00360                         sc-\/>sc\_max\_depth = sc-\/>sc\_depth;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00361}00361                         \textcolor{keywordflow}{if} (sc-\/>sc\_max\_depth > sleepq\_max\_depth)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00362}00362                                 sleepq\_max\_depth = sc-\/>sc\_max\_depth;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00363}00363                 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00364}00364 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00365}00365                 sq = td-\/>td\_sleepqueue;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00366}00366                 LIST\_INSERT\_HEAD(\&sc-\/>sc\_queues, sq, sq\_hash);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00367}00367                 sq-\/>sq\_wchan = wchan;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00368}00368                 sq-\/>sq\_type = \mbox{\hyperlink{subr__stats_8c_a1e87af3c18a2fd36c61faf89949bdc3f}{flags}} \& SLEEPQ\_TYPE;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00369}00369         \} \textcolor{keywordflow}{else} \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00370}00370                 MPASS(wchan == sq-\/>sq\_wchan);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00371}00371                 MPASS(lock == sq-\/>sq\_lock);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00372}00372                 MPASS((\mbox{\hyperlink{subr__stats_8c_a1e87af3c18a2fd36c61faf89949bdc3f}{flags}} \& SLEEPQ\_TYPE) == sq-\/>sq\_type);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00373}00373                 LIST\_INSERT\_HEAD(\&sq-\/>sq\_free, td-\/>td\_sleepqueue, sq\_hash);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00374}00374         \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00375}00375         thread\_lock(td);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00376}00376         TAILQ\_INSERT\_TAIL(\&sq-\/>\mbox{\hyperlink{structsleepqueue_a8afd5c01f6e71471d36a7270ff07ebe8}{sq\_blocked}}[queue], td, td\_slpq);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00377}00377         sq-\/>\mbox{\hyperlink{structsleepqueue_a439a41f50ae79d9f7b33e2d0a1f468dd}{sq\_blockedcnt}}[queue]++;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00378}00378         td-\/>td\_sleepqueue = NULL;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00379}00379         td-\/>td\_sqqueue = queue;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00380}00380         td-\/>td\_wchan = wchan;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00381}00381         td-\/>td\_wmesg = wmesg;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00382}00382         \textcolor{keywordflow}{if} (\mbox{\hyperlink{subr__stats_8c_a1e87af3c18a2fd36c61faf89949bdc3f}{flags}} \& SLEEPQ\_INTERRUPTIBLE) \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00383}00383                 td-\/>td\_intrval = 0;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00384}00384                 td-\/>td\_flags |= TDF\_SINTR;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00385}00385         \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00386}00386         td-\/>td\_flags \&= \string~TDF\_TIMEOUT;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00387}00387         thread\_unlock(td);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00388}00388 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00389}00389 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00390}00390 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00391}00391 \textcolor{comment}{ * Sets a timeout that will remove the current thread from the specified}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00392}00392 \textcolor{comment}{ * sleep queue after timo ticks if the thread has not already been awakened.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00393}00393 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00394}00394 \textcolor{keywordtype}{void}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00395}\mbox{\hyperlink{subr__sleepqueue_8c_ac2eb0510c71a0db22f57a44b0e53bfd0}{00395}} \mbox{\hyperlink{subr__sleepqueue_8c_ac2eb0510c71a0db22f57a44b0e53bfd0}{sleepq\_set\_timeout\_sbt}}(\textcolor{keyword}{const} \textcolor{keywordtype}{void} *wchan, sbintime\_t sbt, sbintime\_t \mbox{\hyperlink{kern__poll_8c_a18e32b1f69fa6affa136620d0aadca4c}{pr}},}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00396}00396     \textcolor{keywordtype}{int} \mbox{\hyperlink{subr__stats_8c_a1e87af3c18a2fd36c61faf89949bdc3f}{flags}})}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00397}00397 \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00398}00398         \textcolor{keyword}{struct }\mbox{\hyperlink{structsleepqueue__chain}{sleepqueue\_chain}} *sc \_\_unused;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00399}00399         \textcolor{keyword}{struct }thread *td;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00400}00400         sbintime\_t pr1;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00401}00401 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00402}00402         td = curthread;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00403}00403         sc = \mbox{\hyperlink{subr__sleepqueue_8c_aed1c1c8de67981699a715d02955c624c}{SC\_LOOKUP}}(wchan);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00404}00404         mtx\_assert(\&sc-\/>sc\_lock, MA\_OWNED);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00405}00405         MPASS(TD\_ON\_SLEEPQ(td));}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00406}00406         MPASS(td-\/>td\_sleepqueue == NULL);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00407}00407         MPASS(wchan != NULL);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00408}00408         \textcolor{keywordflow}{if} (cold \&\& td == \&thread0)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00409}00409                 \mbox{\hyperlink{kern__shutdown_8c_ad1f1a1dc0581a11b597453f148106393}{panic}}(\textcolor{stringliteral}{"{}timed sleep before timers are working"{}});}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00410}00410         KASSERT(td-\/>td\_sleeptimo == 0, (\textcolor{stringliteral}{"{}td \%d \%p td\_sleeptimo \%jx"{}},}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00411}00411             td-\/>td\_tid, td, (uintmax\_t)td-\/>td\_sleeptimo));}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00412}00412         thread\_lock(td);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00413}00413         \mbox{\hyperlink{kern__timeout_8c_ab9d5f6a22bc557375b60bf2c986a3fc8}{callout\_when}}(sbt, \mbox{\hyperlink{kern__poll_8c_a18e32b1f69fa6affa136620d0aadca4c}{pr}}, \mbox{\hyperlink{subr__stats_8c_a1e87af3c18a2fd36c61faf89949bdc3f}{flags}}, \&td-\/>td\_sleeptimo, \&pr1);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00414}00414         thread\_unlock(td);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00415}00415         \mbox{\hyperlink{kern__timeout_8c_a4d23c2a3d46289ea67f304ae21f8aeac}{callout\_reset\_sbt\_on}}(\&td-\/>td\_slpcallout, td-\/>td\_sleeptimo, pr1,}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00416}00416             \mbox{\hyperlink{subr__sleepqueue_8c_abfa8981c0b0687d63b3285dc80d3330d}{sleepq\_timeout}}, td, PCPU\_GET(cpuid), \mbox{\hyperlink{subr__stats_8c_a1e87af3c18a2fd36c61faf89949bdc3f}{flags}} | C\_PRECALC |}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00417}00417             C\_DIRECT\_EXEC);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00418}00418 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00419}00419 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00420}00420 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00421}00421 \textcolor{comment}{ * Return the number of actual sleepers for the specified queue.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00422}00422 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00423}00423 u\_int}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00424}\mbox{\hyperlink{subr__sleepqueue_8c_a9705dc06b2f7af3c15a9239c7fdae058}{00424}} \mbox{\hyperlink{subr__sleepqueue_8c_a9705dc06b2f7af3c15a9239c7fdae058}{sleepq\_sleepcnt}}(\textcolor{keyword}{const} \textcolor{keywordtype}{void} *wchan, \textcolor{keywordtype}{int} queue)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00425}00425 \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00426}00426         \textcolor{keyword}{struct }\mbox{\hyperlink{structsleepqueue}{sleepqueue}} *sq;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00427}00427 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00428}00428         KASSERT(wchan != NULL, (\textcolor{stringliteral}{"{}\%s: invalid NULL wait channel"{}}, \_\_func\_\_));}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00429}00429         MPASS((queue >= 0) \&\& (queue < \mbox{\hyperlink{subr__sleepqueue_8c_a51b446e9977c5c46691e73f05d9b9308}{NR\_SLEEPQS}}));}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00430}00430         sq = \mbox{\hyperlink{subr__sleepqueue_8c_a0e37b7bc6c43d74e8073e92130d15864}{sleepq\_lookup}}(wchan);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00431}00431         \textcolor{keywordflow}{if} (sq == NULL)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00432}00432                 \textcolor{keywordflow}{return} (0);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00433}00433         \textcolor{keywordflow}{return} (sq-\/>\mbox{\hyperlink{structsleepqueue_a439a41f50ae79d9f7b33e2d0a1f468dd}{sq\_blockedcnt}}[queue]);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00434}00434 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00435}00435 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00436}00436 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00437}\mbox{\hyperlink{subr__sleepqueue_8c_af25cd5203dfd19b37f0ce32c72bb663b}{00437}} \mbox{\hyperlink{subr__sleepqueue_8c_af25cd5203dfd19b37f0ce32c72bb663b}{sleepq\_check\_ast\_sc\_locked}}(\textcolor{keyword}{struct} thread *td, \textcolor{keyword}{struct} \mbox{\hyperlink{structsleepqueue__chain}{sleepqueue\_chain}} *sc)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00438}00438 \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00439}00439         \textcolor{keyword}{struct }proc *p;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00440}00440         \textcolor{keywordtype}{int} ret;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00441}00441 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00442}00442         mtx\_assert(\&sc-\/>sc\_lock, MA\_OWNED);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00443}00443 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00444}00444         \textcolor{keywordflow}{if} ((td-\/>td\_pflags \& TDP\_WAKEUP) != 0) \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00445}00445                 td-\/>td\_pflags \&= \string~TDP\_WAKEUP;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00446}00446                 thread\_lock(td);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00447}00447                 \textcolor{keywordflow}{return} (EINTR);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00448}00448         \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00449}00449 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00450}00450         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00451}00451 \textcolor{comment}{         * See if there are any pending signals or suspension requests for this}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00452}00452 \textcolor{comment}{         * thread.  If not, we can switch immediately.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00453}00453 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00454}00454         thread\_lock(td);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00455}00455         \textcolor{keywordflow}{if} ((td-\/>td\_flags \& (TDF\_NEEDSIGCHK | TDF\_NEEDSUSPCHK)) == 0)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00456}00456                 \textcolor{keywordflow}{return} (0);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00457}00457 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00458}00458         thread\_unlock(td);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00459}00459         mtx\_unlock\_spin(\&sc-\/>sc\_lock);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00460}00460 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00461}00461         p = td-\/>td\_proc;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00462}00462         CTR3(KTR\_PROC, \textcolor{stringliteral}{"{}sleepq catching signals: thread \%p (pid \%ld, \%s)"{}},}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00463}00463             (\textcolor{keywordtype}{void} *)td, (\textcolor{keywordtype}{long})p-\/>p\_pid, td-\/>td\_name);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00464}00464         PROC\_LOCK(p);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00465}00465 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00466}00466         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00467}00467 \textcolor{comment}{         * Check for suspension first. Checking for signals and then}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00468}00468 \textcolor{comment}{         * suspending could result in a missed signal, since a signal}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00469}00469 \textcolor{comment}{         * can be delivered while this thread is suspended.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00470}00470 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00471}00471         ret = \mbox{\hyperlink{kern__sig_8c_ae1831554128d22e8453ba6992db44b0e}{sig\_ast\_checksusp}}(td);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00472}00472         \textcolor{keywordflow}{if} (ret != 0) \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00473}00473                 PROC\_UNLOCK(p);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00474}00474                 mtx\_lock\_spin(\&sc-\/>sc\_lock);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00475}00475                 thread\_lock(td);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00476}00476                 \textcolor{keywordflow}{return} (ret);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00477}00477         \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00478}00478 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00479}00479         ret = \mbox{\hyperlink{kern__sig_8c_a0a0f9a26e15ff6213d70cfeb95ef4f66}{sig\_ast\_needsigchk}}(td);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00480}00480 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00481}00481         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00482}00482 \textcolor{comment}{         * Lock the per-\/process spinlock prior to dropping the}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00483}00483 \textcolor{comment}{         * PROC\_LOCK to avoid a signal delivery race.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00484}00484 \textcolor{comment}{         * PROC\_LOCK, PROC\_SLOCK, and thread\_lock() are}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00485}00485 \textcolor{comment}{         * currently held in tdsendsignal().}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00486}00486 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00487}00487         PROC\_SLOCK(p);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00488}00488         mtx\_lock\_spin(\&sc-\/>sc\_lock);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00489}00489         PROC\_UNLOCK(p);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00490}00490         thread\_lock(td);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00491}00491         PROC\_SUNLOCK(p);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00492}00492 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00493}00493         \textcolor{keywordflow}{return} (ret);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00494}00494 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00495}00495 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00496}00496 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00497}00497 \textcolor{comment}{ * Marks the pending sleep of the current thread as interruptible and}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00498}00498 \textcolor{comment}{ * makes an initial check for pending signals before putting a thread}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00499}00499 \textcolor{comment}{ * to sleep. Enters and exits with the thread lock held.  Thread lock}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00500}00500 \textcolor{comment}{ * may have transitioned from the sleepq lock to a run lock.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00501}00501 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00502}00502 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00503}\mbox{\hyperlink{subr__sleepqueue_8c_a2cfaa28e3f75239b8fff05d69007990a}{00503}} \mbox{\hyperlink{subr__sleepqueue_8c_a2cfaa28e3f75239b8fff05d69007990a}{sleepq\_catch\_signals}}(\textcolor{keyword}{const} \textcolor{keywordtype}{void} *wchan, \textcolor{keywordtype}{int} pri)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00504}00504 \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00505}00505         \textcolor{keyword}{struct }thread *td;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00506}00506         \textcolor{keyword}{struct }\mbox{\hyperlink{structsleepqueue__chain}{sleepqueue\_chain}} *sc;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00507}00507         \textcolor{keyword}{struct }\mbox{\hyperlink{structsleepqueue}{sleepqueue}} *sq;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00508}00508         \textcolor{keywordtype}{int} ret;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00509}00509 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00510}00510         sc = \mbox{\hyperlink{subr__sleepqueue_8c_aed1c1c8de67981699a715d02955c624c}{SC\_LOOKUP}}(wchan);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00511}00511         mtx\_assert(\&sc-\/>sc\_lock, MA\_OWNED);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00512}00512         MPASS(wchan != NULL);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00513}00513         td = curthread;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00514}00514 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00515}00515         ret = \mbox{\hyperlink{subr__sleepqueue_8c_af25cd5203dfd19b37f0ce32c72bb663b}{sleepq\_check\_ast\_sc\_locked}}(td, sc);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00516}00516         THREAD\_LOCK\_ASSERT(td, MA\_OWNED);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00517}00517         mtx\_assert(\&sc-\/>sc\_lock, MA\_OWNED);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00518}00518 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00519}00519         \textcolor{keywordflow}{if} (ret == 0) \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00520}00520                 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00521}00521 \textcolor{comment}{                 * No pending signals and no suspension requests found.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00522}00522 \textcolor{comment}{                 * Switch the thread off the cpu.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00523}00523 \textcolor{comment}{                 */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00524}00524                 \mbox{\hyperlink{subr__sleepqueue_8c_ad0589d2a980cb7a3cc5c1ba8c83b5b7f}{sleepq\_switch}}(wchan, pri);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00525}00525         \} \textcolor{keywordflow}{else} \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00526}00526                 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00527}00527 \textcolor{comment}{                 * There were pending signals and this thread is still}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00528}00528 \textcolor{comment}{                 * on the sleep queue, remove it from the sleep queue.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00529}00529 \textcolor{comment}{                 */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00530}00530                 \textcolor{keywordflow}{if} (TD\_ON\_SLEEPQ(td)) \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00531}00531                         sq = \mbox{\hyperlink{subr__sleepqueue_8c_a0e37b7bc6c43d74e8073e92130d15864}{sleepq\_lookup}}(wchan);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00532}00532                         \mbox{\hyperlink{subr__sleepqueue_8c_aea091c09cc6a4ecd5b801506cd25c262}{sleepq\_remove\_thread}}(sq, td);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00533}00533                 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00534}00534                 MPASS(td-\/>td\_lock != \&sc-\/>sc\_lock);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00535}00535                 mtx\_unlock\_spin(\&sc-\/>sc\_lock);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00536}00536                 thread\_unlock(td);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00537}00537         \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00538}00538         \textcolor{keywordflow}{return} (ret);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00539}00539 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00540}00540 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00541}00541 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00542}00542 \textcolor{comment}{ * Switches to another thread if we are still asleep on a sleep queue.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00543}00543 \textcolor{comment}{ * Returns with thread lock.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00544}00544 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00545}00545 \textcolor{keyword}{static} \textcolor{keywordtype}{void}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00546}\mbox{\hyperlink{subr__sleepqueue_8c_ad0589d2a980cb7a3cc5c1ba8c83b5b7f}{00546}} \mbox{\hyperlink{subr__sleepqueue_8c_ad0589d2a980cb7a3cc5c1ba8c83b5b7f}{sleepq\_switch}}(\textcolor{keyword}{const} \textcolor{keywordtype}{void} *wchan, \textcolor{keywordtype}{int} pri)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00547}00547 \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00548}00548         \textcolor{keyword}{struct }\mbox{\hyperlink{structsleepqueue__chain}{sleepqueue\_chain}} *sc;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00549}00549         \textcolor{keyword}{struct }\mbox{\hyperlink{structsleepqueue}{sleepqueue}} *sq;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00550}00550         \textcolor{keyword}{struct }thread *td;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00551}00551         \textcolor{keywordtype}{bool} rtc\_changed;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00552}00552 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00553}00553         td = curthread;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00554}00554         sc = \mbox{\hyperlink{subr__sleepqueue_8c_aed1c1c8de67981699a715d02955c624c}{SC\_LOOKUP}}(wchan);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00555}00555         mtx\_assert(\&sc-\/>sc\_lock, MA\_OWNED);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00556}00556         THREAD\_LOCK\_ASSERT(td, MA\_OWNED);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00557}00557 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00558}00558         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00559}00559 \textcolor{comment}{         * If we have a sleep queue, then we've already been woken up, so}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00560}00560 \textcolor{comment}{         * just return.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00561}00561 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00562}00562         \textcolor{keywordflow}{if} (td-\/>td\_sleepqueue != NULL) \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00563}00563                 mtx\_unlock\_spin(\&sc-\/>sc\_lock);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00564}00564                 thread\_unlock(td);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00565}00565                 \textcolor{keywordflow}{return};}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00566}00566         \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00567}00567 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00568}00568         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00569}00569 \textcolor{comment}{         * If TDF\_TIMEOUT is set, then our sleep has been timed out}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00570}00570 \textcolor{comment}{         * already but we are still on the sleep queue, so dequeue the}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00571}00571 \textcolor{comment}{         * thread and return.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00572}00572 \textcolor{comment}{         *}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00573}00573 \textcolor{comment}{         * Do the same if the real-\/time clock has been adjusted since this}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00574}00574 \textcolor{comment}{         * thread calculated its timeout based on that clock.  This handles}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00575}00575 \textcolor{comment}{         * the following race:}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00576}00576 \textcolor{comment}{         * -\/ The Ts thread needs to sleep until an absolute real-\/clock time.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00577}00577 \textcolor{comment}{         *   It copies the global rtc\_generation into curthread-\/>td\_rtcgen,}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00578}00578 \textcolor{comment}{         *   reads the RTC, and calculates a sleep duration based on that time.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00579}00579 \textcolor{comment}{         *   See umtxq\_sleep() for an example.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00580}00580 \textcolor{comment}{         * -\/ The Tc thread adjusts the RTC, bumps rtc\_generation, and wakes}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00581}00581 \textcolor{comment}{         *   threads that are sleeping until an absolute real-\/clock time.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00582}00582 \textcolor{comment}{         *   See tc\_setclock() and the POSIX specification of clock\_settime().}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00583}00583 \textcolor{comment}{         * -\/ Ts reaches the code below.  It holds the sleepqueue chain lock,}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00584}00584 \textcolor{comment}{         *   so Tc has finished waking, so this thread must test td\_rtcgen.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00585}00585 \textcolor{comment}{         * (The declaration of td\_rtcgen refers to this comment.)}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00586}00586 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00587}00587         rtc\_changed = td-\/>td\_rtcgen != 0 \&\& td-\/>td\_rtcgen != \mbox{\hyperlink{kern__tc_8c_a28a361b4119bc0fda1ede69d075aa621}{rtc\_generation}};}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00588}00588         \textcolor{keywordflow}{if} ((td-\/>td\_flags \& TDF\_TIMEOUT) || rtc\_changed) \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00589}00589                 \textcolor{keywordflow}{if} (rtc\_changed) \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00590}00590                         td-\/>td\_rtcgen = 0;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00591}00591                 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00592}00592                 MPASS(TD\_ON\_SLEEPQ(td));}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00593}00593                 sq = \mbox{\hyperlink{subr__sleepqueue_8c_a0e37b7bc6c43d74e8073e92130d15864}{sleepq\_lookup}}(wchan);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00594}00594                 \mbox{\hyperlink{subr__sleepqueue_8c_aea091c09cc6a4ecd5b801506cd25c262}{sleepq\_remove\_thread}}(sq, td);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00595}00595                 mtx\_unlock\_spin(\&sc-\/>sc\_lock);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00596}00596                 thread\_unlock(td);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00597}00597                 \textcolor{keywordflow}{return};}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00598}00598         \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00599}00599 \textcolor{preprocessor}{\#ifdef SLEEPQUEUE\_PROFILING}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00600}00600         \textcolor{keywordflow}{if} (prof\_enabled)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00601}00601                 sleepq\_profile(td-\/>td\_wmesg);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00602}00602 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00603}00603         MPASS(td-\/>td\_sleepqueue == NULL);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00604}00604         \mbox{\hyperlink{sched__4bsd_8c_ac0c12eebc7f6eeec742ef5f7c2c254f1}{sched\_sleep}}(td, pri);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00605}00605         \mbox{\hyperlink{kern__mutex_8c_aa09052452feb15958ad3dfda8fb48f45}{thread\_lock\_set}}(td, \&sc-\/>sc\_lock);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00606}00606         SDT\_PROBE0(sched, , , sleep);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00607}00607         TD\_SET\_SLEEPING(td);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00608}00608         \mbox{\hyperlink{kern__synch_8c_a255ddd9782b8682f61a69174bd9fc0b8}{mi\_switch}}(SW\_VOL | SWT\_SLEEPQ);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00609}00609         KASSERT(TD\_IS\_RUNNING(td), (\textcolor{stringliteral}{"{}running but not TDS\_RUNNING"{}}));}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00610}00610         CTR3(KTR\_PROC, \textcolor{stringliteral}{"{}sleepq resume: thread \%p (pid \%ld, \%s)"{}},}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00611}00611             (\textcolor{keywordtype}{void} *)td, (\textcolor{keywordtype}{long})td-\/>td\_proc-\/>p\_pid, (\textcolor{keywordtype}{void} *)td-\/>td\_name);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00612}00612 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00613}00613 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00614}00614 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00615}00615 \textcolor{comment}{ * Check to see if we timed out.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00616}00616 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00617}00617 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00618}\mbox{\hyperlink{subr__sleepqueue_8c_ae920e6e5394b64d8369c276a12b98f49}{00618}} \mbox{\hyperlink{subr__sleepqueue_8c_ae920e6e5394b64d8369c276a12b98f49}{sleepq\_check\_timeout}}(\textcolor{keywordtype}{void})}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00619}00619 \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00620}00620         \textcolor{keyword}{struct }thread *td;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00621}00621         \textcolor{keywordtype}{int} \mbox{\hyperlink{pic__if_8m_a3cbc3b98ed07988f5e3be53a0eebbb92}{res}};}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00622}00622 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00623}00623         \mbox{\hyperlink{pic__if_8m_a3cbc3b98ed07988f5e3be53a0eebbb92}{res}} = 0;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00624}00624         td = curthread;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00625}00625         \textcolor{keywordflow}{if} (td-\/>td\_sleeptimo != 0) \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00626}00626                 \textcolor{keywordflow}{if} (td-\/>td\_sleeptimo <= sbinuptime())}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00627}00627                         \mbox{\hyperlink{pic__if_8m_a3cbc3b98ed07988f5e3be53a0eebbb92}{res}} = EWOULDBLOCK;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00628}00628                 td-\/>td\_sleeptimo = 0;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00629}00629         \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00630}00630         \textcolor{keywordflow}{return} (\mbox{\hyperlink{pic__if_8m_a3cbc3b98ed07988f5e3be53a0eebbb92}{res}});}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00631}00631 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00632}00632 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00633}00633 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00634}00634 \textcolor{comment}{ * Check to see if we were awoken by a signal.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00635}00635 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00636}00636 \textcolor{keyword}{static} \textcolor{keyword}{inline} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00637}\mbox{\hyperlink{subr__sleepqueue_8c_a269f92a3ed92698b160244cf98d51b7a}{00637}} \mbox{\hyperlink{subr__sleepqueue_8c_a269f92a3ed92698b160244cf98d51b7a}{sleepq\_check\_signals}}(\textcolor{keywordtype}{void})}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00638}00638 \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00639}00639         \textcolor{keyword}{struct }thread *td;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00640}00640 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00641}00641         td = curthread;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00642}00642         KASSERT((td-\/>td\_flags \& TDF\_SINTR) == 0,}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00643}00643             (\textcolor{stringliteral}{"{}thread \%p still in interruptible sleep?"{}}, td));}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00644}00644 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00645}00645         \textcolor{keywordflow}{return} (td-\/>td\_intrval);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00646}00646 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00647}00647 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00648}00648 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00649}00649 \textcolor{comment}{ * Block the current thread until it is awakened from its sleep queue.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00650}00650 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00651}00651 \textcolor{keywordtype}{void}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00652}\mbox{\hyperlink{subr__sleepqueue_8c_ac839176dcd4b987ba04b3112b5502303}{00652}} \mbox{\hyperlink{subr__sleepqueue_8c_ac839176dcd4b987ba04b3112b5502303}{sleepq\_wait}}(\textcolor{keyword}{const} \textcolor{keywordtype}{void} *wchan, \textcolor{keywordtype}{int} pri)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00653}00653 \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00654}00654         \textcolor{keyword}{struct }thread *td;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00655}00655 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00656}00656         td = curthread;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00657}00657         MPASS(!(td-\/>td\_flags \& TDF\_SINTR));}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00658}00658         thread\_lock(td);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00659}00659         \mbox{\hyperlink{subr__sleepqueue_8c_ad0589d2a980cb7a3cc5c1ba8c83b5b7f}{sleepq\_switch}}(wchan, pri);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00660}00660 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00661}00661 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00662}00662 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00663}00663 \textcolor{comment}{ * Block the current thread until it is awakened from its sleep queue}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00664}00664 \textcolor{comment}{ * or it is interrupted by a signal.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00665}00665 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00666}00666 \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00667}\mbox{\hyperlink{subr__sleepqueue_8c_a1ceaeff8d86d1d875208f14e9342ded6}{00667}} \mbox{\hyperlink{subr__sleepqueue_8c_a1ceaeff8d86d1d875208f14e9342ded6}{sleepq\_wait\_sig}}(\textcolor{keyword}{const} \textcolor{keywordtype}{void} *wchan, \textcolor{keywordtype}{int} pri)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00668}00668 \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00669}00669         \textcolor{keywordtype}{int} rcatch;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00670}00670 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00671}00671         rcatch = \mbox{\hyperlink{subr__sleepqueue_8c_a2cfaa28e3f75239b8fff05d69007990a}{sleepq\_catch\_signals}}(wchan, pri);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00672}00672         \textcolor{keywordflow}{if} (rcatch)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00673}00673                 \textcolor{keywordflow}{return} (rcatch);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00674}00674         \textcolor{keywordflow}{return} (\mbox{\hyperlink{subr__sleepqueue_8c_a269f92a3ed92698b160244cf98d51b7a}{sleepq\_check\_signals}}());}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00675}00675 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00676}00676 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00677}00677 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00678}00678 \textcolor{comment}{ * Block the current thread until it is awakened from its sleep queue}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00679}00679 \textcolor{comment}{ * or it times out while waiting.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00680}00680 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00681}00681 \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00682}\mbox{\hyperlink{subr__sleepqueue_8c_a9169c9354a2030d00d66045bf634f1cd}{00682}} \mbox{\hyperlink{subr__sleepqueue_8c_a9169c9354a2030d00d66045bf634f1cd}{sleepq\_timedwait}}(\textcolor{keyword}{const} \textcolor{keywordtype}{void} *wchan, \textcolor{keywordtype}{int} pri)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00683}00683 \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00684}00684         \textcolor{keyword}{struct }thread *td;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00685}00685 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00686}00686         td = curthread;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00687}00687         MPASS(!(td-\/>td\_flags \& TDF\_SINTR));}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00688}00688 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00689}00689         thread\_lock(td);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00690}00690         \mbox{\hyperlink{subr__sleepqueue_8c_ad0589d2a980cb7a3cc5c1ba8c83b5b7f}{sleepq\_switch}}(wchan, pri);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00691}00691 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00692}00692         \textcolor{keywordflow}{return} (\mbox{\hyperlink{subr__sleepqueue_8c_ae920e6e5394b64d8369c276a12b98f49}{sleepq\_check\_timeout}}());}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00693}00693 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00694}00694 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00695}00695 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00696}00696 \textcolor{comment}{ * Block the current thread until it is awakened from its sleep queue,}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00697}00697 \textcolor{comment}{ * it is interrupted by a signal, or it times out waiting to be awakened.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00698}00698 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00699}00699 \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00700}\mbox{\hyperlink{subr__sleepqueue_8c_a5883b17b0778f577bd7ce73f070b4efa}{00700}} \mbox{\hyperlink{subr__sleepqueue_8c_a5883b17b0778f577bd7ce73f070b4efa}{sleepq\_timedwait\_sig}}(\textcolor{keyword}{const} \textcolor{keywordtype}{void} *wchan, \textcolor{keywordtype}{int} pri)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00701}00701 \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00702}00702         \textcolor{keywordtype}{int} rcatch, rvalt, rvals;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00703}00703 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00704}00704         rcatch = \mbox{\hyperlink{subr__sleepqueue_8c_a2cfaa28e3f75239b8fff05d69007990a}{sleepq\_catch\_signals}}(wchan, pri);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00705}00705         \textcolor{comment}{/* We must always call check\_timeout() to clear sleeptimo. */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00706}00706         rvalt = \mbox{\hyperlink{subr__sleepqueue_8c_ae920e6e5394b64d8369c276a12b98f49}{sleepq\_check\_timeout}}();}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00707}00707         rvals = \mbox{\hyperlink{subr__sleepqueue_8c_a269f92a3ed92698b160244cf98d51b7a}{sleepq\_check\_signals}}();}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00708}00708         \textcolor{keywordflow}{if} (rcatch)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00709}00709                 \textcolor{keywordflow}{return} (rcatch);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00710}00710         \textcolor{keywordflow}{if} (rvals)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00711}00711                 \textcolor{keywordflow}{return} (rvals);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00712}00712         \textcolor{keywordflow}{return} (rvalt);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00713}00713 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00714}00714 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00715}00715 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00716}00716 \textcolor{comment}{ * Returns the type of sleepqueue given a waitchannel.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00717}00717 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00718}00718 \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00719}\mbox{\hyperlink{subr__sleepqueue_8c_a8c7ed1f37bf78606e06c47dd7d646e60}{00719}} \mbox{\hyperlink{subr__sleepqueue_8c_a8c7ed1f37bf78606e06c47dd7d646e60}{sleepq\_type}}(\textcolor{keyword}{const} \textcolor{keywordtype}{void} *wchan)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00720}00720 \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00721}00721         \textcolor{keyword}{struct }\mbox{\hyperlink{structsleepqueue}{sleepqueue}} *sq;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00722}00722         \textcolor{keywordtype}{int} \mbox{\hyperlink{group__BUS_ga0141f9c2e01a93ce25d669aa4851ec87}{type}};}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00723}00723 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00724}00724         MPASS(wchan != NULL);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00725}00725 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00726}00726         sq = \mbox{\hyperlink{subr__sleepqueue_8c_a0e37b7bc6c43d74e8073e92130d15864}{sleepq\_lookup}}(wchan);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00727}00727         \textcolor{keywordflow}{if} (sq == NULL)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00728}00728                 \textcolor{keywordflow}{return} (-\/1);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00729}00729         \mbox{\hyperlink{group__BUS_ga0141f9c2e01a93ce25d669aa4851ec87}{type}} = sq-\/>sq\_type;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00730}00730 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00731}00731         \textcolor{keywordflow}{return} (\mbox{\hyperlink{group__BUS_ga0141f9c2e01a93ce25d669aa4851ec87}{type}});}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00732}00732 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00733}00733 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00734}00734 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00735}00735 \textcolor{comment}{ * Removes a thread from a sleep queue and makes it}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00736}00736 \textcolor{comment}{ * runnable.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00737}00737 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00738}00738 \textcolor{comment}{ * Requires the sc chain locked on entry.  If SRQ\_HOLD is specified it will}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00739}00739 \textcolor{comment}{ * be locked on return.  Returns without the thread lock held.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00740}00740 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00741}00741 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00742}\mbox{\hyperlink{subr__sleepqueue_8c_a0b87894a4dc0cc1bd1957bd9e13cd5bc}{00742}} \mbox{\hyperlink{subr__sleepqueue_8c_a0b87894a4dc0cc1bd1957bd9e13cd5bc}{sleepq\_resume\_thread}}(\textcolor{keyword}{struct} \mbox{\hyperlink{structsleepqueue}{sleepqueue}} *sq, \textcolor{keyword}{struct} thread *td, \textcolor{keywordtype}{int} pri,}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00743}00743     \textcolor{keywordtype}{int} srqflags)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00744}00744 \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00745}00745         \textcolor{keyword}{struct }\mbox{\hyperlink{structsleepqueue__chain}{sleepqueue\_chain}} *sc;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00746}00746         \textcolor{keywordtype}{bool} drop;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00747}00747 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00748}00748         MPASS(td != NULL);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00749}00749         MPASS(sq-\/>sq\_wchan != NULL);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00750}00750         MPASS(td-\/>td\_wchan == sq-\/>sq\_wchan);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00751}00751 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00752}00752         sc = \mbox{\hyperlink{subr__sleepqueue_8c_aed1c1c8de67981699a715d02955c624c}{SC\_LOOKUP}}(sq-\/>sq\_wchan);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00753}00753         mtx\_assert(\&sc-\/>sc\_lock, MA\_OWNED);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00754}00754 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00755}00755         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00756}00756 \textcolor{comment}{         * Avoid recursing on the chain lock.  If the locks don't match we}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00757}00757 \textcolor{comment}{         * need to acquire the thread lock which setrunnable will drop for}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00758}00758 \textcolor{comment}{         * us.  In this case we need to drop the chain lock afterwards.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00759}00759 \textcolor{comment}{         *}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00760}00760 \textcolor{comment}{         * There is no race that will make td\_lock equal to sc\_lock because}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00761}00761 \textcolor{comment}{         * we hold sc\_lock.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00762}00762 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00763}00763         drop = \textcolor{keyword}{false};}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00764}00764         \textcolor{keywordflow}{if} (!TD\_IS\_SLEEPING(td)) \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00765}00765                 thread\_lock(td);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00766}00766                 drop = \textcolor{keyword}{true};}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00767}00767         \} \textcolor{keywordflow}{else}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00768}00768                 \mbox{\hyperlink{kern__mutex_8c_a94e84aff145edffc0e7b473febd346cc}{thread\_lock\_block\_wait}}(td);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00769}00769 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00770}00770         \textcolor{comment}{/* Remove thread from the sleepq. */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00771}00771         \mbox{\hyperlink{subr__sleepqueue_8c_aea091c09cc6a4ecd5b801506cd25c262}{sleepq\_remove\_thread}}(sq, td);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00772}00772 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00773}00773         \textcolor{comment}{/* If we're done with the sleepqueue release it. */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00774}00774         \textcolor{keywordflow}{if} ((srqflags \& SRQ\_HOLD) == 0 \&\& drop)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00775}00775                 mtx\_unlock\_spin(\&sc-\/>sc\_lock);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00776}00776 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00777}00777         \textcolor{comment}{/* Adjust priority if requested. */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00778}00778         MPASS(pri == 0 || (pri >= PRI\_MIN \&\& pri <= PRI\_MAX));}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00779}00779         \textcolor{keywordflow}{if} (pri != 0 \&\& td-\/>td\_priority > pri \&\&}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00780}00780             PRI\_BASE(td-\/>td\_pri\_class) == PRI\_TIMESHARE)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00781}00781                 \mbox{\hyperlink{sched__4bsd_8c_a798c873d2e4f42d44d2e8c1f88d9ace2}{sched\_prio}}(td, pri);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00782}00782 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00783}00783         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00784}00784 \textcolor{comment}{         * Note that thread td might not be sleeping if it is running}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00785}00785 \textcolor{comment}{         * sleepq\_catch\_signals() on another CPU or is blocked on its}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00786}00786 \textcolor{comment}{         * proc lock to check signals.  There's no need to mark the}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00787}00787 \textcolor{comment}{         * thread runnable in that case.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00788}00788 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00789}00789         \textcolor{keywordflow}{if} (TD\_IS\_SLEEPING(td)) \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00790}00790                 MPASS(!drop);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00791}00791                 TD\_CLR\_SLEEPING(td);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00792}00792                 \textcolor{keywordflow}{return} (\mbox{\hyperlink{kern__synch_8c_a907b1ce251d75aa35a0a74860bcbcaea}{setrunnable}}(td, srqflags));}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00793}00793         \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00794}00794         MPASS(drop);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00795}00795         thread\_unlock(td);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00796}00796 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00797}00797         \textcolor{keywordflow}{return} (0);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00798}00798 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00799}00799 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00800}00800 \textcolor{keyword}{static} \textcolor{keywordtype}{void}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00801}\mbox{\hyperlink{subr__sleepqueue_8c_aea091c09cc6a4ecd5b801506cd25c262}{00801}} \mbox{\hyperlink{subr__sleepqueue_8c_aea091c09cc6a4ecd5b801506cd25c262}{sleepq\_remove\_thread}}(\textcolor{keyword}{struct} \mbox{\hyperlink{structsleepqueue}{sleepqueue}} *sq, \textcolor{keyword}{struct} thread *td)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00802}00802 \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00803}00803         \textcolor{keyword}{struct }\mbox{\hyperlink{structsleepqueue__chain}{sleepqueue\_chain}} *sc \_\_unused;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00804}00804 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00805}00805         MPASS(td != NULL);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00806}00806         MPASS(sq-\/>sq\_wchan != NULL);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00807}00807         MPASS(td-\/>td\_wchan == sq-\/>sq\_wchan);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00808}00808         MPASS(td-\/>td\_sqqueue < \mbox{\hyperlink{subr__sleepqueue_8c_a51b446e9977c5c46691e73f05d9b9308}{NR\_SLEEPQS}} \&\& td-\/>td\_sqqueue >= 0);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00809}00809         THREAD\_LOCK\_ASSERT(td, MA\_OWNED);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00810}00810         sc = \mbox{\hyperlink{subr__sleepqueue_8c_aed1c1c8de67981699a715d02955c624c}{SC\_LOOKUP}}(sq-\/>sq\_wchan);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00811}00811         mtx\_assert(\&sc-\/>sc\_lock, MA\_OWNED);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00812}00812 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00813}00813         SDT\_PROBE2(sched, , , \mbox{\hyperlink{kern__synch_8c_ab5e31e48f559b1015c09a61a83c59f19}{wakeup}}, td, td-\/>td\_proc);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00814}00814 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00815}00815         \textcolor{comment}{/* Remove the thread from the queue. */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00816}00816         sq-\/>\mbox{\hyperlink{structsleepqueue_a439a41f50ae79d9f7b33e2d0a1f468dd}{sq\_blockedcnt}}[td-\/>td\_sqqueue]-\/-\/;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00817}00817         TAILQ\_REMOVE(\&sq-\/>\mbox{\hyperlink{structsleepqueue_a8afd5c01f6e71471d36a7270ff07ebe8}{sq\_blocked}}[td-\/>td\_sqqueue], td, td\_slpq);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00818}00818 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00819}00819         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00820}00820 \textcolor{comment}{         * Get a sleep queue for this thread.  If this is the last waiter,}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00821}00821 \textcolor{comment}{         * use the queue itself and take it out of the chain, otherwise,}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00822}00822 \textcolor{comment}{         * remove a queue from the free list.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00823}00823 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00824}00824         \textcolor{keywordflow}{if} (LIST\_EMPTY(\&sq-\/>sq\_free)) \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00825}00825                 td-\/>td\_sleepqueue = sq;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00826}00826 \textcolor{preprocessor}{\#ifdef INVARIANTS}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00827}00827                 sq-\/>sq\_wchan = NULL;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00828}00828 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00829}00829 \textcolor{preprocessor}{\#ifdef SLEEPQUEUE\_PROFILING}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00830}00830                 sc-\/>sc\_depth-\/-\/;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00831}00831 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00832}00832         \} \textcolor{keywordflow}{else}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00833}00833                 td-\/>td\_sleepqueue = LIST\_FIRST(\&sq-\/>sq\_free);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00834}00834         LIST\_REMOVE(td-\/>td\_sleepqueue, sq\_hash);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00835}00835 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00836}00836         \textcolor{keywordflow}{if} ((td-\/>td\_flags \& TDF\_TIMEOUT) == 0 \&\& td-\/>td\_sleeptimo != 0 \&\&}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00837}00837             td-\/>td\_lock == \&sc-\/>sc\_lock) \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00838}00838                 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00839}00839 \textcolor{comment}{                 * We ignore the situation where timeout subsystem was}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00840}00840 \textcolor{comment}{                 * unable to stop our callout.  The struct thread is}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00841}00841 \textcolor{comment}{                 * type-\/stable, the callout will use the correct}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00842}00842 \textcolor{comment}{                 * memory when running.  The checks of the}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00843}00843 \textcolor{comment}{                 * td\_sleeptimo value in this function and in}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00844}00844 \textcolor{comment}{                 * sleepq\_timeout() ensure that the thread does not}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00845}00845 \textcolor{comment}{                 * get spurious wakeups, even if the callout was reset}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00846}00846 \textcolor{comment}{                 * or thread reused.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00847}00847 \textcolor{comment}{                 *}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00848}00848 \textcolor{comment}{                 * We also cannot safely stop the callout if a scheduler}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00849}00849 \textcolor{comment}{                 * lock is held since softclock\_thread() forces a lock}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00850}00850 \textcolor{comment}{                 * order of callout lock -\/> scheduler lock.  The thread}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00851}00851 \textcolor{comment}{                 * lock will be a scheduler lock only if the thread is}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00852}00852 \textcolor{comment}{                 * preparing to go to sleep, so this is hopefully a rare}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00853}00853 \textcolor{comment}{                 * scenario.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00854}00854 \textcolor{comment}{                 */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00855}00855                 callout\_stop(\&td-\/>td\_slpcallout);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00856}00856         \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00857}00857 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00858}00858         td-\/>td\_wmesg = NULL;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00859}00859         td-\/>td\_wchan = NULL;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00860}00860         td-\/>td\_flags \&= \string~(TDF\_SINTR | TDF\_TIMEOUT);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00861}00861 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00862}00862         CTR3(KTR\_PROC, \textcolor{stringliteral}{"{}sleepq\_wakeup: thread \%p (pid \%ld, \%s)"{}},}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00863}00863             (\textcolor{keywordtype}{void} *)td, (\textcolor{keywordtype}{long})td-\/>td\_proc-\/>p\_pid, td-\/>td\_name);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00864}00864 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00865}00865 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00866}00866 \textcolor{keywordtype}{void}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00867}\mbox{\hyperlink{subr__sleepqueue_8c_a2d99dd7ccd6d1b291abb5b3c14eb03b9}{00867}} \mbox{\hyperlink{subr__sleepqueue_8c_a2d99dd7ccd6d1b291abb5b3c14eb03b9}{sleepq\_remove\_nested}}(\textcolor{keyword}{struct} thread *td)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00868}00868 \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00869}00869         \textcolor{keyword}{struct }\mbox{\hyperlink{structsleepqueue__chain}{sleepqueue\_chain}} *sc;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00870}00870         \textcolor{keyword}{struct }\mbox{\hyperlink{structsleepqueue}{sleepqueue}} *sq;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00871}00871         \textcolor{keyword}{const} \textcolor{keywordtype}{void} *wchan;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00872}00872 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00873}00873         MPASS(TD\_ON\_SLEEPQ(td));}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00874}00874 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00875}00875         wchan = td-\/>td\_wchan;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00876}00876         sc = \mbox{\hyperlink{subr__sleepqueue_8c_aed1c1c8de67981699a715d02955c624c}{SC\_LOOKUP}}(wchan);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00877}00877         mtx\_lock\_spin(\&sc-\/>sc\_lock);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00878}00878         sq = \mbox{\hyperlink{subr__sleepqueue_8c_a0e37b7bc6c43d74e8073e92130d15864}{sleepq\_lookup}}(wchan);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00879}00879         MPASS(sq != NULL);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00880}00880         thread\_lock(td);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00881}00881         \mbox{\hyperlink{subr__sleepqueue_8c_aea091c09cc6a4ecd5b801506cd25c262}{sleepq\_remove\_thread}}(sq, td);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00882}00882         mtx\_unlock\_spin(\&sc-\/>sc\_lock);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00883}00883         \textcolor{comment}{/* Returns with the thread lock owned. */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00884}00884 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00885}00885 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00886}00886 \textcolor{preprocessor}{\#ifdef INVARIANTS}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00887}00887 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00888}00888 \textcolor{comment}{ * UMA zone item deallocator.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00889}00889 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00890}00890 \textcolor{keyword}{static} \textcolor{keywordtype}{void}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00891}00891 sleepq\_dtor(\textcolor{keywordtype}{void} *mem, \textcolor{keywordtype}{int} size, \textcolor{keywordtype}{void} *arg)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00892}00892 \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00893}00893         \textcolor{keyword}{struct }\mbox{\hyperlink{structsleepqueue}{sleepqueue}} *sq;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00894}00894         \textcolor{keywordtype}{int} i;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00895}00895 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00896}00896         sq = mem;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00897}00897         \textcolor{keywordflow}{for} (i = 0; i < \mbox{\hyperlink{subr__sleepqueue_8c_a51b446e9977c5c46691e73f05d9b9308}{NR\_SLEEPQS}}; i++) \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00898}00898                 MPASS(TAILQ\_EMPTY(\&sq-\/>\mbox{\hyperlink{structsleepqueue_a8afd5c01f6e71471d36a7270ff07ebe8}{sq\_blocked}}[i]));}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00899}00899                 MPASS(sq-\/>\mbox{\hyperlink{structsleepqueue_a439a41f50ae79d9f7b33e2d0a1f468dd}{sq\_blockedcnt}}[i] == 0);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00900}00900         \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00901}00901 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00902}00902 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00903}00903 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00904}00904 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00905}00905 \textcolor{comment}{ * UMA zone item initializer.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00906}00906 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00907}00907 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00908}\mbox{\hyperlink{subr__sleepqueue_8c_a9b199d5393b0ef0e727057462ebde268}{00908}} \mbox{\hyperlink{subr__sleepqueue_8c_a9b199d5393b0ef0e727057462ebde268}{sleepq\_init}}(\textcolor{keywordtype}{void} *mem, \textcolor{keywordtype}{int} size, \textcolor{keywordtype}{int} \mbox{\hyperlink{subr__stats_8c_a1e87af3c18a2fd36c61faf89949bdc3f}{flags}})}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00909}00909 \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00910}00910         \textcolor{keyword}{struct }\mbox{\hyperlink{structsleepqueue}{sleepqueue}} *sq;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00911}00911         \textcolor{keywordtype}{int} i;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00912}00912 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00913}00913         bzero(mem, size);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00914}00914         sq = mem;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00915}00915         \textcolor{keywordflow}{for} (i = 0; i < \mbox{\hyperlink{subr__sleepqueue_8c_a51b446e9977c5c46691e73f05d9b9308}{NR\_SLEEPQS}}; i++) \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00916}00916                 TAILQ\_INIT(\&sq-\/>\mbox{\hyperlink{structsleepqueue_a8afd5c01f6e71471d36a7270ff07ebe8}{sq\_blocked}}[i]);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00917}00917                 sq-\/>\mbox{\hyperlink{structsleepqueue_a439a41f50ae79d9f7b33e2d0a1f468dd}{sq\_blockedcnt}}[i] = 0;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00918}00918         \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00919}00919         LIST\_INIT(\&sq-\/>sq\_free);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00920}00920         \textcolor{keywordflow}{return} (0);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00921}00921 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00922}00922 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00923}00923 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00924}00924 \textcolor{comment}{ * Find thread sleeping on a wait channel and resume it.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00925}00925 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00926}00926 \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00927}\mbox{\hyperlink{subr__sleepqueue_8c_a8e47b3f45894ca82fca0af34a0a0e7e5}{00927}} \mbox{\hyperlink{subr__sleepqueue_8c_a8e47b3f45894ca82fca0af34a0a0e7e5}{sleepq\_signal}}(\textcolor{keyword}{const} \textcolor{keywordtype}{void} *wchan, \textcolor{keywordtype}{int} \mbox{\hyperlink{subr__stats_8c_a1e87af3c18a2fd36c61faf89949bdc3f}{flags}}, \textcolor{keywordtype}{int} pri, \textcolor{keywordtype}{int} queue)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00928}00928 \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00929}00929         \textcolor{keyword}{struct }\mbox{\hyperlink{structsleepqueue__chain}{sleepqueue\_chain}} *sc;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00930}00930         \textcolor{keyword}{struct }\mbox{\hyperlink{structsleepqueue}{sleepqueue}} *sq;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00931}00931         \textcolor{keyword}{struct }threadqueue *head;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00932}00932         \textcolor{keyword}{struct }thread *td, *besttd;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00933}00933         \textcolor{keywordtype}{int} wakeup\_swapper;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00934}00934 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00935}00935         CTR2(KTR\_PROC, \textcolor{stringliteral}{"{}sleepq\_signal(\%p, \%d)"{}}, wchan, \mbox{\hyperlink{subr__stats_8c_a1e87af3c18a2fd36c61faf89949bdc3f}{flags}});}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00936}00936         KASSERT(wchan != NULL, (\textcolor{stringliteral}{"{}\%s: invalid NULL wait channel"{}}, \_\_func\_\_));}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00937}00937         MPASS((queue >= 0) \&\& (queue < \mbox{\hyperlink{subr__sleepqueue_8c_a51b446e9977c5c46691e73f05d9b9308}{NR\_SLEEPQS}}));}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00938}00938         sq = \mbox{\hyperlink{subr__sleepqueue_8c_a0e37b7bc6c43d74e8073e92130d15864}{sleepq\_lookup}}(wchan);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00939}00939         \textcolor{keywordflow}{if} (sq == NULL) \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00940}00940                 \textcolor{keywordflow}{if} (\mbox{\hyperlink{subr__stats_8c_a1e87af3c18a2fd36c61faf89949bdc3f}{flags}} \& SLEEPQ\_DROP)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00941}00941                         \mbox{\hyperlink{subr__sleepqueue_8c_a0157460dbeca34582ee4d5890b74fa15}{sleepq\_release}}(wchan);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00942}00942                 \textcolor{keywordflow}{return} (0);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00943}00943         \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00944}00944         KASSERT(sq-\/>sq\_type == (\mbox{\hyperlink{subr__stats_8c_a1e87af3c18a2fd36c61faf89949bdc3f}{flags}} \& SLEEPQ\_TYPE),}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00945}00945             (\textcolor{stringliteral}{"{}\%s: mismatch between sleep/wakeup and cv\_*"{}}, \_\_func\_\_));}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00946}00946 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00947}00947         head = \&sq-\/>\mbox{\hyperlink{structsleepqueue_a8afd5c01f6e71471d36a7270ff07ebe8}{sq\_blocked}}[queue];}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00948}00948         \textcolor{keywordflow}{if} (\mbox{\hyperlink{subr__stats_8c_a1e87af3c18a2fd36c61faf89949bdc3f}{flags}} \& SLEEPQ\_UNFAIR) \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00949}00949                 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00950}00950 \textcolor{comment}{                 * Find the most recently sleeping thread, but try to}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00951}00951 \textcolor{comment}{                 * skip threads still in process of context switch to}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00952}00952 \textcolor{comment}{                 * avoid spinning on the thread lock.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00953}00953 \textcolor{comment}{                 */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00954}00954                 sc = \mbox{\hyperlink{subr__sleepqueue_8c_aed1c1c8de67981699a715d02955c624c}{SC\_LOOKUP}}(wchan);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00955}00955                 besttd = TAILQ\_LAST\_FAST(head, thread, td\_slpq);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00956}00956                 \textcolor{keywordflow}{while} (besttd-\/>td\_lock != \&sc-\/>sc\_lock) \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00957}00957                         td = TAILQ\_PREV\_FAST(besttd, head, thread, td\_slpq);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00958}00958                         \textcolor{keywordflow}{if} (td == NULL)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00959}00959                                 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00960}00960                         besttd = td;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00961}00961                 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00962}00962         \} \textcolor{keywordflow}{else} \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00963}00963                 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00964}00964 \textcolor{comment}{                 * Find the highest priority thread on the queue.  If there}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00965}00965 \textcolor{comment}{                 * is a tie, use the thread that first appears in the queue}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00966}00966 \textcolor{comment}{                 * as it has been sleeping the longest since threads are}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00967}00967 \textcolor{comment}{                 * always added to the tail of sleep queues.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00968}00968 \textcolor{comment}{                 */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00969}00969                 besttd = td = TAILQ\_FIRST(head);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00970}00970                 \textcolor{keywordflow}{while} ((td = TAILQ\_NEXT(td, td\_slpq)) != NULL) \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00971}00971                         \textcolor{keywordflow}{if} (td-\/>td\_priority < besttd-\/>td\_priority)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00972}00972                                 besttd = td;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00973}00973                 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00974}00974         \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00975}00975         MPASS(besttd != NULL);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00976}00976         wakeup\_swapper = \mbox{\hyperlink{subr__sleepqueue_8c_a0b87894a4dc0cc1bd1957bd9e13cd5bc}{sleepq\_resume\_thread}}(sq, besttd, pri,}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00977}00977             (\mbox{\hyperlink{subr__stats_8c_a1e87af3c18a2fd36c61faf89949bdc3f}{flags}} \& SLEEPQ\_DROP) ? 0 : SRQ\_HOLD);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00978}00978         \textcolor{keywordflow}{return} (wakeup\_swapper);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00979}00979 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00980}00980 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00981}00981 \textcolor{keyword}{static} \textcolor{keywordtype}{bool}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00982}\mbox{\hyperlink{subr__sleepqueue_8c_a478ae9e78577a870be2553ea520aa11e}{00982}} \mbox{\hyperlink{subr__sleepqueue_8c_a478ae9e78577a870be2553ea520aa11e}{match\_any}}(\textcolor{keyword}{struct} thread *td \_\_unused)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00983}00983 \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00984}00984 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00985}00985         \textcolor{keywordflow}{return} (\textcolor{keyword}{true});}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00986}00986 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00987}00987 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00988}00988 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00989}00989 \textcolor{comment}{ * Resume all threads sleeping on a specified wait channel.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00990}00990 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00991}00991 \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00992}\mbox{\hyperlink{subr__sleepqueue_8c_a2c739ee96a9938ed1de78a8772311bd7}{00992}} \mbox{\hyperlink{subr__sleepqueue_8c_a2c739ee96a9938ed1de78a8772311bd7}{sleepq\_broadcast}}(\textcolor{keyword}{const} \textcolor{keywordtype}{void} *wchan, \textcolor{keywordtype}{int} \mbox{\hyperlink{subr__stats_8c_a1e87af3c18a2fd36c61faf89949bdc3f}{flags}}, \textcolor{keywordtype}{int} pri, \textcolor{keywordtype}{int} queue)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00993}00993 \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00994}00994         \textcolor{keyword}{struct }\mbox{\hyperlink{structsleepqueue}{sleepqueue}} *sq;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00995}00995 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00996}00996         CTR2(KTR\_PROC, \textcolor{stringliteral}{"{}sleepq\_broadcast(\%p, \%d)"{}}, wchan, \mbox{\hyperlink{subr__stats_8c_a1e87af3c18a2fd36c61faf89949bdc3f}{flags}});}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00997}00997         KASSERT(wchan != NULL, (\textcolor{stringliteral}{"{}\%s: invalid NULL wait channel"{}}, \_\_func\_\_));}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00998}00998         MPASS((queue >= 0) \&\& (queue < \mbox{\hyperlink{subr__sleepqueue_8c_a51b446e9977c5c46691e73f05d9b9308}{NR\_SLEEPQS}}));}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l00999}00999         sq = \mbox{\hyperlink{subr__sleepqueue_8c_a0e37b7bc6c43d74e8073e92130d15864}{sleepq\_lookup}}(wchan);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01000}01000         \textcolor{keywordflow}{if} (sq == NULL)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01001}01001                 \textcolor{keywordflow}{return} (0);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01002}01002         KASSERT(sq-\/>sq\_type == (\mbox{\hyperlink{subr__stats_8c_a1e87af3c18a2fd36c61faf89949bdc3f}{flags}} \& SLEEPQ\_TYPE),}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01003}01003             (\textcolor{stringliteral}{"{}\%s: mismatch between sleep/wakeup and cv\_*"{}}, \_\_func\_\_));}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01004}01004 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01005}01005         \textcolor{keywordflow}{return} (\mbox{\hyperlink{subr__sleepqueue_8c_a37f0e016dedaf4105240c0aa9139ee20}{sleepq\_remove\_matching}}(sq, queue, \mbox{\hyperlink{subr__sleepqueue_8c_a478ae9e78577a870be2553ea520aa11e}{match\_any}}, pri));}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01006}01006 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01007}01007 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01008}01008 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01009}01009 \textcolor{comment}{ * Resume threads on the sleep queue that match the given predicate.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01010}01010 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01011}01011 \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01012}\mbox{\hyperlink{subr__sleepqueue_8c_a37f0e016dedaf4105240c0aa9139ee20}{01012}} \mbox{\hyperlink{subr__sleepqueue_8c_a37f0e016dedaf4105240c0aa9139ee20}{sleepq\_remove\_matching}}(\textcolor{keyword}{struct} \mbox{\hyperlink{structsleepqueue}{sleepqueue}} *sq, \textcolor{keywordtype}{int} queue,}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01013}01013     \textcolor{keywordtype}{bool} (*matches)(\textcolor{keyword}{struct} thread *), \textcolor{keywordtype}{int} pri)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01014}01014 \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01015}01015         \textcolor{keyword}{struct }thread *td, *tdn;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01016}01016         \textcolor{keywordtype}{int} wakeup\_swapper;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01017}01017 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01018}01018         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01019}01019 \textcolor{comment}{         * The last thread will be given ownership of sq and may}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01020}01020 \textcolor{comment}{         * re-\/enqueue itself before sleepq\_resume\_thread() returns,}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01021}01021 \textcolor{comment}{         * so we must cache the "{}next"{} queue item at the beginning}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01022}01022 \textcolor{comment}{         * of the final iteration.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01023}01023 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01024}01024         wakeup\_swapper = 0;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01025}01025         TAILQ\_FOREACH\_SAFE(td, \&sq-\/>\mbox{\hyperlink{structsleepqueue_a8afd5c01f6e71471d36a7270ff07ebe8}{sq\_blocked}}[queue], td\_slpq, tdn) \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01026}01026                 \textcolor{keywordflow}{if} (matches(td))}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01027}01027                         wakeup\_swapper |= \mbox{\hyperlink{subr__sleepqueue_8c_a0b87894a4dc0cc1bd1957bd9e13cd5bc}{sleepq\_resume\_thread}}(sq, td, pri,}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01028}01028                             SRQ\_HOLD);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01029}01029         \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01030}01030 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01031}01031         \textcolor{keywordflow}{return} (wakeup\_swapper);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01032}01032 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01033}01033 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01034}01034 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01035}01035 \textcolor{comment}{ * Time sleeping threads out.  When the timeout expires, the thread is}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01036}01036 \textcolor{comment}{ * removed from the sleep queue and made runnable if it is still asleep.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01037}01037 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01038}01038 \textcolor{keyword}{static} \textcolor{keywordtype}{void}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01039}\mbox{\hyperlink{subr__sleepqueue_8c_abfa8981c0b0687d63b3285dc80d3330d}{01039}} \mbox{\hyperlink{subr__sleepqueue_8c_abfa8981c0b0687d63b3285dc80d3330d}{sleepq\_timeout}}(\textcolor{keywordtype}{void} *arg)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01040}01040 \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01041}01041         \textcolor{keyword}{struct }\mbox{\hyperlink{structsleepqueue__chain}{sleepqueue\_chain}} *sc \_\_unused;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01042}01042         \textcolor{keyword}{struct }\mbox{\hyperlink{structsleepqueue}{sleepqueue}} *sq;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01043}01043         \textcolor{keyword}{struct }thread *td;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01044}01044         \textcolor{keyword}{const} \textcolor{keywordtype}{void} *wchan;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01045}01045         \textcolor{keywordtype}{int} wakeup\_swapper;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01046}01046 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01047}01047         td = arg;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01048}01048         CTR3(KTR\_PROC, \textcolor{stringliteral}{"{}sleepq\_timeout: thread \%p (pid \%ld, \%s)"{}},}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01049}01049             (\textcolor{keywordtype}{void} *)td, (\textcolor{keywordtype}{long})td-\/>td\_proc-\/>p\_pid, (\textcolor{keywordtype}{void} *)td-\/>td\_name);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01050}01050 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01051}01051         thread\_lock(td);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01052}01052         \textcolor{keywordflow}{if} (td-\/>td\_sleeptimo == 0 ||}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01053}01053             td-\/>td\_sleeptimo > td-\/>td\_slpcallout.c\_time) \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01054}01054                 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01055}01055 \textcolor{comment}{                 * The thread does not want a timeout (yet).}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01056}01056 \textcolor{comment}{                 */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01057}01057         \} \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (TD\_IS\_SLEEPING(td) \&\& TD\_ON\_SLEEPQ(td)) \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01058}01058                 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01059}01059 \textcolor{comment}{                 * See if the thread is asleep and get the wait}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01060}01060 \textcolor{comment}{                 * channel if it is.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01061}01061 \textcolor{comment}{                 */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01062}01062                 wchan = td-\/>td\_wchan;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01063}01063                 sc = \mbox{\hyperlink{subr__sleepqueue_8c_aed1c1c8de67981699a715d02955c624c}{SC\_LOOKUP}}(wchan);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01064}01064                 THREAD\_LOCKPTR\_ASSERT(td, \&sc-\/>sc\_lock);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01065}01065                 sq = \mbox{\hyperlink{subr__sleepqueue_8c_a0e37b7bc6c43d74e8073e92130d15864}{sleepq\_lookup}}(wchan);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01066}01066                 MPASS(sq != NULL);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01067}01067                 td-\/>td\_flags |= TDF\_TIMEOUT;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01068}01068                 wakeup\_swapper = \mbox{\hyperlink{subr__sleepqueue_8c_a0b87894a4dc0cc1bd1957bd9e13cd5bc}{sleepq\_resume\_thread}}(sq, td, 0, 0);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01069}01069                 \textcolor{keywordflow}{if} (wakeup\_swapper)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01070}01070                         kick\_proc0();}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01071}01071                 \textcolor{keywordflow}{return};}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01072}01072         \} \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (TD\_ON\_SLEEPQ(td)) \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01073}01073                 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01074}01074 \textcolor{comment}{                 * If the thread is on the SLEEPQ but isn't sleeping}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01075}01075 \textcolor{comment}{                 * yet, it can either be on another CPU in between}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01076}01076 \textcolor{comment}{                 * sleepq\_add() and one of the sleepq\_*wait*()}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01077}01077 \textcolor{comment}{                 * routines or it can be in sleepq\_catch\_signals().}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01078}01078 \textcolor{comment}{                 */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01079}01079                 td-\/>td\_flags |= TDF\_TIMEOUT;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01080}01080         \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01081}01081         thread\_unlock(td);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01082}01082 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01083}01083 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01084}01084 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01085}01085 \textcolor{comment}{ * Resumes a specific thread from the sleep queue associated with a specific}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01086}01086 \textcolor{comment}{ * wait channel if it is on that queue.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01087}01087 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01088}01088 \textcolor{keywordtype}{void}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01089}\mbox{\hyperlink{subr__sleepqueue_8c_a60cddd9a90b4f8be77cfa6e9634498ba}{01089}} \mbox{\hyperlink{subr__sleepqueue_8c_a60cddd9a90b4f8be77cfa6e9634498ba}{sleepq\_remove}}(\textcolor{keyword}{struct} thread *td, \textcolor{keyword}{const} \textcolor{keywordtype}{void} *wchan)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01090}01090 \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01091}01091         \textcolor{keyword}{struct }\mbox{\hyperlink{structsleepqueue__chain}{sleepqueue\_chain}} *sc;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01092}01092         \textcolor{keyword}{struct }\mbox{\hyperlink{structsleepqueue}{sleepqueue}} *sq;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01093}01093         \textcolor{keywordtype}{int} wakeup\_swapper;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01094}01094 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01095}01095         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01096}01096 \textcolor{comment}{         * Look up the sleep queue for this wait channel, then re-\/check}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01097}01097 \textcolor{comment}{         * that the thread is asleep on that channel, if it is not, then}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01098}01098 \textcolor{comment}{         * bail.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01099}01099 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01100}01100         MPASS(wchan != NULL);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01101}01101         sc = \mbox{\hyperlink{subr__sleepqueue_8c_aed1c1c8de67981699a715d02955c624c}{SC\_LOOKUP}}(wchan);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01102}01102         mtx\_lock\_spin(\&sc-\/>sc\_lock);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01103}01103         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01104}01104 \textcolor{comment}{         * We can not lock the thread here as it may be sleeping on a}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01105}01105 \textcolor{comment}{         * different sleepq.  However, holding the sleepq lock for this}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01106}01106 \textcolor{comment}{         * wchan can guarantee that we do not miss a wakeup for this}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01107}01107 \textcolor{comment}{         * channel.  The asserts below will catch any false positives.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01108}01108 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01109}01109         \textcolor{keywordflow}{if} (!TD\_ON\_SLEEPQ(td) || td-\/>td\_wchan != wchan) \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01110}01110                 mtx\_unlock\_spin(\&sc-\/>sc\_lock);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01111}01111                 \textcolor{keywordflow}{return};}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01112}01112         \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01113}01113 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01114}01114         \textcolor{comment}{/* Thread is asleep on sleep queue sq, so wake it up. */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01115}01115         sq = \mbox{\hyperlink{subr__sleepqueue_8c_a0e37b7bc6c43d74e8073e92130d15864}{sleepq\_lookup}}(wchan);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01116}01116         MPASS(sq != NULL);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01117}01117         MPASS(td-\/>td\_wchan == wchan);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01118}01118         wakeup\_swapper = \mbox{\hyperlink{subr__sleepqueue_8c_a0b87894a4dc0cc1bd1957bd9e13cd5bc}{sleepq\_resume\_thread}}(sq, td, 0, 0);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01119}01119         \textcolor{keywordflow}{if} (wakeup\_swapper)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01120}01120                 kick\_proc0();}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01121}01121 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01122}01122 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01123}01123 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01124}01124 \textcolor{comment}{ * Abort a thread as if an interrupt had occurred.  Only abort}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01125}01125 \textcolor{comment}{ * interruptible waits (unfortunately it isn't safe to abort others).}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01126}01126 \textcolor{comment}{ *}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01127}01127 \textcolor{comment}{ * Requires thread lock on entry, releases on return.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01128}01128 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01129}01129 \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01130}\mbox{\hyperlink{subr__sleepqueue_8c_aed564b9db54d91b798349fe4bea35295}{01130}} \mbox{\hyperlink{subr__sleepqueue_8c_aed564b9db54d91b798349fe4bea35295}{sleepq\_abort}}(\textcolor{keyword}{struct} thread *td, \textcolor{keywordtype}{int} intrval)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01131}01131 \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01132}01132         \textcolor{keyword}{struct }\mbox{\hyperlink{structsleepqueue}{sleepqueue}} *sq;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01133}01133         \textcolor{keyword}{const} \textcolor{keywordtype}{void} *wchan;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01134}01134 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01135}01135         THREAD\_LOCK\_ASSERT(td, MA\_OWNED);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01136}01136         MPASS(TD\_ON\_SLEEPQ(td));}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01137}01137         MPASS(td-\/>td\_flags \& TDF\_SINTR);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01138}01138         MPASS((intrval == 0 \&\& (td-\/>td\_flags \& TDF\_SIGWAIT) != 0) ||}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01139}01139             intrval == EINTR || intrval == ERESTART);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01140}01140 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01141}01141         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01142}01142 \textcolor{comment}{         * If the TDF\_TIMEOUT flag is set, just leave. A}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01143}01143 \textcolor{comment}{         * timeout is scheduled anyhow.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01144}01144 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01145}01145         \textcolor{keywordflow}{if} (td-\/>td\_flags \& TDF\_TIMEOUT) \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01146}01146                 thread\_unlock(td);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01147}01147                 \textcolor{keywordflow}{return} (0);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01148}01148         \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01149}01149 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01150}01150         CTR3(KTR\_PROC, \textcolor{stringliteral}{"{}sleepq\_abort: thread \%p (pid \%ld, \%s)"{}},}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01151}01151             (\textcolor{keywordtype}{void} *)td, (\textcolor{keywordtype}{long})td-\/>td\_proc-\/>p\_pid, (\textcolor{keywordtype}{void} *)td-\/>td\_name);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01152}01152         td-\/>td\_intrval = intrval;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01153}01153 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01154}01154         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01155}01155 \textcolor{comment}{         * If the thread has not slept yet it will find the signal in}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01156}01156 \textcolor{comment}{         * sleepq\_catch\_signals() and call sleepq\_resume\_thread.  Otherwise}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01157}01157 \textcolor{comment}{         * we have to do it here.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01158}01158 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01159}01159         \textcolor{keywordflow}{if} (!TD\_IS\_SLEEPING(td)) \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01160}01160                 thread\_unlock(td);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01161}01161                 \textcolor{keywordflow}{return} (0);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01162}01162         \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01163}01163         wchan = td-\/>td\_wchan;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01164}01164         MPASS(wchan != NULL);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01165}01165         sq = \mbox{\hyperlink{subr__sleepqueue_8c_a0e37b7bc6c43d74e8073e92130d15864}{sleepq\_lookup}}(wchan);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01166}01166         MPASS(sq != NULL);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01167}01167 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01168}01168         \textcolor{comment}{/* Thread is asleep on sleep queue sq, so wake it up. */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01169}01169         \textcolor{keywordflow}{return} (\mbox{\hyperlink{subr__sleepqueue_8c_a0b87894a4dc0cc1bd1957bd9e13cd5bc}{sleepq\_resume\_thread}}(sq, td, 0, 0));}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01170}01170 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01171}01171 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01172}01172 \textcolor{keywordtype}{void}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01173}\mbox{\hyperlink{subr__sleepqueue_8c_a881b4ca63bf22269c910c8fa0e11f335}{01173}} \mbox{\hyperlink{subr__sleepqueue_8c_a881b4ca63bf22269c910c8fa0e11f335}{sleepq\_chains\_remove\_matching}}(\textcolor{keywordtype}{bool} (*matches)(\textcolor{keyword}{struct} thread *))}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01174}01174 \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01175}01175         \textcolor{keyword}{struct }\mbox{\hyperlink{structsleepqueue__chain}{sleepqueue\_chain}} *sc;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01176}01176         \textcolor{keyword}{struct }\mbox{\hyperlink{structsleepqueue}{sleepqueue}} *sq, *sq1;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01177}01177         \textcolor{keywordtype}{int} i, wakeup\_swapper;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01178}01178 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01179}01179         wakeup\_swapper = 0;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01180}01180         \textcolor{keywordflow}{for} (sc = \&\mbox{\hyperlink{subr__sleepqueue_8c_a85cd25b29ad496ce638931fa7a460b10}{sleepq\_chains}}[0]; sc < \mbox{\hyperlink{subr__sleepqueue_8c_a85cd25b29ad496ce638931fa7a460b10}{sleepq\_chains}} + \mbox{\hyperlink{subr__sleepqueue_8c_a9c9580acd9e79bc40e085bdf500210a4}{SC\_TABLESIZE}}; ++sc) \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01181}01181                 \textcolor{keywordflow}{if} (LIST\_EMPTY(\&sc-\/>sc\_queues)) \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01182}01182                         \textcolor{keywordflow}{continue};}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01183}01183                 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01184}01184                 mtx\_lock\_spin(\&sc-\/>sc\_lock);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01185}01185                 LIST\_FOREACH\_SAFE(sq, \&sc-\/>sc\_queues, sq\_hash, sq1) \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01186}01186                         \textcolor{keywordflow}{for} (i = 0; i < \mbox{\hyperlink{subr__sleepqueue_8c_a51b446e9977c5c46691e73f05d9b9308}{NR\_SLEEPQS}}; ++i) \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01187}01187                                 wakeup\_swapper |= \mbox{\hyperlink{subr__sleepqueue_8c_a37f0e016dedaf4105240c0aa9139ee20}{sleepq\_remove\_matching}}(sq, i,}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01188}01188                                     matches, 0);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01189}01189                         \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01190}01190                 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01191}01191                 mtx\_unlock\_spin(\&sc-\/>sc\_lock);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01192}01192         \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01193}01193         \textcolor{keywordflow}{if} (wakeup\_swapper) \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01194}01194                 kick\_proc0();}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01195}01195         \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01196}01196 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01197}01197 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01198}01198 \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01199}01199 \textcolor{comment}{ * Prints the stacks of all threads presently sleeping on wchan/queue to}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01200}01200 \textcolor{comment}{ * the sbuf sb.  Sets count\_stacks\_printed to the number of stacks actually}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01201}01201 \textcolor{comment}{ * printed.  Typically, this will equal the number of threads sleeping on the}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01202}01202 \textcolor{comment}{ * queue, but may be less if sb overflowed before all stacks were printed.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01203}01203 \textcolor{comment}{ */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01204}01204 \textcolor{preprocessor}{\#ifdef STACK}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01205}01205 \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01206}01206 sleepq\_sbuf\_print\_stacks(\textcolor{keyword}{struct} sbuf *sb, \textcolor{keyword}{const} \textcolor{keywordtype}{void} *wchan, \textcolor{keywordtype}{int} queue,}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01207}01207     \textcolor{keywordtype}{int} *count\_stacks\_printed)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01208}01208 \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01209}01209         \textcolor{keyword}{struct }thread *td, *td\_next;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01210}01210         \textcolor{keyword}{struct }\mbox{\hyperlink{structsleepqueue}{sleepqueue}} *sq;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01211}01211         \textcolor{keyword}{struct }stack **\mbox{\hyperlink{kern__boottrace_8c_ab0419db3c2ed9e9d1cadb7b425a097f9}{st}};}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01212}01212         \textcolor{keyword}{struct }sbuf **td\_infos;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01213}01213         \textcolor{keywordtype}{int} i, stack\_idx, error, stacks\_to\_allocate;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01214}01214         \textcolor{keywordtype}{bool} finished;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01215}01215 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01216}01216         error = 0;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01217}01217         finished = \textcolor{keyword}{false};}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01218}01218 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01219}01219         KASSERT(wchan != NULL, (\textcolor{stringliteral}{"{}\%s: invalid NULL wait channel"{}}, \_\_func\_\_));}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01220}01220         MPASS((queue >= 0) \&\& (queue < \mbox{\hyperlink{subr__sleepqueue_8c_a51b446e9977c5c46691e73f05d9b9308}{NR\_SLEEPQS}}));}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01221}01221 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01222}01222         stacks\_to\_allocate = 10;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01223}01223         \textcolor{keywordflow}{for} (i = 0; i < 3 \&\& !finished ; i++) \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01224}01224                 \textcolor{comment}{/* We cannot malloc while holding the queue's spinlock, so}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01225}01225 \textcolor{comment}{                 * we do our mallocs now, and hope it is enough.  If it}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01226}01226 \textcolor{comment}{                 * isn't, we will free these, drop the lock, malloc more,}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01227}01227 \textcolor{comment}{                 * and try again, up to a point.  After that point we will}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01228}01228 \textcolor{comment}{                 * give up and report ENOMEM. We also cannot write to sb}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01229}01229 \textcolor{comment}{                 * during this time since the client may have set the}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01230}01230 \textcolor{comment}{                 * SBUF\_AUTOEXTEND flag on their sbuf, which could cause a}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01231}01231 \textcolor{comment}{                 * malloc as we print to it.  So we defer actually printing}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01232}01232 \textcolor{comment}{                 * to sb until after we drop the spinlock.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01233}01233 \textcolor{comment}{                 */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01234}01234 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01235}01235                 \textcolor{comment}{/* Where we will store the stacks. */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01236}01236                 \mbox{\hyperlink{kern__boottrace_8c_ab0419db3c2ed9e9d1cadb7b425a097f9}{st}} = \mbox{\hyperlink{kern__malloc_8c_a13e924a88f20870d2d55e3f7fb660352}{malloc}}(\textcolor{keyword}{sizeof}(\textcolor{keyword}{struct} stack *) * stacks\_to\_allocate,}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01237}01237                     M\_TEMP, M\_WAITOK);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01238}01238                 \textcolor{keywordflow}{for} (stack\_idx = 0; stack\_idx < stacks\_to\_allocate;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01239}01239                     stack\_idx++)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01240}01240                         \mbox{\hyperlink{kern__boottrace_8c_ab0419db3c2ed9e9d1cadb7b425a097f9}{st}}[stack\_idx] = \mbox{\hyperlink{subr__stack_8c_a31df1ec95ee869d8a71ffd71b4d6e751}{stack\_create}}(M\_WAITOK);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01241}01241 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01242}01242                 \textcolor{comment}{/* Where we will store the td name, tid, etc. */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01243}01243                 td\_infos = \mbox{\hyperlink{kern__malloc_8c_a13e924a88f20870d2d55e3f7fb660352}{malloc}}(\textcolor{keyword}{sizeof}(\textcolor{keyword}{struct} sbuf *) * stacks\_to\_allocate,}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01244}01244                     M\_TEMP, M\_WAITOK);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01245}01245                 \textcolor{keywordflow}{for} (stack\_idx = 0; stack\_idx < stacks\_to\_allocate;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01246}01246                     stack\_idx++)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01247}01247                         td\_infos[stack\_idx] = \mbox{\hyperlink{subr__sbuf_8c_ad3cd536452958687b5d1e0005b232f8e}{sbuf\_new}}(NULL, NULL,}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01248}01248                             MAXCOMLEN + \textcolor{keyword}{sizeof}(\textcolor{keyword}{struct} thread *) * 2 + 40,}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01249}01249                             SBUF\_FIXEDLEN);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01250}01250 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01251}01251                 \mbox{\hyperlink{subr__sleepqueue_8c_ae0a612e63d885f5b440f1c0e84652baf}{sleepq\_lock}}(wchan);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01252}01252                 sq = \mbox{\hyperlink{subr__sleepqueue_8c_a0e37b7bc6c43d74e8073e92130d15864}{sleepq\_lookup}}(wchan);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01253}01253                 \textcolor{keywordflow}{if} (sq == NULL) \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01254}01254                         \textcolor{comment}{/* This sleepq does not exist; exit and return ENOENT. */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01255}01255                         error = ENOENT;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01256}01256                         finished = \textcolor{keyword}{true};}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01257}01257                         \mbox{\hyperlink{subr__sleepqueue_8c_a0157460dbeca34582ee4d5890b74fa15}{sleepq\_release}}(wchan);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01258}01258                         \textcolor{keywordflow}{goto} loop\_end;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01259}01259                 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01260}01260 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01261}01261                 stack\_idx = 0;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01262}01262                 \textcolor{comment}{/* Save thread info */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01263}01263                 TAILQ\_FOREACH\_SAFE(td, \&sq-\/>\mbox{\hyperlink{structsleepqueue_a8afd5c01f6e71471d36a7270ff07ebe8}{sq\_blocked}}[queue], td\_slpq,}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01264}01264                     td\_next) \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01265}01265                         \textcolor{keywordflow}{if} (stack\_idx >= stacks\_to\_allocate)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01266}01266                                 \textcolor{keywordflow}{goto} loop\_end;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01267}01267 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01268}01268                         \textcolor{comment}{/* Note the td\_lock is equal to the sleepq\_lock here. */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01269}01269                         (void)stack\_save\_td(\mbox{\hyperlink{kern__boottrace_8c_ab0419db3c2ed9e9d1cadb7b425a097f9}{st}}[stack\_idx], td);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01270}01270 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01271}01271                         \mbox{\hyperlink{subr__sbuf_8c_a6c6abdb7c0c9a19d892b1d07757dd056}{sbuf\_printf}}(td\_infos[stack\_idx], \textcolor{stringliteral}{"{}\%d: \%s \%p"{}},}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01272}01272                             td-\/>td\_tid, td-\/>td\_name, td);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01273}01273 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01274}01274                         ++stack\_idx;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01275}01275                 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01276}01276 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01277}01277                 finished = \textcolor{keyword}{true};}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01278}01278                 \mbox{\hyperlink{subr__sleepqueue_8c_a0157460dbeca34582ee4d5890b74fa15}{sleepq\_release}}(wchan);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01279}01279 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01280}01280                 \textcolor{comment}{/* Print the stacks */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01281}01281                 \textcolor{keywordflow}{for} (i = 0; i < stack\_idx; i++) \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01282}01282                         \mbox{\hyperlink{subr__sbuf_8c_a29e35276bb1dcf4342f5a49ec3d0068a}{sbuf\_finish}}(td\_infos[i]);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01283}01283                         \mbox{\hyperlink{subr__sbuf_8c_a6c6abdb7c0c9a19d892b1d07757dd056}{sbuf\_printf}}(sb, \textcolor{stringliteral}{"{}-\/-\/-\/ thread \%s: -\/-\/-\/\(\backslash\)n"{}}, \mbox{\hyperlink{subr__sbuf_8c_a852f3538d102353413a73cea9f2efd1f}{sbuf\_data}}(td\_infos[i]));}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01284}01284                         \mbox{\hyperlink{subr__stack_8c_ad081b79677914fef23738c49276807e4}{stack\_sbuf\_print}}(sb, \mbox{\hyperlink{kern__boottrace_8c_ab0419db3c2ed9e9d1cadb7b425a097f9}{st}}[i]);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01285}01285                         \mbox{\hyperlink{subr__sbuf_8c_a6c6abdb7c0c9a19d892b1d07757dd056}{sbuf\_printf}}(sb, \textcolor{stringliteral}{"{}\(\backslash\)n"{}});}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01286}01286 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01287}01287                         error = \mbox{\hyperlink{subr__sbuf_8c_a8d3a74fa8648102d62e687d5932252c9}{sbuf\_error}}(sb);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01288}01288                         \textcolor{keywordflow}{if} (error == 0)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01289}01289                                 *count\_stacks\_printed = stack\_idx;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01290}01290                 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01291}01291 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01292}01292 loop\_end:}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01293}01293                 \textcolor{keywordflow}{if} (!finished)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01294}01294                         \mbox{\hyperlink{subr__sleepqueue_8c_a0157460dbeca34582ee4d5890b74fa15}{sleepq\_release}}(wchan);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01295}01295                 \textcolor{keywordflow}{for} (stack\_idx = 0; stack\_idx < stacks\_to\_allocate;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01296}01296                     stack\_idx++)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01297}01297                         \mbox{\hyperlink{subr__stack_8c_a31a5e23d1e9e00a13c0d663f8aac528f}{stack\_destroy}}(\mbox{\hyperlink{kern__boottrace_8c_ab0419db3c2ed9e9d1cadb7b425a097f9}{st}}[stack\_idx]);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01298}01298                 \textcolor{keywordflow}{for} (stack\_idx = 0; stack\_idx < stacks\_to\_allocate;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01299}01299                     stack\_idx++)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01300}01300                         \mbox{\hyperlink{subr__sbuf_8c_a60934581249642aa5f426992ace71542}{sbuf\_delete}}(td\_infos[stack\_idx]);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01301}01301                 \mbox{\hyperlink{kern__malloc_8c_af6592f7dfb186f55f99e52892336fff0}{free}}(\mbox{\hyperlink{kern__boottrace_8c_ab0419db3c2ed9e9d1cadb7b425a097f9}{st}}, M\_TEMP);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01302}01302                 \mbox{\hyperlink{kern__malloc_8c_af6592f7dfb186f55f99e52892336fff0}{free}}(td\_infos, M\_TEMP);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01303}01303                 stacks\_to\_allocate *= 10;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01304}01304         \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01305}01305 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01306}01306         \textcolor{keywordflow}{if} (!finished \&\& error == 0)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01307}01307                 error = ENOMEM;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01308}01308 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01309}01309         \textcolor{keywordflow}{return} (error);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01310}01310 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01311}01311 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01312}01312 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01313}01313 \textcolor{preprocessor}{\#ifdef SLEEPQUEUE\_PROFILING}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01314}01314 \textcolor{preprocessor}{\#define SLEEPQ\_PROF\_LOCATIONS   1024}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01315}01315 \textcolor{preprocessor}{\#define SLEEPQ\_SBUFSIZE         512}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01316}01316 \textcolor{keyword}{struct }sleepq\_prof \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01317}01317         LIST\_ENTRY(sleepq\_prof) sp\_link;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01318}01318         \textcolor{keyword}{const} \textcolor{keywordtype}{char}      *sp\_wmesg;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01319}01319         \textcolor{keywordtype}{long}            sp\_count;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01320}01320 \};}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01321}01321 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01322}01322 \mbox{\hyperlink{kern__alq_8c_afc8bb74c7e13909590e320029ed68586}{LIST\_HEAD}}(sqphead, sleepq\_prof);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01323}01323 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01324}01324 \textcolor{keyword}{struct }sqphead sleepq\_prof\_free;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01325}01325 \textcolor{keyword}{struct }sqphead sleepq\_hash[\mbox{\hyperlink{subr__sleepqueue_8c_a9c9580acd9e79bc40e085bdf500210a4}{SC\_TABLESIZE}}];}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01326}01326 \textcolor{keyword}{static} \textcolor{keyword}{struct }sleepq\_prof sleepq\_profent[SLEEPQ\_PROF\_LOCATIONS];}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01327}01327 \textcolor{keyword}{static} \textcolor{keyword}{struct }\mbox{\hyperlink{uipc__ktls_8c_a7b5de10a04be6deb16c42cef5da02110}{mtx}} sleepq\_prof\_lock;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01328}01328 \mbox{\hyperlink{kern__et_8c_aee0c3a77bbd5ad269269621bf93fa9de}{MTX\_SYSINIT}}(sleepq\_prof\_lock, \&sleepq\_prof\_lock, \textcolor{stringliteral}{"{}sleepq\_prof"{}}, MTX\_SPIN);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01329}01329 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01330}01330 \textcolor{keyword}{static} \textcolor{keywordtype}{void}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01331}01331 sleepq\_profile(\textcolor{keyword}{const} \textcolor{keywordtype}{char} *wmesg)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01332}01332 \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01333}01333         \textcolor{keyword}{struct }sleepq\_prof *sp;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01334}01334 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01335}01335         mtx\_lock\_spin(\&sleepq\_prof\_lock);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01336}01336         \textcolor{keywordflow}{if} (prof\_enabled == 0)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01337}01337                 \textcolor{keywordflow}{goto} unlock;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01338}01338         LIST\_FOREACH(sp, \&sleepq\_hash[\mbox{\hyperlink{subr__sleepqueue_8c_a8af60d8683dfa6e26b85c861652fee0d}{SC\_HASH}}(wmesg)], sp\_link)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01339}01339                 \textcolor{keywordflow}{if} (sp-\/>sp\_wmesg == wmesg)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01340}01340                         \textcolor{keywordflow}{goto} done;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01341}01341         sp = LIST\_FIRST(\&sleepq\_prof\_free);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01342}01342         \textcolor{keywordflow}{if} (sp == NULL)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01343}01343                 \textcolor{keywordflow}{goto} unlock;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01344}01344         sp-\/>sp\_wmesg = wmesg;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01345}01345         LIST\_REMOVE(sp, sp\_link);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01346}01346         LIST\_INSERT\_HEAD(\&sleepq\_hash[\mbox{\hyperlink{subr__sleepqueue_8c_a8af60d8683dfa6e26b85c861652fee0d}{SC\_HASH}}(wmesg)], sp, sp\_link);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01347}01347 done:}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01348}01348         sp-\/>sp\_count++;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01349}01349 unlock:}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01350}01350         mtx\_unlock\_spin(\&sleepq\_prof\_lock);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01351}01351         \textcolor{keywordflow}{return};}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01352}01352 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01353}01353 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01354}01354 \textcolor{keyword}{static} \textcolor{keywordtype}{void}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01355}01355 sleepq\_prof\_reset(\textcolor{keywordtype}{void})}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01356}01356 \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01357}01357         \textcolor{keyword}{struct }sleepq\_prof *sp;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01358}01358         \textcolor{keywordtype}{int} enabled;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01359}01359         \textcolor{keywordtype}{int} i;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01360}01360 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01361}01361         mtx\_lock\_spin(\&sleepq\_prof\_lock);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01362}01362         enabled = prof\_enabled;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01363}01363         prof\_enabled = 0;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01364}01364         \textcolor{keywordflow}{for} (i = 0; i < \mbox{\hyperlink{subr__sleepqueue_8c_a9c9580acd9e79bc40e085bdf500210a4}{SC\_TABLESIZE}}; i++)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01365}01365                 LIST\_INIT(\&sleepq\_hash[i]);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01366}01366         LIST\_INIT(\&sleepq\_prof\_free);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01367}01367         \textcolor{keywordflow}{for} (i = 0; i < SLEEPQ\_PROF\_LOCATIONS; i++) \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01368}01368                 sp = \&sleepq\_profent[i];}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01369}01369                 sp-\/>sp\_wmesg = NULL;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01370}01370                 sp-\/>sp\_count = 0;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01371}01371                 LIST\_INSERT\_HEAD(\&sleepq\_prof\_free, sp, sp\_link);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01372}01372         \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01373}01373         prof\_enabled = enabled;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01374}01374         mtx\_unlock\_spin(\&sleepq\_prof\_lock);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01375}01375 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01376}01376 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01377}01377 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01378}01378 enable\_sleepq\_prof(SYSCTL\_HANDLER\_ARGS)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01379}01379 \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01380}01380         \textcolor{keywordtype}{int} error, v;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01381}01381 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01382}01382         v = prof\_enabled;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01383}01383         error = \mbox{\hyperlink{kern__sysctl_8c_aab82ede27ea5d6975c4e91eb6c6111b7}{sysctl\_handle\_int}}(oidp, \&v, v, req);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01384}01384         \textcolor{keywordflow}{if} (error)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01385}01385                 \textcolor{keywordflow}{return} (error);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01386}01386         \textcolor{keywordflow}{if} (req-\/>newptr == NULL)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01387}01387                 \textcolor{keywordflow}{return} (error);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01388}01388         \textcolor{keywordflow}{if} (v == prof\_enabled)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01389}01389                 \textcolor{keywordflow}{return} (0);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01390}01390         \textcolor{keywordflow}{if} (v == 1)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01391}01391                 sleepq\_prof\_reset();}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01392}01392         mtx\_lock\_spin(\&sleepq\_prof\_lock);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01393}01393         prof\_enabled = !!v;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01394}01394         mtx\_unlock\_spin(\&sleepq\_prof\_lock);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01395}01395 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01396}01396         \textcolor{keywordflow}{return} (0);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01397}01397 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01398}01398 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01399}01399 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01400}01400 reset\_sleepq\_prof\_stats(SYSCTL\_HANDLER\_ARGS)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01401}01401 \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01402}01402         \textcolor{keywordtype}{int} error, v;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01403}01403 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01404}01404         v = 0;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01405}01405         error = \mbox{\hyperlink{kern__sysctl_8c_aab82ede27ea5d6975c4e91eb6c6111b7}{sysctl\_handle\_int}}(oidp, \&v, 0, req);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01406}01406         \textcolor{keywordflow}{if} (error)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01407}01407                 \textcolor{keywordflow}{return} (error);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01408}01408         \textcolor{keywordflow}{if} (req-\/>newptr == NULL)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01409}01409                 \textcolor{keywordflow}{return} (error);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01410}01410         \textcolor{keywordflow}{if} (v == 0)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01411}01411                 \textcolor{keywordflow}{return} (0);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01412}01412         sleepq\_prof\_reset();}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01413}01413 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01414}01414         \textcolor{keywordflow}{return} (0);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01415}01415 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01416}01416 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01417}01417 \textcolor{keyword}{static} \textcolor{keywordtype}{int}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01418}01418 dump\_sleepq\_prof\_stats(SYSCTL\_HANDLER\_ARGS)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01419}01419 \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01420}01420         \textcolor{keyword}{struct }sleepq\_prof *sp;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01421}01421         \textcolor{keyword}{struct }sbuf *sb;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01422}01422         \textcolor{keywordtype}{int} enabled;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01423}01423         \textcolor{keywordtype}{int} error;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01424}01424         \textcolor{keywordtype}{int} i;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01425}01425 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01426}01426         error = \mbox{\hyperlink{kern__sysctl_8c_a591f82d54efedffb48467e9519bd4eba}{sysctl\_wire\_old\_buffer}}(req, 0);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01427}01427         \textcolor{keywordflow}{if} (error != 0)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01428}01428                 \textcolor{keywordflow}{return} (error);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01429}01429         sb = \mbox{\hyperlink{kern__sysctl_8c_af7691ec0fcb72946d348acb4222ce572}{sbuf\_new\_for\_sysctl}}(NULL, NULL, SLEEPQ\_SBUFSIZE, req);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01430}01430         \mbox{\hyperlink{subr__sbuf_8c_a6c6abdb7c0c9a19d892b1d07757dd056}{sbuf\_printf}}(sb, \textcolor{stringliteral}{"{}\(\backslash\)nwmesg\(\backslash\)tcount\(\backslash\)n"{}});}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01431}01431         enabled = prof\_enabled;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01432}01432         mtx\_lock\_spin(\&sleepq\_prof\_lock);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01433}01433         prof\_enabled = 0;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01434}01434         mtx\_unlock\_spin(\&sleepq\_prof\_lock);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01435}01435         \textcolor{keywordflow}{for} (i = 0; i < \mbox{\hyperlink{subr__sleepqueue_8c_a9c9580acd9e79bc40e085bdf500210a4}{SC\_TABLESIZE}}; i++) \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01436}01436                 LIST\_FOREACH(sp, \&sleepq\_hash[i], sp\_link) \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01437}01437                         \mbox{\hyperlink{subr__sbuf_8c_a6c6abdb7c0c9a19d892b1d07757dd056}{sbuf\_printf}}(sb, \textcolor{stringliteral}{"{}\%s\(\backslash\)t\%ld\(\backslash\)n"{}},}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01438}01438                             sp-\/>sp\_wmesg, sp-\/>sp\_count);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01439}01439                 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01440}01440         \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01441}01441         mtx\_lock\_spin(\&sleepq\_prof\_lock);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01442}01442         prof\_enabled = enabled;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01443}01443         mtx\_unlock\_spin(\&sleepq\_prof\_lock);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01444}01444 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01445}01445         error = \mbox{\hyperlink{subr__sbuf_8c_a29e35276bb1dcf4342f5a49ec3d0068a}{sbuf\_finish}}(sb);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01446}01446         \mbox{\hyperlink{subr__sbuf_8c_a60934581249642aa5f426992ace71542}{sbuf\_delete}}(sb);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01447}01447         \textcolor{keywordflow}{return} (error);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01448}01448 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01449}01449 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01450}01450 \mbox{\hyperlink{imgact__binmisc_8c_ab102523114ab5e342a91cf4d6d564381}{SYSCTL\_PROC}}(\_debug\_sleepq, OID\_AUTO, stats,}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01451}01451     CTLTYPE\_STRING | CTLFLAG\_RD | CTLFLAG\_NEEDGIANT, NULL, 0,}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01452}01452     dump\_sleepq\_prof\_stats, \textcolor{stringliteral}{"{}A"{}},}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01453}01453     \textcolor{stringliteral}{"{}Sleepqueue profiling statistics"{}});}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01454}01454 \mbox{\hyperlink{imgact__binmisc_8c_ab102523114ab5e342a91cf4d6d564381}{SYSCTL\_PROC}}(\_debug\_sleepq, OID\_AUTO, reset,}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01455}01455     CTLTYPE\_INT | CTLFLAG\_RW | CTLFLAG\_MPSAFE, NULL, 0,}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01456}01456     reset\_sleepq\_prof\_stats, \textcolor{stringliteral}{"{}I"{}},}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01457}01457     \textcolor{stringliteral}{"{}Reset sleepqueue profiling statistics"{}});}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01458}01458 \mbox{\hyperlink{imgact__binmisc_8c_ab102523114ab5e342a91cf4d6d564381}{SYSCTL\_PROC}}(\_debug\_sleepq, OID\_AUTO, enable,}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01459}01459     CTLTYPE\_INT | CTLFLAG\_RW | CTLFLAG\_MPSAFE, NULL, 0,}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01460}01460     enable\_sleepq\_prof, \textcolor{stringliteral}{"{}I"{}},}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01461}01461     \textcolor{stringliteral}{"{}Enable sleepqueue profiling"{}});}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01462}01462 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01463}01463 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01464}01464 \textcolor{preprocessor}{\#ifdef DDB}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01465}01465 DB\_SHOW\_COMMAND(sleepq, db\_show\_sleepqueue)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01466}01466 \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01467}01467         \textcolor{keyword}{struct }\mbox{\hyperlink{structsleepqueue__chain}{sleepqueue\_chain}} *sc;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01468}01468         \textcolor{keyword}{struct }\mbox{\hyperlink{structsleepqueue}{sleepqueue}} *sq;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01469}01469 \textcolor{preprocessor}{\#ifdef INVARIANTS}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01470}01470         \textcolor{keyword}{struct }lock\_object *lock;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01471}01471 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01472}01472         \textcolor{keyword}{struct }thread *td;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01473}01473         \textcolor{keywordtype}{void} *wchan;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01474}01474         \textcolor{keywordtype}{int} i;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01475}01475 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01476}01476         \textcolor{keywordflow}{if} (!have\_addr)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01477}01477                 \textcolor{keywordflow}{return};}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01478}01478 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01479}01479         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01480}01480 \textcolor{comment}{         * First, see if there is an active sleep queue for the wait channel}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01481}01481 \textcolor{comment}{         * indicated by the address.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01482}01482 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01483}01483         wchan = (\textcolor{keywordtype}{void} *)\mbox{\hyperlink{msi__if_8m_a7345ae8680eeb32913b762d1d5e502b4}{addr}};}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01484}01484         sc = \mbox{\hyperlink{subr__sleepqueue_8c_aed1c1c8de67981699a715d02955c624c}{SC\_LOOKUP}}(wchan);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01485}01485         LIST\_FOREACH(sq, \&sc-\/>sc\_queues, sq\_hash)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01486}01486                 \textcolor{keywordflow}{if} (sq-\/>sq\_wchan == wchan)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01487}01487                         \textcolor{keywordflow}{goto} found;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01488}01488 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01489}01489         \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01490}01490 \textcolor{comment}{         * Second, see if there is an active sleep queue at the address}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01491}01491 \textcolor{comment}{         * indicated.}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01492}01492 \textcolor{comment}{         */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01493}01493         \textcolor{keywordflow}{for} (i = 0; i < \mbox{\hyperlink{subr__sleepqueue_8c_a9c9580acd9e79bc40e085bdf500210a4}{SC\_TABLESIZE}}; i++)}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01494}01494                 LIST\_FOREACH(sq, \&\mbox{\hyperlink{subr__sleepqueue_8c_a85cd25b29ad496ce638931fa7a460b10}{sleepq\_chains}}[i].sc\_queues, sq\_hash) \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01495}01495                         \textcolor{keywordflow}{if} (sq == (\textcolor{keyword}{struct} \mbox{\hyperlink{structsleepqueue}{sleepqueue}} *)\mbox{\hyperlink{msi__if_8m_a7345ae8680eeb32913b762d1d5e502b4}{addr}})}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01496}01496                                 \textcolor{keywordflow}{goto} found;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01497}01497                 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01498}01498 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01499}01499         db\_printf(\textcolor{stringliteral}{"{}Unable to locate a sleep queue via \%p\(\backslash\)n"{}}, (\textcolor{keywordtype}{void} *)\mbox{\hyperlink{msi__if_8m_a7345ae8680eeb32913b762d1d5e502b4}{addr}});}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01500}01500         \textcolor{keywordflow}{return};}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01501}01501 found:}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01502}01502         db\_printf(\textcolor{stringliteral}{"{}Wait channel: \%p\(\backslash\)n"{}}, sq-\/>sq\_wchan);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01503}01503         db\_printf(\textcolor{stringliteral}{"{}Queue type: \%d\(\backslash\)n"{}}, sq-\/>sq\_type);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01504}01504 \textcolor{preprocessor}{\#ifdef INVARIANTS}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01505}01505         \textcolor{keywordflow}{if} (sq-\/>sq\_lock) \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01506}01506                 lock = sq-\/>sq\_lock;}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01507}01507                 db\_printf(\textcolor{stringliteral}{"{}Associated Interlock: \%p -\/ (\%s) \%s\(\backslash\)n"{}}, lock,}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01508}01508                     LOCK\_CLASS(lock)-\/>lc\_name, lock-\/>lo\_name);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01509}01509         \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01510}01510 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01511}01511         db\_printf(\textcolor{stringliteral}{"{}Blocked threads:\(\backslash\)n"{}});}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01512}01512         \textcolor{keywordflow}{for} (i = 0; i < \mbox{\hyperlink{subr__sleepqueue_8c_a51b446e9977c5c46691e73f05d9b9308}{NR\_SLEEPQS}}; i++) \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01513}01513                 db\_printf(\textcolor{stringliteral}{"{}\(\backslash\)nQueue[\%d]:\(\backslash\)n"{}}, i);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01514}01514                 \textcolor{keywordflow}{if} (TAILQ\_EMPTY(\&sq-\/>\mbox{\hyperlink{structsleepqueue_a8afd5c01f6e71471d36a7270ff07ebe8}{sq\_blocked}}[i]))}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01515}01515                         db\_printf(\textcolor{stringliteral}{"{}\(\backslash\)tempty\(\backslash\)n"{}});}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01516}01516                 \textcolor{keywordflow}{else}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01517}01517                         TAILQ\_FOREACH(td, \&sq-\/>\mbox{\hyperlink{structsleepqueue_a8afd5c01f6e71471d36a7270ff07ebe8}{sq\_blocked}}[i],}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01518}01518                                       td\_slpq) \{}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01519}01519                                 db\_printf(\textcolor{stringliteral}{"{}\(\backslash\)t\%p (tid \%d, pid \%d, \(\backslash\)"{}\%s\(\backslash\)"{})\(\backslash\)n"{}}, td,}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01520}01520                                           td-\/>td\_tid, td-\/>td\_proc-\/>p\_pid,}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01521}01521                                           td-\/>td\_name);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01522}01522                         \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01523}01523                 db\_printf(\textcolor{stringliteral}{"{}(expected: \%u)\(\backslash\)n"{}}, sq-\/>\mbox{\hyperlink{structsleepqueue_a439a41f50ae79d9f7b33e2d0a1f468dd}{sq\_blockedcnt}}[i]);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01524}01524         \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01525}01525 \}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01526}01526 }
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01527}01527 \textcolor{comment}{/* Alias 'show sleepqueue' to 'show sleepq'. */}}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01528}01528 DB\_SHOW\_ALIAS(\mbox{\hyperlink{structsleepqueue}{sleepqueue}}, db\_show\_sleepqueue);}
\DoxyCodeLine{\Hypertarget{subr__sleepqueue_8c_source_l01529}01529 \textcolor{preprocessor}{\#endif}}

\end{DoxyCode}
