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

os_sleep.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_sleep.c,v 12.1 2005/06/16 20:23:30 bostic Exp $
00008  */
00009 
00010 #include "db_config.h"
00011 
00012 #include "db_int.h"
00013 
00014 /*
00015  * __os_sleep --
00016  *      Yield the processor for a period of time.
00017  */
00018 void
00019 __os_sleep(dbenv, secs, usecs)
00020         DB_ENV *dbenv;
00021         u_long secs, usecs;             /* Seconds and microseconds. */
00022 {
00023         COMPQUIET(dbenv, NULL);
00024 
00025         /* Don't require that the values be normalized. */
00026         for (; usecs >= 1000000; ++secs, usecs -= 1000000)
00027                 ;
00028 
00029         if (DB_GLOBAL(j_sleep) != NULL) {
00030                 DB_GLOBAL(j_sleep)(secs, usecs);
00031                 return;
00032         }
00033 
00034         /*
00035          * It's important that we yield the processor here so that other
00036          * processes or threads are permitted to run.
00037          */
00038         Sleep(secs * 1000 + usecs / 1000);
00039 }

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