2001-03-05 01:42:05 +01:00
|
|
|
/*-
|
|
|
|
* See the file LICENSE for redistribution information.
|
|
|
|
*
|
2002-10-30 12:57:05 +01:00
|
|
|
* Copyright (c) 1997-2002
|
2001-03-05 01:42:05 +01:00
|
|
|
* Sleepycat Software. All rights reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "db_config.h"
|
|
|
|
|
|
|
|
#ifndef lint
|
2002-10-30 12:57:05 +01:00
|
|
|
static const char revid[] = "$Id: os_spin.c,v 11.11 2002/07/12 18:56:56 bostic Exp $";
|
2001-03-05 01:42:05 +01:00
|
|
|
#endif /* not lint */
|
|
|
|
|
|
|
|
#include "db_int.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* __os_spin --
|
|
|
|
* Return the number of default spins before blocking.
|
|
|
|
*/
|
|
|
|
int
|
2002-10-30 12:57:05 +01:00
|
|
|
__os_spin(dbenv)
|
|
|
|
DB_ENV *dbenv;
|
2001-03-05 01:42:05 +01:00
|
|
|
{
|
|
|
|
SYSTEM_INFO SystemInfo;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the application specified a value or we've already figured it
|
|
|
|
* out, return it.
|
|
|
|
*/
|
2002-10-30 12:57:05 +01:00
|
|
|
if (dbenv->tas_spins != 0)
|
|
|
|
return (dbenv->tas_spins);
|
2001-03-05 01:42:05 +01:00
|
|
|
|
|
|
|
/* Get the number of processors */
|
|
|
|
GetSystemInfo(&SystemInfo);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Spin 50 times per processor -- we have anecdotal evidence that this
|
|
|
|
* is a reasonable value.
|
|
|
|
*/
|
|
|
|
if (SystemInfo.dwNumberOfProcessors > 1)
|
2002-10-30 12:57:05 +01:00
|
|
|
dbenv->tas_spins = 50 * SystemInfo.dwNumberOfProcessors;
|
2001-03-05 01:42:05 +01:00
|
|
|
else
|
2002-10-30 12:57:05 +01:00
|
|
|
dbenv->tas_spins = 1;
|
|
|
|
return (dbenv->tas_spins);
|
2001-03-05 01:42:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* __os_yield --
|
|
|
|
* Yield the processor.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
__os_yield(dbenv, usecs)
|
|
|
|
DB_ENV *dbenv;
|
|
|
|
u_long usecs;
|
|
|
|
{
|
2002-10-30 12:57:05 +01:00
|
|
|
if (DB_GLOBAL(j_yield) != NULL && DB_GLOBAL(j_yield)() == 0)
|
2001-03-05 01:42:05 +01:00
|
|
|
return;
|
|
|
|
__os_sleep(dbenv, 0, usecs);
|
|
|
|
}
|