VirtualBox

Changeset 39443 in vbox


Ignore:
Timestamp:
Nov 28, 2011 3:01:21 PM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
75079
Message:

Introduced RTThreadSleepNoLog for spinlocking in the electric fence heap. (Caused trouble with all logging enabled.)

Location:
trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/mangling.h

    r39378 r39443  
    14681468# define RTThreadSetType                                RT_MANGLER(RTThreadSetType)
    14691469# define RTThreadSleep                                  RT_MANGLER(RTThreadSleep)
     1470# define RTThreadSleepNoLog                             RT_MANGLER(RTThreadSleepNoLog)
    14701471# define RTThreadStateName                              RT_MANGLER(RTThreadStateName)
    14711472# define RTThreadUnblocked                              RT_MANGLER(RTThreadUnblocked)
  • trunk/include/iprt/thread.h

    r37154 r39443  
    201201 */
    202202RTDECL(int) RTThreadSleep(RTMSINTERVAL cMillies);
     203
     204/**
     205 * Millisecond granular sleep function, no logger calls.
     206 *
     207 * Same as RTThreadSleep, except it will never call into the IPRT logger.  It
     208 * can therefore safely be used in places where the logger is off limits, like
     209 * at termination or init time.  The electric fence heap is one consumer of
     210 * this API.
     211 *
     212 * @returns VINF_SUCCESS on success.
     213 * @returns VERR_INTERRUPTED if a signal or other asynchronous stuff happened
     214 *          which interrupt the peaceful sleep.
     215 * @param   cMillies    Number of milliseconds to sleep.
     216 *                      0 milliseconds means yielding the timeslice - deprecated!
     217 */
     218RTDECL(int) RTThreadSleepNoLog(RTMSINTERVAL cMillies);
    203219
    204220/**
  • trunk/src/VBox/Runtime/r0drv/darwin/thread-r0drv-darwin.cpp

    r28800 r39443  
    4444
    4545
    46 RTDECL(int) RTThreadSleep(RTMSINTERVAL cMillies)
     46static int rtR0ThreadDarwinSleepCommon(RTMSINTERVAL cMillies)
    4747{
    4848    RT_ASSERT_PREEMPTIBLE();
     
    5151    clock_delay_until(u64Deadline);
    5252    return VINF_SUCCESS;
     53}
     54
     55
     56RTDECL(int) RTThreadSleep(RTMSINTERVAL cMillies)
     57{
     58    return rtR0ThreadDarwinSleepCommon(cMillies);
     59}
     60
     61
     62RTDECL(int) RTThreadSleepNoLog(RTMSINTERVAL cMillies)
     63{
     64    return rtR0ThreadDarwinSleepCommon(cMillies);
    5365}
    5466
  • trunk/src/VBox/Runtime/r0drv/freebsd/thread-r0drv-freebsd.c

    r35960 r39443  
    4646
    4747
    48 RTDECL(int) RTThreadSleep(RTMSINTERVAL cMillies)
     48static int rtR0ThreadFbsdSleepCommon(RTMSINTERVAL cMillies)
    4949{
    5050    int rc;
     
    9797            return VERR_NO_TRANSLATION;
    9898    }
     99}
     100
     101
     102RTDECL(int) RTThreadSleep(RTMSINTERVAL cMillies)
     103{
     104    return rtR0ThreadFbsdSleepCommon(cMillies);
     105}
     106
     107
     108RTDECL(int) RTThreadSleepNoLog(RTMSINTERVAL cMillies)
     109{
     110    return rtR0ThreadFbsdSleepCommon(cMillies);
    99111}
    100112
  • trunk/src/VBox/Runtime/r0drv/linux/thread-r0drv-linux.c

    r33358 r39443  
    5858
    5959
    60 RTDECL(int) RTThreadSleep(RTMSINTERVAL cMillies)
     60static int rtR0ThreadLnxSleepCommon(RTMSINTERVAL cMillies)
    6161{
    6262    long cJiffies = msecs_to_jiffies(cMillies);
     
    6767    return VERR_INTERRUPTED;
    6868}
     69
     70
     71RTDECL(int) RTThreadSleep(RTMSINTERVAL cMillies)
     72{
     73    return rtR0ThreadLnxSleepCommon(cMillies);
     74}
    6975RT_EXPORT_SYMBOL(RTThreadSleep);
     76
     77
     78RTDECL(int) RTThreadSleepNoLog(RTMSINTERVAL cMillies)
     79{
     80    return rtR0ThreadLnxSleepCommon(cMillies);
     81}
     82RT_EXPORT_SYMBOL(RTThreadSleepNoLog);
    7083
    7184
  • trunk/src/VBox/Runtime/r0drv/nt/thread-r0drv-nt.cpp

    r30359 r39443  
    5252
    5353
    54 RTDECL(int)   RTThreadSleep(RTMSINTERVAL cMillies)
     54static int rtR0ThreadNtSleepCommon(RTMSINTERVAL cMillies)
    5555{
    5656    LARGE_INTEGER Interval;
     
    6767            return RTErrConvertFromNtStatus(rcNt);
    6868    }
     69}
     70
     71
     72RTDECL(int)   RTThreadSleep(RTMSINTERVAL cMillies)
     73{
     74    return rtR0ThreadNtSleepCommon(cMillies);
     75}
     76
     77
     78RTDECL(int)   RTThreadSleepCommon(RTMSINTERVAL cMillies)
     79{
     80    return rtR0ThreadNtSleepCommon(cMillies);
    6981}
    7082
  • trunk/src/VBox/Runtime/r0drv/os2/thread-r0drv-os2.cpp

    r33393 r39443  
    6060
    6161
    62 RTDECL(int) RTThreadSleep(RTMSINTERVAL cMillies)
     62static int rtR0ThreadOs2SleepCommon(RTMSINTERVAL cMillies)
    6363{
    6464    int rc = KernBlock((ULONG)RTThreadSleep,
     
    7777            return VERR_NO_TRANSLATION;
    7878    }
     79}
     80
     81
     82RTDECL(int) RTThreadSleep(RTMSINTERVAL cMillies)
     83{
     84    return rtR0ThreadOs2SleepCommon(cMillies);
     85}
     86
     87
     88RTDECL(int) RTThreadSleepNoBlock(RTMSINTERVAL cMillies)
     89{
     90    return rtR0ThreadOs2SleepCommon(cMillies);
    7991}
    8092
  • trunk/src/VBox/Runtime/r0drv/solaris/vbi/thread-r0drv-solaris.c

    r29281 r39443  
    4848
    4949
    50 RTDECL(int) RTThreadSleep(RTMSINTERVAL cMillies)
     50static int rtR0ThreadSolSleepCommon(RTMSINTERVAL cMillies)
    5151{
    5252    clock_t cTicks;
     
    5555    if (!cMillies)
    5656    {
    57         RTThreadYield();
     57        vbi_yield();
    5858        return VINF_SUCCESS;
    5959    }
     
    6666    delay(cTicks);
    6767    return VINF_SUCCESS;
     68}
     69
     70
     71RTDECL(int) RTThreadSleep(RTMSINTERVAL cMillies)
     72{
     73    return rtR0ThreadSolSleepCommon(cMillies);
     74}
     75
     76
     77RTDECL(int) RTThreadSleepNoLog(RTMSINTERVAL cMillies)
     78{
     79    return rtR0ThreadSolSleepCommon(cMillies);
    6880}
    6981
  • trunk/src/VBox/Runtime/r3/alloc-ef.cpp

    r39091 r39443  
    111111    unsigned c = 0;
    112112    while (!ASMAtomicCmpXchgU32(&g_BlocksLock, 1, 0))
    113         RTThreadSleep(((++c) >> 2) & 31);
     113        RTThreadSleepNoLog(((++c) >> 2) & 31);
    114114}
    115115
  • trunk/src/VBox/Runtime/r3/os2/thread-os2.cpp

    r37154 r39443  
    188188
    189189
     190RTDECL(int)   RTThreadSleepNoLog(RTMSINTERVAL cMillies)
     191{
     192    DosSleep(cMillies);
     193    return VINF_SUCCESS;
     194}
     195
     196
    190197RTDECL(bool) RTThreadYield(void)
    191198{
  • trunk/src/VBox/Runtime/r3/posix/thread2-posix.cpp

    r37733 r39443  
    9393
    9494
     95RTDECL(int) RTThreadSleepNoLog(RTMSINTERVAL cMillies)
     96{
     97    if (!cMillies)
     98    {
     99        /* pthread_yield() isn't part of SuS, thus this fun. */
     100#ifdef RT_OS_DARWIN
     101        pthread_yield_np();
     102#elif defined(RT_OS_FREEBSD) /* void pthread_yield */
     103        pthread_yield();
     104#elif defined(RT_OS_SOLARIS)
     105        sched_yield();
     106#else
     107        if (!pthread_yield())
     108#endif
     109            return VINF_SUCCESS;
     110    }
     111    else
     112    {
     113        struct timespec ts;
     114        struct timespec tsrem = {0,0};
     115
     116        ts.tv_nsec = (cMillies % 1000) * 1000000;
     117        ts.tv_sec  = cMillies / 1000;
     118        if (!nanosleep(&ts, &tsrem))
     119            return VINF_SUCCESS;
     120    }
     121
     122    return RTErrConvertFromErrno(errno);
     123}
     124
     125
    95126RTDECL(bool) RTThreadYield(void)
    96127{
  • trunk/src/VBox/Runtime/r3/win/thread2-win.cpp

    r39327 r39443  
    5656
    5757
     58RTR3DECL(int)   RTThreadSleepNoLog(RTMSINTERVAL cMillies)
     59{
     60    Sleep(cMillies);
     61    return VINF_SUCCESS;
     62}
     63
     64
    5865RTR3DECL(bool) RTThreadYield(void)
    5966{
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette