VirtualBox

Changeset 58829 in vbox


Ignore:
Timestamp:
Nov 23, 2015 5:13:18 PM (9 years ago)
Author:
vboxsync
Message:

IPRT: Make read-write critical sections available to ring-0 code.

Location:
trunk/src/VBox/Runtime
Files:
2 edited

Legend:

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

    r58758 r58829  
    11971197        generic/RTSemEventMultiWaitNoResume-2-ex-generic.cpp \
    11981198        generic/sched-generic.cpp \
    1199         generic/semrw-$(if-expr defined(VBOX_WITH_LOCKLESS_SEMRW),ockless-,)generic.cpp \
     1199        generic/semrw-$(if-expr defined(VBOX_WITH_LOCKLESS_SEMRW),lockless-,)generic.cpp \
    12001200        generic/timer-generic.cpp \
    12011201        generic/utf16locale-generic.cpp \
     
    17551755        generic/RTAssertShouldPanic-generic.cpp \
    17561756        generic/critsect-generic.cpp \
     1757        generic/critsectrw-generic.cpp \
    17571758        \
    17581759        $(RuntimeNoCrt_SOURCES)
  • trunk/src/VBox/Runtime/generic/critsectrw-generic.cpp

    r57358 r58829  
    6767    pThis->u32Magic         = RTCRITSECTRW_MAGIC_DEAD;
    6868    pThis->fNeedReset       = false;
     69#ifdef IN_RING0
     70    pThis->fFlags           = (uint16_t)(fFlags | RTCRITSECT_FLAGS_RING0);
     71#else
     72    pThis->fFlags           = (uint16_t)(fFlags & ~RTCRITSECT_FLAGS_RING0);
     73#endif
    6974    pThis->u64State         = 0;
    7075    pThis->hNativeWriter    = NIL_RTNATIVETHREAD;
     
    138143    AssertPtrReturn(pThis, RTLOCKVAL_SUB_CLASS_INVALID);
    139144    AssertReturn(pThis->u32Magic == RTCRITSECTRW_MAGIC, RTLOCKVAL_SUB_CLASS_INVALID);
     145#ifdef IN_RING0
     146    Assert(pThis->fFlags & RTCRITSECT_FLAGS_RING0);
     147#else
     148    Assert(!(pThis->fFlags & RTCRITSECT_FLAGS_RING0));
     149#endif
    140150#ifdef RTCRITSECTRW_STRICT
    141151    AssertReturn(!(pThis->fFlags & RTCRITSECT_FLAGS_NOP), RTLOCKVAL_SUB_CLASS_INVALID);
     
    158168    AssertPtr(pThis);
    159169    AssertReturn(pThis->u32Magic == RTCRITSECTRW_MAGIC, VERR_SEM_DESTROYED);
     170#ifdef IN_RING0
     171    Assert(pThis->fFlags & RTCRITSECT_FLAGS_RING0);
     172#else
     173    Assert(!(pThis->fFlags & RTCRITSECT_FLAGS_RING0));
     174#endif
    160175
    161176#ifdef RTCRITSECTRW_STRICT
     
    257272                                                               RT_INDEFINITE_WAIT, RTTHREADSTATE_RW_READ, false);
    258273                    if (RT_SUCCESS(rc))
    259 #else
     274#elif defined(IN_RING3)
    260275                    RTTHREAD hThreadSelf = RTThreadSelf();
    261276                    RTThreadBlocking(hThreadSelf, RTTHREADSTATE_RW_READ, false);
     
    263278                    {
    264279                        rc = RTSemEventMultiWait(pThis->hEvtRead, RT_INDEFINITE_WAIT);
     280#ifdef IN_RING3
    265281                        RTThreadUnblocked(hThreadSelf, RTTHREADSTATE_RW_READ);
     282#endif
    266283                        if (pThis->u32Magic != RTCRITSECTRW_MAGIC)
    267284                            return VERR_SEM_DESTROYED;
     
    388405    AssertPtr(pThis);
    389406    AssertReturn(pThis->u32Magic == RTCRITSECTRW_MAGIC, VERR_SEM_DESTROYED);
     407#ifdef IN_RING0
     408    Assert(pThis->fFlags & RTCRITSECT_FLAGS_RING0);
     409#else
     410    Assert(!(pThis->fFlags & RTCRITSECT_FLAGS_RING0));
     411#endif
    390412
    391413    /*
     
    461483    AssertPtr(pThis);
    462484    AssertReturn(pThis->u32Magic == RTCRITSECTRW_MAGIC, VERR_SEM_DESTROYED);
     485#ifdef IN_RING0
     486    Assert(pThis->fFlags & RTCRITSECT_FLAGS_RING0);
     487#else
     488    Assert(!(pThis->fFlags & RTCRITSECT_FLAGS_RING0));
     489#endif
    463490
    464491#ifdef RTCRITSECTRW_STRICT
     
    584611                                                     RT_INDEFINITE_WAIT, RTTHREADSTATE_RW_WRITE, false);
    585612            if (RT_SUCCESS(rc))
    586 #else
     613#elif defined(IN_RING3)
    587614            RTTHREAD hThreadSelf = RTThreadSelf();
    588615            RTThreadBlocking(hThreadSelf, RTTHREADSTATE_RW_WRITE, false);
     
    590617            {
    591618                rc = RTSemEventWait(pThis->hEvtWrite, RT_INDEFINITE_WAIT);
     619#ifdef IN_RING3
    592620                RTThreadUnblocked(hThreadSelf, RTTHREADSTATE_RW_WRITE);
     621#endif
    593622                if (pThis->u32Magic != RTCRITSECTRW_MAGIC)
    594623                    return VERR_SEM_DESTROYED;
     
    682711    AssertPtr(pThis);
    683712    AssertReturn(pThis->u32Magic == RTCRITSECTRW_MAGIC, VERR_SEM_DESTROYED);
     713#ifdef IN_RING0
     714    Assert(pThis->fFlags & RTCRITSECT_FLAGS_RING0);
     715#else
     716    Assert(!(pThis->fFlags & RTCRITSECT_FLAGS_RING0));
     717#endif
    684718
    685719    RTNATIVETHREAD hNativeSelf = RTThreadNativeSelf();
     
    773807    AssertPtr(pThis);
    774808    AssertReturn(pThis->u32Magic == RTCRITSECTRW_MAGIC, false);
     809#ifdef IN_RING0
     810    Assert(pThis->fFlags & RTCRITSECT_FLAGS_RING0);
     811#else
     812    Assert(!(pThis->fFlags & RTCRITSECT_FLAGS_RING0));
     813#endif
    775814
    776815    /*
     
    792831    AssertPtr(pThis);
    793832    AssertReturn(pThis->u32Magic == RTCRITSECTRW_MAGIC, false);
     833#ifdef IN_RING0
     834    Assert(pThis->fFlags & RTCRITSECT_FLAGS_RING0);
     835#else
     836    Assert(!(pThis->fFlags & RTCRITSECT_FLAGS_RING0));
     837#endif
    794838
    795839    /*
     
    891935    //Assert(pThis->cLockers == -1);
    892936    Assert(pThis->hNativeWriter == NIL_RTNATIVETHREAD);
     937#ifdef IN_RING0
     938    Assert(pThis->fFlags & RTCRITSECT_FLAGS_RING0);
     939#else
     940    Assert(!(pThis->fFlags & RTCRITSECT_FLAGS_RING0));
     941#endif
    893942
    894943    /*
     
    909958    int rc2 = RTSemEventMultiDestroy(hEvtRead); AssertRC(rc2);
    910959
     960#ifndef IN_RING0
    911961    RTLockValidatorRecSharedDestroy(&pThis->pValidatorRead);
    912962    RTLockValidatorRecExclDestroy(&pThis->pValidatorWrite);
     963#endif
    913964
    914965    return RT_SUCCESS(rc1) ? rc2 : rc1;
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