VirtualBox

Changeset 13254 in vbox for trunk/src


Ignore:
Timestamp:
Oct 14, 2008 12:35:50 PM (16 years ago)
Author:
vboxsync
Message:

IPRT: Added RTThreadPreemptIsEnabled, RTThreadPreemptDisable and RTThreadPreemptRestore. Made the logger check that preemption is enabled before trying to take the semaphore on Solaris and Windows.

Location:
trunk/src/VBox/Runtime
Files:
3 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/Makefile.kmk

    r13248 r13254  
    976976        generic/RTLogWriteStdOut-stub-generic.cpp \
    977977        generic/mppresent-generic.cpp \
     978        r0drv/generic/RTThreadPreemptIsEnabled-r0drv-generic.cpp \
     979        r0drv/generic/RTThreadPreemptDisable-r0drv-generic.cpp \
     980        r0drv/generic/RTThreadPreemptRestore-r0drv-generic.cpp \
    978981        r0drv/linux/alloc-r0drv-linux.c \
    979982        r0drv/linux/initterm-r0drv-linux.c \
     
    10101013        r0drv/memobj-r0drv.cpp \
    10111014        r0drv/mpnotification-r0drv.c \
     1015        r0drv/generic/RTThreadPreemptIsEnabled-r0drv-generic.cpp \
     1016        r0drv/generic/RTThreadPreemptDisable-r0drv-generic.cpp \
     1017        r0drv/generic/RTThreadPreemptRestore-r0drv-generic.cpp \
    10121018        r0drv/nt/alloc-r0drv-nt.cpp \
    10131019        r0drv/nt/assert-r0drv-nt.cpp \
     
    10541060        generic/timer-generic.cpp \
    10551061        r0drv/generic/RTMpOn-r0drv-generic.cpp \
     1062        r0drv/generic/RTThreadPreemptIsEnabled-r0drv-generic.cpp \
     1063        r0drv/generic/RTThreadPreemptDisable-r0drv-generic.cpp \
     1064        r0drv/generic/RTThreadPreemptRestore-r0drv-generic.cpp \
    10561065        r0drv/generic/mpnotification-r0drv-generic.cpp \
    10571066        r0drv/darwin/alloc-r0drv-darwin.cpp \
     
    11031112        r0drv/memobj-r0drv.cpp \
    11041113        r0drv/generic/RTMpOn-r0drv-generic.cpp \
     1114        r0drv/generic/RTThreadPreemptIsEnabled-r0drv-generic.cpp \
     1115        r0drv/generic/RTThreadPreemptDisable-r0drv-generic.cpp \
     1116        r0drv/generic/RTThreadPreemptRestore-r0drv-generic.cpp \
    11051117        r0drv/generic/mpnotification-r0drv-generic.cpp \
    11061118        r0drv/os2/alloc-r0drv-os2.cpp \
     
    11491161        generic/mppresent-generic.cpp \
    11501162        r0drv/generic/RTMpOn-r0drv-generic.cpp \
     1163        r0drv/generic/RTThreadPreemptIsEnabled-r0drv-generic.cpp \
     1164        r0drv/generic/RTThreadPreemptDisable-r0drv-generic.cpp \
     1165        r0drv/generic/RTThreadPreemptRestore-r0drv-generic.cpp \
    11511166        r0drv/generic/mpnotification-r0drv-generic.cpp \
    11521167        r0drv/freebsd/alloc-r0drv-freebsd.c \
     
    11961211else  # !VBOX_WITH_SOLARIS_VBI
    11971212 RuntimeR0Drv_SOURCES.solaris += \
     1213        r0drv/generic/RTThreadPreemptIsEnabled-r0drv-generic.cpp \
     1214        r0drv/generic/RTThreadPreemptDisable-r0drv-generic.cpp \
     1215        r0drv/generic/RTThreadPreemptRestore-r0drv-generic.cpp \
    11981216        r0drv/solaris/mpnotification-r0drv-solaris.c \
    11991217        r0drv/solaris/alloc-r0drv-solaris.c \
  • trunk/src/VBox/Runtime/common/log/log.cpp

    r12905 r13254  
    143143    if (pLogger->MutexSem != NIL_RTSEMFASTMUTEX)
    144144    {
     145# if defined(IN_RING0) \
     146  && (defined(RT_OS_WINDOWS) || defined(RT_OS_SOLARIS))
     147        if (!RTThreadPreemptIsEnabled())
     148            return VERR_PREEMPT_DISABLED;
     149# endif
    145150        int rc = RTSemFastMutexRequest(pLogger->MutexSem);
    146151        if (RT_FAILURE(rc))
  • trunk/src/VBox/Runtime/r0drv/nt/thread-r0drv-nt.cpp

    r8245 r13254  
    7272
    7373
     74RTDECL(bool) RTThreadPreemptIsEnabled(RTTHREAD hThread)
     75{
     76    Assert(hThread == NIL_RTTHREAD);
     77    KIRQL Irql = KeGetCurrentIrql();
     78    return Irql <= APC_LEVEL;
     79}
     80
     81
     82RTDECL(void) RTThreadPreemptDisable(PRTTHREADPREEMPTSTATE pState)
     83{
     84    AssertPtr(pState);
     85    Assert(pState->uchOldIrql == 255);
     86    Assert(KeGetCurrentIrql() <= DISPATCH_LEVEL);
     87
     88    KeRaiseIrql(DISPATCH_LEVEL, &pState->uchOldIrql);
     89}
     90
     91
     92RTDECL(void) RTThreadPreemptRestore(PRTTHREADPREEMPTSTATE pState)
     93{
     94    AssertPtr(pState);
     95
     96    KeLowerIrql(pState->uchOldIrql);
     97    pState->uchOldIrql = 255;
     98}
     99
  • trunk/src/VBox/Runtime/r0drv/solaris/thread-r0drv-solaris.c

    r8245 r13254  
    4949    clock_t cTicks;
    5050    unsigned long timeout;
    51    
     51
    5252    if (!cMillies)
    5353    {
     
    6363#if 0
    6464    timeout = ddi_get_lbolt();
    65     timeout += cTicks; 
    66  
     65    timeout += cTicks;
     66
    6767    kcondvar_t cnd;
    6868    kmutex_t mtx;
     
    9898}
    9999
     100
     101RTDECL(bool) RTThreadPreemptIsEnabled(RTTHREAD hThread)
     102{
     103    Assert(hThread == NIL_RTTHREAD);
     104    return curthread->t_preempt == 0;
     105}
     106
     107
     108RTDECL(void) RTThreadPreemptDisable(PRTTHREADPREEMPTSTATE pState)
     109{
     110    AssertPtr(pState);
     111    Assert(pState->uchDummy != 42);
     112    pState->uchDummy = 42;
     113
     114    kpreempt_disable();
     115}
     116
     117
     118RTDECL(void) RTThreadPreemptRestore(PRTTHREADPREEMPTSTATE pState)
     119{
     120    AssertPtr(pState);
     121    Assert(pState->uchDummy == 42);
     122    pState->uchDummy = 0;
     123
     124    kpreempt_enable();
     125}
     126
  • trunk/src/VBox/Runtime/r0drv/solaris/vbi/thread-r0drv-solaris.c

    r9176 r13254  
    6262#if 0
    6363    timeout = ddi_get_lbolt();
    64     timeout += cTicks; 
    65  
     64    timeout += cTicks;
     65
    6666    kcondvar_t cnd;
    6767    kmutex_t mtx;
     
    9696}
    9797
     98
     99RTDECL(bool) RTThreadPreemptIsEnabled(RTTHREAD hThread)
     100{
     101    Assert(hThread == NIL_RTTHREAD);
     102    return vbi_is_preempt_enabled() != 0;
     103}
     104
     105
     106RTDECL(void) RTThreadPreemptDisable(PRTTHREADPREEMPTSTATE pState)
     107{
     108    AssertPtr(pState);
     109    Assert(pState->uchDummy != 42);
     110    pState->uchDummy = 42;
     111    vbi_preempt_disable();
     112}
     113
     114
     115RTDECL(void) RTThreadPreemptRestore(PRTTHREADPREEMPTSTATE pState)
     116{
     117    AssertPtr(pState);
     118    Assert(pState->uchDummy == 42);
     119    pState->uchDummy = 0;
     120    vbi_preempt_enable();
     121}
     122
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