Logo Search packages:      
Sourcecode: virtualbox-ose version File versions  Download package

void kHlpSleep ( unsigned  cMillies  ) 

Sleep for a number of milliseconds.

Parameters:
cMillies Number of milliseconds to sleep.

Definition at line 57 of file kHlpBareThread.c.

References K_FALSE, K_TRUE, and K_UNKNOWN.

Referenced by kldrInit().

{
#if K_OS == K_OS_DARWIN
    static struct mach_timebase_info   s_Info;
    static KBOOL                s_fNanoseconds = K_UNKNOWN;
    KU64 uNow = mach_absolute_time();
    KU64 uDeadline;
    KU64 uPeriod;

    if (s_fNanoseconds == K_UNKNOWN)
    {
        if (mach_timebase_info(&s_Info))
            s_fNanoseconds = K_TRUE; /* the easy way out */
        else if (s_Info.denom == s_Info.numer)
            s_fNanoseconds = K_TRUE;
        else
            s_fNanoseconds = K_FALSE;
    }

    uPeriod = (KU64)cMillies * 1000 * 1000;
    if (!s_fNanoseconds)
        uPeriod = (double)uPeriod * s_Info.denom / s_Info.numer; /* Use double to avoid 32-bit trouble. */
    uDeadline = uNow + uPeriod;
    mach_wait_until(uDeadline);

#elif K_OS == K_OS_LINUX
    /** @todo find the right syscall... */

#elif K_OS == K_OS_OS2
    DosSleep(cMillies);
#elif  K_OS == K_OS_WINDOWS
    Sleep(cMillies);
#else
    usleep(cMillies * 1000);
#endif
}


Generated by  Doxygen 1.6.0   Back to index