2 * See the file LICENSE for redistribution information.
4 * Copyright (c) 1997, 1998
5 * Sleepycat Software. All rights reserved.
11 static const char sccsid
[] = "@(#)os_spin.c 10.7 (Sleepycat) 5/20/98";
14 #ifndef NO_SYSTEM_INCLUDES
15 #include <sys/types.h>
25 * Return the number of default spins before blocking.
27 * PUBLIC: int __os_spin __P((void));
34 /* If the application specified the spins, use its value. */
35 if (DB_GLOBAL(db_tsl_spins
) != 0)
36 return (DB_GLOBAL(db_tsl_spins
));
38 /* If we've already figured this out, return the value. */
44 * Solaris and Linux use _SC_NPROCESSORS_ONLN to return the number of
45 * online processors. We don't want to repeatedly call sysconf because
46 * it's quite expensive (requiring multiple filesystem accesses) under
49 * Spin 50 times per processor -- we have anecdotal evidence that this
50 * is a reasonable value.
52 #if defined(HAVE_SYSCONF) && defined(_SC_NPROCESSORS_ONLN)
53 if ((sys_val
= sysconf(_SC_NPROCESSORS_ONLN
)) > 1)