kern_synch.c (126755) | kern_synch.c (126885) |
---|---|
1/*- 2 * Copyright (c) 1982, 1986, 1990, 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 25 unchanged lines hidden (view full) --- 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)kern_synch.c 8.9 (Berkeley) 5/19/95 39 */ 40 41#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1982, 1986, 1990, 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 25 unchanged lines hidden (view full) --- 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)kern_synch.c 8.9 (Berkeley) 5/19/95 39 */ 40 41#include <sys/cdefs.h> |
42__FBSDID("$FreeBSD: head/sys/kern/kern_synch.c 126755 2004-03-08 22:01:19Z rwatson $"); | 42__FBSDID("$FreeBSD: head/sys/kern/kern_synch.c 126885 2004-03-12 19:06:18Z jhb $"); |
43 44#include "opt_ddb.h" 45#include "opt_ktrace.h" 46 47#include <sys/param.h> 48#include <sys/systm.h> 49#include <sys/condvar.h> 50#include <sys/kernel.h> --- 43 unchanged lines hidden (view full) --- 94 95/* kernel uses `FSCALE', userland (SHOULD) use kern.fscale */ 96static int fscale __unused = FSCALE; 97SYSCTL_INT(_kern, OID_AUTO, fscale, CTLFLAG_RD, 0, FSCALE, ""); 98 99static void loadav(void *arg); 100static void lboltcb(void *arg); 101 | 43 44#include "opt_ddb.h" 45#include "opt_ktrace.h" 46 47#include <sys/param.h> 48#include <sys/systm.h> 49#include <sys/condvar.h> 50#include <sys/kernel.h> --- 43 unchanged lines hidden (view full) --- 94 95/* kernel uses `FSCALE', userland (SHOULD) use kern.fscale */ 96static int fscale __unused = FSCALE; 97SYSCTL_INT(_kern, OID_AUTO, fscale, CTLFLAG_RD, 0, FSCALE, ""); 98 99static void loadav(void *arg); 100static void lboltcb(void *arg); 101 |
102/* 103 * We're only looking at 7 bits of the address; everything is 104 * aligned to 4, lots of things are aligned to greater powers 105 * of 2. Shift right by 8, i.e. drop the bottom 256 worth. 106 */ 107#define TABLESIZE 128 108static TAILQ_HEAD(slpquehead, thread) slpque[TABLESIZE]; 109#define LOOKUP(x) (((intptr_t)(x) >> 8) & (TABLESIZE - 1)) 110 | |
111void 112sleepinit(void) 113{ | 102void 103sleepinit(void) 104{ |
114 int i; | |
115 116 hogticks = (hz / 10) * 2; /* Default only. */ | 105 106 hogticks = (hz / 10) * 2; /* Default only. */ |
117 for (i = 0; i < TABLESIZE; i++) 118 TAILQ_INIT(&slpque[i]); | |
119 init_sleepqueues(); 120} 121 122/* 123 * General sleep call. Suspends the current process until a wakeup is 124 * performed on the specified identifier. The process will then be made 125 * runnable with the specified priority. Sleeps at most timo/hz seconds 126 * (0 means no timeout). If pri includes PCATCH flag, signals are checked --- 104 unchanged lines hidden (view full) --- 231 * and a wakeup or a SIGCONT (or both) could occur while we were 232 * stopped without resuming us. Thus, we must be ready for sleep 233 * when cursig() is called. If the wakeup happens while we're 234 * stopped, then td will no longer be on a sleep queue upon 235 * return from cursig(). 236 */ 237 sleepq_add(sq, ident, mtx, wmesg, 0); 238 if (timo) | 107 init_sleepqueues(); 108} 109 110/* 111 * General sleep call. Suspends the current process until a wakeup is 112 * performed on the specified identifier. The process will then be made 113 * runnable with the specified priority. Sleeps at most timo/hz seconds 114 * (0 means no timeout). If pri includes PCATCH flag, signals are checked --- 104 unchanged lines hidden (view full) --- 219 * and a wakeup or a SIGCONT (or both) could occur while we were 220 * stopped without resuming us. Thus, we must be ready for sleep 221 * when cursig() is called. If the wakeup happens while we're 222 * stopped, then td will no longer be on a sleep queue upon 223 * return from cursig(). 224 */ 225 sleepq_add(sq, ident, mtx, wmesg, 0); 226 if (timo) |
239 sleepq_set_timeout(sq, ident, timo); | 227 sleepq_set_timeout(ident, timo); |
240 if (catch) { 241 sig = sleepq_catch_signals(ident); 242 if (sig == 0 && !TD_ON_SLEEPQ(td)) { 243 mtx_lock_spin(&sched_lock); 244 td->td_flags &= ~TDF_SINTR; 245 mtx_unlock_spin(&sched_lock); 246 catch = 0; 247 } --- 256 unchanged lines hidden --- | 228 if (catch) { 229 sig = sleepq_catch_signals(ident); 230 if (sig == 0 && !TD_ON_SLEEPQ(td)) { 231 mtx_lock_spin(&sched_lock); 232 td->td_flags &= ~TDF_SINTR; 233 mtx_unlock_spin(&sched_lock); 234 catch = 0; 235 } --- 256 unchanged lines hidden --- |