1/*- 2 * See the file LICENSE for redistribution information. 3 * 4 * Copyright (c) 1997,2008 Oracle. All rights reserved. 5 * 6 * $Id: os_yield.c,v 12.13 2008/01/08 20:58:46 bostic Exp $ 7 */ 8 9#include "db_config.h" 10 11#include "db_int.h" 12 13/* 14 * __os_yield -- 15 * Yield the processor, optionally pausing until running again. 16 */ 17void 18__os_yield(env, secs, usecs) 19 ENV *env; 20 u_long secs, usecs; /* Seconds and microseconds. */ 21{ 22 COMPQUIET(env, NULL); 23 24 /* Don't require the values be normalized. */ 25 for (; usecs >= US_PER_SEC; usecs -= US_PER_SEC) 26 ++secs; 27 28 /* 29 * Yield the processor so other processes or threads can run. 30 * 31 * Sheer raving paranoia -- don't sleep for 0 time, in case some 32 * implementation doesn't yield the processor in that case. 33 */ 34 Sleep(secs * MS_PER_SEC + (usecs / US_PER_MS) + 1); 35} 36