Main Page | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Related Pages

os_spin.c

00001 /*-
00002  * See the file LICENSE for redistribution information.
00003  *
00004  * Copyright (c) 1997-2005
00005  *      Sleepycat Software.  All rights reserved.
00006  *
00007  * $Id: os_spin.c,v 12.2 2005/07/20 16:52:02 bostic Exp $
00008  */
00009 
00010 #include "db_config.h"
00011 
00012 #include "db_int.h"
00013 
00014 /*
00015  * __os_spin --
00016  *      Return the number of default spins before blocking.
00017  */
00018 u_int32_t
00019 __os_spin(dbenv)
00020         DB_ENV *dbenv;
00021 {
00022         SYSTEM_INFO SystemInfo;
00023         u_int32_t tas_spins;
00024 
00025         /* Get the number of processors */
00026         GetSystemInfo(&SystemInfo);
00027 
00028         /*
00029          * Spin 50 times per processor -- we have anecdotal evidence that this
00030          * is a reasonable value.
00031          */
00032         if (SystemInfo.dwNumberOfProcessors > 1)
00033                  tas_spins = 50 * SystemInfo.dwNumberOfProcessors;
00034         else
00035                  tas_spins = 1;
00036 
00037         return (tas_spins);
00038 }
00039 
00040 /*
00041  * __os_yield --
00042  *      Yield the processor.
00043  */
00044 void
00045 __os_yield(dbenv, usecs)
00046         DB_ENV *dbenv;
00047         u_long usecs;
00048 {
00049         if (DB_GLOBAL(j_yield) != NULL && DB_GLOBAL(j_yield)() == 0)
00050                 return;
00051         __os_sleep(dbenv, 0, usecs);
00052 }

Generated on Sun Dec 25 12:14:42 2005 for Berkeley DB 4.4.16 by  doxygen 1.4.2