VirtualBox

Changeset 28462 in vbox


Ignore:
Timestamp:
Apr 19, 2010 1:36:19 PM (15 years ago)
Author:
vboxsync
Message:

IPRT,SUPDrv: Basic testcase for ring-0 RTSemMutex*.

Location:
trunk/src/VBox
Files:
5 edited
3 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/Support/SUPDrv.c

    r28210 r28462  
    211211    { "RTR0MemKernelIsValidAddr",               (void *)RTR0MemKernelIsValidAddr },
    212212    { "RTR0MemAreKrnlAndUsrDifferent",          (void *)RTR0MemAreKrnlAndUsrDifferent },
    213 /* These don't work yet on linux - use fast mutexes!
    214213    { "RTSemMutexCreate",                       (void *)RTSemMutexCreate },
    215214    { "RTSemMutexRequest",                      (void *)RTSemMutexRequest },
     215    { "RTSemMutexRequestDebug",                 (void *)RTSemMutexRequestDebug },
     216    { "RTSemMutexRequestNoResume",              (void *)RTSemMutexRequestNoResume },
     217    { "RTSemMutexRequestNoResumeDebug",         (void *)RTSemMutexRequestNoResumeDebug },
    216218    { "RTSemMutexRelease",                      (void *)RTSemMutexRelease },
    217219    { "RTSemMutexDestroy",                      (void *)RTSemMutexDestroy },
    218 */
    219220    { "RTProcSelf",                             (void *)RTProcSelf },
    220221    { "RTR0ProcHandleSelf",                     (void *)RTR0ProcHandleSelf },
  • trunk/src/VBox/HostDrivers/Support/linux/Makefile

    r28283 r28462  
    9494        r0drv/linux/semeventmulti-r0drv-linux.o \
    9595        r0drv/linux/semfastmutex-r0drv-linux.o \
     96        r0drv/linux/semmutex-r0drv-linux.o \
    9697        r0drv/linux/spinlock-r0drv-linux.o \
    9798        r0drv/linux/thread-r0drv-linux.o \
  • trunk/src/VBox/HostDrivers/Support/linux/files_vboxdrv

    r28283 r28462  
    3939    ${PATH_ROOT}/include/iprt/handletable.h=>include/iprt/handletable.h \
    4040    ${PATH_ROOT}/include/iprt/initterm.h=>include/iprt/initterm.h \
     41    ${PATH_ROOT}/include/iprt/list.h=>include/iprt/list.h \
    4142    ${PATH_ROOT}/include/iprt/lockvalidator.h=>include/iprt/lockvalidator.h \
    4243    ${PATH_ROOT}/include/iprt/log.h=>include/iprt/log.h \
     
    141142    ${PATH_ROOT}/src/VBox/Runtime/r0drv/linux/semeventmulti-r0drv-linux.c=>r0drv/linux/semeventmulti-r0drv-linux.c \
    142143    ${PATH_ROOT}/src/VBox/Runtime/r0drv/linux/semfastmutex-r0drv-linux.c=>r0drv/linux/semfastmutex-r0drv-linux.c \
     144    ${PATH_ROOT}/src/VBox/Runtime/r0drv/linux/semmutex-r0drv-linux.c=>r0drv/linux/semmutex-r0drv-linux.c \
    143145    ${PATH_ROOT}/src/VBox/Runtime/r0drv/linux/spinlock-r0drv-linux.c=>r0drv/linux/spinlock-r0drv-linux.c \
    144146    ${PATH_ROOT}/src/VBox/Runtime/r0drv/linux/string.h=>r0drv/linux/string.h \
  • trunk/src/VBox/Runtime/r0drv/linux/semmutex-r0drv-linux.c

    r28436 r28462  
    320320    return rtSemMutexLinuxRequest(hMutexSem, cMillies, true /*fInterruptible*/);
    321321}
    322 RT_EXPORT_SYMBOL(RTSemMutexRequest);
     322RT_EXPORT_SYMBOL(RTSemMutexRequestNoResume);
    323323
    324324
     
    364364            IPRT_DEBUG_SEMS_STATE(pThis, 'u');
    365365        }
     366        rc = VINF_SUCCESS;
    366367    }
    367368    else
  • trunk/src/VBox/Runtime/testcase/Makefile.kmk

    r27800 r28462  
    9191        tstRand \
    9292        tstRTFsQueries \
     93        tstRTR0SemMutexDriver \
    9394        tstR0ThreadPreemptionDriver \
    9495        tstSemEvent \
     
    149150        tstLdrObjR0 \
    150151        tstRTR0MemUserKernel \
     152        tstRTR0SemMutex \
    151153        tstR0ThreadPreemption
    152154 ifdef VBOX_WITH_RAW_MODE
     
    394396endif
    395397
     398tstR0ThreadPreemptionDriver_TEMPLATE = VBOXR3TSTEXE
    396399tstR0ThreadPreemptionDriver_SOURCES = tstR0ThreadPreemptionDriver.cpp
     400
     401tstRTR0SemMutex_TEMPLATE = VBoxR0
     402tstRTR0SemMutex_INST = $(INST_TESTCASE)
     403tstRTR0SemMutex_DEFS = IN_RT_R0
     404tstRTR0SemMutex_SYSSUFF = .r0
     405tstRTR0SemMutex_SOURCES = tstRTR0SemMutex.cpp
     406tstRTR0SemMutex_LIBS = $(PATH_LIB)/RuntimeR0$(VBOX_SUFF_LIB)
     407if1of ($(VBOX_LDR_FMT), pe lx)
     408 tstRTR0SemMutex_LIBS += $(PATH_LIB)/SUPR0$(VBOX_SUFF_LIB)
     409endif
     410
     411tstRTR0SemMutexDriver_TEMPLATE = VBOXR3TSTEXE
     412tstRTR0SemMutexDriver_SOURCES = tstRTR0SemMutexDriver.cpp
    397413
    398414tstRTFsQueries_SOURCES = tstRTFsQueries.cpp
  • trunk/src/VBox/Runtime/testcase/tstRTR0SemMutex.cpp

    r28430 r28462  
    11/* $Id$ */
    22/** @file
    3  * IPRT R0 Testcase - Thread Preemption.
     3 * IPRT R0 Testcase - Mutex Semaphores.
    44 */
    55
    66/*
    7  * Copyright (C) 2009 Sun Microsystems, Inc.
     7 * Copyright (C) 2009-2010 Sun Microsystems, Inc.
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3232*   Header Files                                                               *
    3333*******************************************************************************/
    34 #include <iprt/thread.h>
     34#include <iprt/semaphore.h>
    3535
    3636#include <iprt/err.h>
     
    3838#include <iprt/string.h>
    3939#include <VBox/sup.h>
    40 #include "tstR0ThreadPreemption.h"
     40#include "tstRTR0SemMutex.h"
    4141
    4242
     
    5050 * @param   pReqHdr     The request header. Input / Output. Optional.
    5151 */
    52 DECLEXPORT(int) TSTR0ThreadPreemptionSrvReqHandler(PSUPDRVSESSION pSession, uint32_t uOperation,
    53                                                    uint64_t u64Arg, PSUPR0SERVICEREQHDR pReqHdr)
     52DECLEXPORT(int) TSTRTR0SemMutexSrvReqHandler(PSUPDRVSESSION pSession, uint32_t uOperation,
     53                                             uint64_t u64Arg, PSUPR0SERVICEREQHDR pReqHdr)
    5454{
    5555    if (u64Arg)
     
    6363    *pszErr = '\0';
    6464
     65#define SET_ERROR(szFmt)                do { if (!*pszErr) RTStrPrintf(pszErr, cchErr, "!" szFmt); } while (0)
     66#define SET_ERROR1(szFmt, a1)           do { if (!*pszErr) RTStrPrintf(pszErr, cchErr, "!" szFmt, a1); } while (0)
     67#define SET_ERROR2(szFmt, a1, a2)       do { if (!*pszErr) RTStrPrintf(pszErr, cchErr, "!" szFmt, a1, a2); } while (0)
     68#define SET_ERROR3(szFmt, a1, a2, a3)   do { if (!*pszErr) RTStrPrintf(pszErr, cchErr, "!" szFmt, a1, a2, a3); } while (0)
     69#define CHECK_RC_BREAK(rc, rcExpect, szOp) \
     70        if ((rc) != (rcExpect)) \
     71        { \
     72            RTStrPrintf(pszErr, cchErr, "!%s -> %Rrc, expected %Rrc. line %u", szOp, rc, rcExpect, __LINE__); \
     73            break; \
     74        }
     75
     76
    6577    /*
    6678     * The big switch.
    6779     */
     80    RTSEMMUTEX  hMtx;
     81    int         rc;
    6882    switch (uOperation)
    6983    {
    70         case TSTR0THREADPREMEPTION_SANITY_OK:
     84        case TSTRTR0SEMMUTEX_SANITY_OK:
    7185            break;
    7286
    73         case TSTR0THREADPREMEPTION_SANITY_FAILURE:
    74             RTStrPrintf(pszErr, cchErr, "!42failure42%1024s", "");
     87        case TSTRTR0SEMMUTEX_SANITY_FAILURE:
     88            SET_ERROR1("42failure42%1024s", "");
    7589            break;
    7690
    77         case TSTR0THREADPREMEPTION_BASIC:
    78         {
    79             if (!ASMIntAreEnabled())
    80                 RTStrPrintf(pszErr, cchErr, "!Interrupts disabled");
    81             else if (!RTThreadPreemptIsEnabled(NIL_RTTHREAD))
    82                 RTStrPrintf(pszErr, cchErr, "!RTThreadPreemptIsEnabled returns false by default");
    83             else
     91        case TSTRTR0SEMMUTEX_BASIC:
     92            rc = RTSemMutexCreate(&hMtx);
     93            CHECK_RC_BREAK(rc, VINF_SUCCESS, "RTSemMutexCreate");
     94            do
    8495            {
    85                 RTTHREADPREEMPTSTATE State = RTTHREADPREEMPTSTATE_INITIALIZER;
    86                 RTThreadPreemptDisable(&State);
    87                 if (RTThreadPreemptIsEnabled(NIL_RTTHREAD))
    88                     RTStrPrintf(pszErr, cchErr, "!RTThreadPreemptIsEnabled returns true after RTThreadPreemptDisable");
    89                 else if (!ASMIntAreEnabled())
    90                     RTStrPrintf(pszErr, cchErr, "!Interrupts disabled");
    91                 RTThreadPreemptRestore(&State);
    92             }
     96                /*
     97                 * The interruptible version first.
     98                 */
     99                /* simple request and release, polling. */
     100                rc = RTSemMutexRequestNoResume(hMtx, 0);
     101                CHECK_RC_BREAK(rc, VINF_SUCCESS, "RTSemMutexRequestNoResume");
     102                rc = RTSemMutexRelease(hMtx);
     103                CHECK_RC_BREAK(rc, VINF_SUCCESS, "RTSemMutexRelease");
     104
     105                /* simple request and release, wait for ever. */
     106                rc = RTSemMutexRequestNoResume(hMtx, RT_INDEFINITE_WAIT);
     107                CHECK_RC_BREAK(rc, VINF_SUCCESS, "RTSemMutexRequestNoResume(indef_wait)");
     108                rc = RTSemMutexRelease(hMtx);
     109                CHECK_RC_BREAK(rc, VINF_SUCCESS, "RTSemMutexRelease");
     110
     111                /* simple request and release, wait a tiny while. */
     112                rc = RTSemMutexRequestNoResume(hMtx, 133);
     113                CHECK_RC_BREAK(rc, VINF_SUCCESS, "RTSemMutexRequestNoResume(133)");
     114                rc = RTSemMutexRelease(hMtx);
     115                CHECK_RC_BREAK(rc, VINF_SUCCESS, "RTSemMutexRelease");
     116
     117                /* nested request and release. */
     118                rc = RTSemMutexRequestNoResume(hMtx, RT_INDEFINITE_WAIT);
     119                CHECK_RC_BREAK(rc, VINF_SUCCESS, "RTSemMutexRequestNoResume#1");
     120                rc = RTSemMutexRequestNoResume(hMtx, RT_INDEFINITE_WAIT);
     121                CHECK_RC_BREAK(rc, VINF_SUCCESS, "RTSemMutexRequestNoResume#2");
     122                rc = RTSemMutexRequestNoResume(hMtx, RT_INDEFINITE_WAIT);
     123                CHECK_RC_BREAK(rc, VINF_SUCCESS, "RTSemMutexRequestNoResume#3");
     124                rc = RTSemMutexRelease(hMtx);
     125                CHECK_RC_BREAK(rc, VINF_SUCCESS, "RTSemMutexRelease#3");
     126                rc = RTSemMutexRequestNoResume(hMtx, RT_INDEFINITE_WAIT);
     127                CHECK_RC_BREAK(rc, VINF_SUCCESS, "RTSemMutexRequestNoResume#3b");
     128                rc = RTSemMutexRelease(hMtx);
     129                CHECK_RC_BREAK(rc, VINF_SUCCESS, "RTSemMutexRelease#3b");
     130                rc = RTSemMutexRelease(hMtx);
     131                CHECK_RC_BREAK(rc, VINF_SUCCESS, "RTSemMutexRelease#2");
     132                rc = RTSemMutexRelease(hMtx);
     133                CHECK_RC_BREAK(rc, VINF_SUCCESS, "RTSemMutexRelease#1");
     134
     135                /*
     136                 * The uninterruptible variant.
     137                 */
     138                /* simple request and release, polling. */
     139                rc = RTSemMutexRequest(hMtx, 0);
     140                CHECK_RC_BREAK(rc, VINF_SUCCESS, "RTSemMutexRequest");
     141                rc = RTSemMutexRelease(hMtx);
     142                CHECK_RC_BREAK(rc, VINF_SUCCESS, "RTSemMutexRelease");
     143
     144                /* simple request and release, wait for ever. */
     145                rc = RTSemMutexRequest(hMtx, RT_INDEFINITE_WAIT);
     146                CHECK_RC_BREAK(rc, VINF_SUCCESS, "RTSemMutexRequest(indef_wait)");
     147                rc = RTSemMutexRelease(hMtx);
     148                CHECK_RC_BREAK(rc, VINF_SUCCESS, "RTSemMutexRelease");
     149
     150                /* simple request and release, wait a tiny while. */
     151                rc = RTSemMutexRequest(hMtx, 133);
     152                CHECK_RC_BREAK(rc, VINF_SUCCESS, "RTSemMutexRequest(133)");
     153                rc = RTSemMutexRelease(hMtx);
     154                CHECK_RC_BREAK(rc, VINF_SUCCESS, "RTSemMutexRelease");
     155
     156                /* nested request and release. */
     157                rc = RTSemMutexRequest(hMtx, RT_INDEFINITE_WAIT);
     158                CHECK_RC_BREAK(rc, VINF_SUCCESS, "RTSemMutexRequest#1");
     159                rc = RTSemMutexRequest(hMtx, RT_INDEFINITE_WAIT);
     160                CHECK_RC_BREAK(rc, VINF_SUCCESS, "RTSemMutexRequest#2");
     161                rc = RTSemMutexRequest(hMtx, RT_INDEFINITE_WAIT);
     162                CHECK_RC_BREAK(rc, VINF_SUCCESS, "RTSemMutexRequest#3");
     163                rc = RTSemMutexRelease(hMtx);
     164                CHECK_RC_BREAK(rc, VINF_SUCCESS, "RTSemMutexRelease#3");
     165                rc = RTSemMutexRequest(hMtx, RT_INDEFINITE_WAIT);
     166                CHECK_RC_BREAK(rc, VINF_SUCCESS, "RTSemMutexRequest#3b");
     167                rc = RTSemMutexRelease(hMtx);
     168                CHECK_RC_BREAK(rc, VINF_SUCCESS, "RTSemMutexRelease#3b");
     169                rc = RTSemMutexRelease(hMtx);
     170                CHECK_RC_BREAK(rc, VINF_SUCCESS, "RTSemMutexRelease#2");
     171                rc = RTSemMutexRelease(hMtx);
     172                CHECK_RC_BREAK(rc, VINF_SUCCESS, "RTSemMutexRelease#1");
     173
     174            } while (false);
     175
     176            rc = RTSemMutexDestroy(hMtx);
     177            CHECK_RC_BREAK(rc, VINF_SUCCESS, "RTSemMutexDestroy");
    93178            break;
    94         }
    95 
    96         case TSTR0THREADPREMEPTION_IS_PENDING:
    97         {
    98             RTTHREADPREEMPTSTATE State = RTTHREADPREEMPTSTATE_INITIALIZER;
    99             RTThreadPreemptDisable(&State);
    100             if (!RTThreadPreemptIsEnabled(NIL_RTTHREAD))
    101             {
    102                 if (ASMIntAreEnabled())
    103                 {
    104                     uint64_t    u64StartTS    = RTTimeNanoTS();
    105                     uint64_t    u64StartSysTS = RTTimeSystemNanoTS();
    106                     uint64_t    cLoops        = 0;
    107                     uint64_t    cNanosSysElapsed;
    108                     uint64_t    cNanosElapsed;
    109                     bool        fPending;
    110                     do
    111                     {
    112                         fPending         = RTThreadPreemptIsPending(NIL_RTTHREAD);
    113                         cNanosElapsed    = RTTimeNanoTS()       - u64StartTS;
    114                         cNanosSysElapsed = RTTimeSystemNanoTS() - u64StartSysTS;
    115                         cLoops++;
    116                     } while (   !fPending
    117                              && cNanosElapsed    < UINT64_C(2)*1000U*1000U*1000U
    118                              && cNanosSysElapsed < UINT64_C(2)*1000U*1000U*1000U
    119                              && cLoops           < 100U*_1M);
    120                     if (!fPending)
    121                         RTStrPrintf(pszErr, cchErr, "!Preempt not pending after %'llu loops / %'llu ns / %'llu ns (sys)",
    122                                     cLoops, cNanosElapsed, cNanosSysElapsed);
    123                     else if (cLoops == 1)
    124                         RTStrPrintf(pszErr, cchErr, "!cLoops=1\n");
    125                     else
    126                         RTStrPrintf(pszErr, cchErr, "RTThreadPreemptIsPending returned true after %'llu loops / %'llu ns / %'llu ns (sys)",
    127                                     cLoops, cNanosElapsed, cNanosSysElapsed);
    128                 }
    129                 else
    130                     RTStrPrintf(pszErr, cchErr, "!Interrupts disabled");
    131             }
    132             else
    133                 RTStrPrintf(pszErr, cchErr, "!RTThreadPreemptIsEnabled returns true after RTThreadPreemptDisable");
    134             RTThreadPreemptRestore(&State);
    135             break;
    136         }
    137 
    138         case TSTR0THREADPREMEPTION_NESTED:
    139         {
    140             bool const fDefault = RTThreadPreemptIsEnabled(NIL_RTTHREAD);
    141             RTTHREADPREEMPTSTATE State1 = RTTHREADPREEMPTSTATE_INITIALIZER;
    142             RTThreadPreemptDisable(&State1);
    143             if (!RTThreadPreemptIsEnabled(NIL_RTTHREAD))
    144             {
    145                 RTTHREADPREEMPTSTATE State2 = RTTHREADPREEMPTSTATE_INITIALIZER;
    146                 RTThreadPreemptDisable(&State2);
    147                 if (!RTThreadPreemptIsEnabled(NIL_RTTHREAD))
    148                 {
    149                     RTTHREADPREEMPTSTATE State3 = RTTHREADPREEMPTSTATE_INITIALIZER;
    150                     RTThreadPreemptDisable(&State3);
    151                     if (RTThreadPreemptIsEnabled(NIL_RTTHREAD))
    152                         RTStrPrintf(pszErr, cchErr, "!RTThreadPreemptIsEnabled returns true after 3rd RTThreadPreemptDisable");
    153 
    154                     RTThreadPreemptRestore(&State3);
    155                     if (RTThreadPreemptIsEnabled(NIL_RTTHREAD) && !*pszErr)
    156                         RTStrPrintf(pszErr, cchErr, "!RTThreadPreemptIsEnabled returns true after 1st RTThreadPreemptRestore");
    157                 }
    158                 else
    159                     RTStrPrintf(pszErr, cchErr, "!RTThreadPreemptIsEnabled returns true after 2nd RTThreadPreemptDisable");
    160 
    161                 RTThreadPreemptRestore(&State2);
    162                 if (RTThreadPreemptIsEnabled(NIL_RTTHREAD) && !*pszErr)
    163                     RTStrPrintf(pszErr, cchErr, "!RTThreadPreemptIsEnabled returns true after 2nd RTThreadPreemptRestore");
    164             }
    165             else
    166                 RTStrPrintf(pszErr, cchErr, "!RTThreadPreemptIsEnabled returns true after 1st RTThreadPreemptDisable");
    167             RTThreadPreemptRestore(&State1);
    168             if (RTThreadPreemptIsEnabled(NIL_RTTHREAD) != fDefault && !*pszErr)
    169                 RTStrPrintf(pszErr, cchErr, "!RTThreadPreemptIsEnabled returns false after 3rd RTThreadPreemptRestore");
    170             break;
    171         }
    172179
    173180        default:
    174             RTStrPrintf(pszErr, cchErr, "!Unknown test #%d", uOperation);
     181            SET_ERROR1("Unknown test #%d", uOperation);
    175182            break;
    176183    }
  • trunk/src/VBox/Runtime/testcase/tstRTR0SemMutex.h

    r28430 r28462  
    11/* $Id$ */
    22/** @file
    3  * IPRT R0 Testcase - Thread Preemption, common header.
     3 * IPRT R0 Testcase - Mutex Semaphores, common header.
    44 */
    55
    66/*
    7  * Copyright (C) 2009 Sun Microsystems, Inc.
     7 * Copyright (C) 2009-2010 Sun Microsystems, Inc.
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3131#ifdef IN_RING0
    3232RT_C_DECLS_BEGIN
    33 DECLEXPORT(int) TSTR0ThreadPreemptionSrvReqHandler(PSUPDRVSESSION pSession, uint32_t uOperation,
    34                                                    uint64_t u64Arg, PSUPR0SERVICEREQHDR pReqHdr);
     33DECLEXPORT(int) TSTRTR0SemMutexSrvReqHandler(PSUPDRVSESSION pSession, uint32_t uOperation,
     34                                             uint64_t u64Arg, PSUPR0SERVICEREQHDR pReqHdr);
    3535RT_C_DECLS_END
    3636#endif
    3737
    38 typedef enum TSTR0THREADPREMEPTION
     38typedef enum TSTRTR0SEMMUTEX
    3939{
    40     TSTR0THREADPREMEPTION_SANITY_OK = 1,
    41     TSTR0THREADPREMEPTION_SANITY_FAILURE,
    42     TSTR0THREADPREMEPTION_BASIC,
    43     TSTR0THREADPREMEPTION_IS_PENDING,
    44     TSTR0THREADPREMEPTION_NESTED
    45 } TSTR0THREADPREMEPTION;
     40    TSTRTR0SEMMUTEX_SANITY_OK = 1,
     41    TSTRTR0SEMMUTEX_SANITY_FAILURE,
     42    TSTRTR0SEMMUTEX_BASIC
     43} TSTRTR0SEMMUTEX;
    4644
  • trunk/src/VBox/Runtime/testcase/tstRTR0SemMutexDriver.cpp

    r28430 r28462  
    55
    66/*
    7  * Copyright (C) 2009 Sun Microsystems, Inc.
     7 * Copyright (C) 2009-2010 Sun Microsystems, Inc.
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    4343#ifdef VBOX
    4444# include <VBox/sup.h>
    45 # include "tstR0ThreadPreemption.h"
     45# include "tstRTR0SemMutex.h"
    4646#endif
    4747
     
    5757     */
    5858    RTTEST hTest;
    59     int rc = RTTestInitAndCreate("tstR0ThreadPreemption", &hTest);
     59    int rc = RTTestInitAndCreate("tstR0SemMutex", &hTest);
    6060    if (rc)
    6161        return rc;
     
    7373    rc = RTPathExecDir(szPath, sizeof(szPath));
    7474    if (RT_SUCCESS(rc))
    75         rc = RTPathAppend(szPath, sizeof(szPath), "tstR0ThreadPreemption.r0");
     75        rc = RTPathAppend(szPath, sizeof(szPath), "tstR0SemMutex.r0");
    7676    if (RT_FAILURE(rc))
    7777    {
     
    8181
    8282    void *pvImageBase;
    83     rc = SUPR3LoadServiceModule(szPath, "tstR0ThreadPreemption",
    84                                 "TSTR0ThreadPreemptionSrvReqHandler",
     83    rc = SUPR3LoadServiceModule(szPath, "tstR0SemMutex",
     84                                "TSTRTR0SemMutexSrvReqHandler",
    8585                                &pvImageBase);
    8686    if (RT_FAILURE(rc))
     
    104104    Req.Hdr.cbReq = sizeof(Req);
    105105    Req.szMsg[0] = '\0';
    106     RTTESTI_CHECK_RC(rc = SUPR3CallR0Service("tstR0ThreadPreemption", sizeof("tstR0ThreadPreemption") - 1,
    107                                              TSTR0THREADPREMEPTION_SANITY_OK, 0, &Req.Hdr), VINF_SUCCESS);
     106    RTTESTI_CHECK_RC(rc = SUPR3CallR0Service("tstR0SemMutex", sizeof("tstR0SemMutex") - 1,
     107                                             TSTRTR0SEMMUTEX_SANITY_OK, 0, &Req.Hdr), VINF_SUCCESS);
    108108    if (RT_FAILURE(rc))
    109109        return RTTestSummaryAndDestroy(hTest);
     
    115115    Req.Hdr.cbReq = sizeof(Req);
    116116    Req.szMsg[0] = '\0';
    117     RTTESTI_CHECK_RC(rc = SUPR3CallR0Service("tstR0ThreadPreemption", sizeof("tstR0ThreadPreemption") - 1,
    118                                              TSTR0THREADPREMEPTION_SANITY_FAILURE, 0, &Req.Hdr), VINF_SUCCESS);
     117    RTTESTI_CHECK_RC(rc = SUPR3CallR0Service("tstR0SemMutex", sizeof("tstR0SemMutex") - 1,
     118                                             TSTRTR0SEMMUTEX_SANITY_FAILURE, 0, &Req.Hdr), VINF_SUCCESS);
    119119    if (RT_FAILURE(rc))
    120120        return RTTestSummaryAndDestroy(hTest);
     
    130130    Req.Hdr.cbReq = sizeof(Req);
    131131    Req.szMsg[0] = '\0';
    132     RTTESTI_CHECK_RC(rc = SUPR3CallR0Service("tstR0ThreadPreemption", sizeof("tstR0ThreadPreemption") - 1,
    133                                              TSTR0THREADPREMEPTION_BASIC, 0, &Req.Hdr), VINF_SUCCESS);
     132    RTTESTI_CHECK_RC(rc = SUPR3CallR0Service("tstR0SemMutex", sizeof("tstR0SemMutex") - 1,
     133                                             TSTRTR0SEMMUTEX_BASIC, 0, &Req.Hdr), VINF_SUCCESS);
    134134    if (RT_FAILURE(rc))
    135135        return RTTestSummaryAndDestroy(hTest);
     
    143143
    144144    /*
    145      * Stay in ring-0 until preemption is pending.
     145     * More to come
    146146     */
    147 RTThreadSleep(250); /** @todo fix GIP initialization? */
    148     RTTestSub(hTest, "Pending Preemption");
    149     for (int i = 0; ; i++)
    150     {
    151         Req.Hdr.u32Magic = SUPR0SERVICEREQHDR_MAGIC;
    152         Req.Hdr.cbReq = sizeof(Req);
    153         Req.szMsg[0] = '\0';
    154         RTTESTI_CHECK_RC(rc = SUPR3CallR0Service("tstR0ThreadPreemption", sizeof("tstR0ThreadPreemption") - 1,
    155                                                  TSTR0THREADPREMEPTION_IS_PENDING, 0, &Req.Hdr), VINF_SUCCESS);
    156         if (    strcmp(Req.szMsg, "cLoops=1\n")
    157             ||  i >= 64)
    158         {
    159             if (Req.szMsg[0] == '!')
    160                 RTTestIFailed("%s", &Req.szMsg[1]);
    161             else if (Req.szMsg[0])
    162                 RTTestIPrintf(RTTESTLVL_ALWAYS, "%s", Req.szMsg);
    163             break;
    164         }
    165         if ((i % 3) == 0)
    166             RTThreadYield();
    167     }
    168 
    169     /*
    170      * Test nested RTThreadPreemptDisable calls.
    171      */
    172     RTTestSub(hTest, "Nested");
    173     Req.Hdr.u32Magic = SUPR0SERVICEREQHDR_MAGIC;
    174     Req.Hdr.cbReq = sizeof(Req);
    175     Req.szMsg[0] = '\0';
    176     RTTESTI_CHECK_RC(rc = SUPR3CallR0Service("tstR0ThreadPreemption", sizeof("tstR0ThreadPreemption") - 1,
    177                                              TSTR0THREADPREMEPTION_NESTED, 0, &Req.Hdr), VINF_SUCCESS);
    178     if (Req.szMsg[0] == '!')
    179         RTTestIFailed("%s", &Req.szMsg[1]);
    180     else if (Req.szMsg[0])
    181         RTTestIPrintf(RTTESTLVL_ALWAYS, "%s", Req.szMsg);
    182147
    183148    /*
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