VirtualBox

Changeset 54457 in vbox


Ignore:
Timestamp:
Feb 24, 2015 4:14:50 PM (10 years ago)
Author:
vboxsync
Message:

Runtime/r0drv: RTMpOnPair implementation for solaris.

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

Legend:

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

    r54446 r54457  
    21692169        generic/RTLogWriteStdOut-stub-generic.cpp \
    21702170        generic/RTMpGetCoreCount-generic.cpp \
    2171         generic/RTMpOnPair-generic.cpp \
    21722171        generic/RTTimerCreate-generic.cpp \
    21732172        generic/mppresent-generic.cpp \
  • trunk/src/VBox/Runtime/r0drv/solaris/mp-r0drv-solaris.c

    r54415 r54457  
    149149 * Wrapper to Solaris IPI infrastructure.
    150150 *
     151 * @returns Solaris error code.
    151152 * @param   pCpuSet        Pointer to Solaris CPU set.
    152153 * @param   pfnSolWorker   Function to execute on target CPU(s).
    153154 * @param   pArgs          Pointer to RTMPARGS to pass to @a pfnSolWorker.
    154  *
    155  * @returns Solaris error code.
    156155 */
    157156static void rtMpSolCrossCall(PRTSOLCPUSET pCpuSet, PFNRTMPSOLWORKER pfnSolWorker, PRTMPARGS pArgs)
     
    296295
    297296
     297
     298/**
     299 * Wrapper between the native solaris per-cpu callback and PFNRTWORKER
     300 * for the RTMpOnPair API.
     301 *
     302 * @returns Solaris error code.
     303 * @param   uArgs       Pointer to the RTMPARGS package.
     304 * @param   uIgnored1   Ignored.
     305 * @param   uIgnored2   Ignored.
     306 */
     307static int rtMpSolOnPairCpuWrapper(void *uArg, void *uIgnored1, void *uIgnored2)
     308{
     309    PRTMPARGS pArgs = (PRTMPARGS)(uArg);
     310    RTCPUID idCpu = RTMpCpuId();
     311
     312    Assert(idCpu == pArgs->idCpu || idCpu == pArgs->idCpu2);
     313    pArgs->pfnWorker(idCpu, pArgs->pvUser1, pArgs->pvUser2);
     314    ASMAtomicIncU32(&pArgs->cHits);
     315
     316    NOREF(uIgnored1);
     317    NOREF(uIgnored2);
     318    return 0;
     319}
     320
     321
     322RTDECL(int) RTMpOnPair(RTCPUID idCpu1, RTCPUID idCpu2, uint32_t fFlags, PFNRTMPWORKER pfnWorker, void *pvUser1, void *pvUser2)
     323{
     324    int rc;
     325    RTMPARGS Args;
     326    RTTHREADPREEMPTSTATE PreemptState = RTTHREADPREEMPTSTATE_INITIALIZER;
     327
     328    AssertReturn(idCpu1 != idCpu2, VERR_INVALID_PARAMETER);
     329    AssertReturn(!(fFlags & RTMPON_F_VALID_MASK), VERR_INVALID_FLAGS);
     330
     331    Args.pfnWorker = pfnWorker;
     332    Args.pvUser1 = pvUser1;
     333    Args.pvUser2 = pvUser2;
     334    Args.idCpu   = idCpu1;
     335    Args.idCpu2  = idCpu2;
     336    Args.cHits   = 0;
     337
     338    RTSOLCPUSET CpuSet;
     339    for (int i = 0; i < IPRT_SOL_SET_WORDS; i++)
     340        CpuSet.auCpus[i] = 0;
     341    BT_SET(CpuSet.auCpus, idCpu1);
     342    BT_SET(CpuSet.auCpus, idCpu2);
     343
     344    /*
     345     * Check that both CPUs are online before doing the broadcast call.
     346     */
     347    RTThreadPreemptDisable(&PreemptState);
     348    if (   RTMpIsCpuOnline(idCpu1)
     349        && RTMpIsCpuOnline(idCpu2))
     350    {
     351        rtMpSolCrossCall(&CpuSet, rtMpSolOnPairCpuWrapper, &Args);
     352
     353        Assert(Args.cHits <= 2);
     354        if (Args.cHits == 2)
     355            rc = VINF_SUCCESS;
     356        else if (Args.cHits == 1)
     357            rc = VERR_NOT_ALL_CPUS_SHOWED;
     358        else if (Args.cHits == 0)
     359            rc = VERR_CPU_OFFLINE;
     360        else
     361            rc = VERR_CPU_IPE_1;
     362    }
     363    /*
     364     * A CPU must be present to be considered just offline.
     365     */
     366    else if (   RTMpIsCpuPresent(idCpu1)
     367             && RTMpIsCpuPresent(idCpu2))
     368        rc = VERR_CPU_OFFLINE;
     369    else
     370        rc = VERR_CPU_NOT_FOUND;
     371
     372    RTThreadPreemptRestore(&PreemptState);;
     373    return rc;
     374}
     375
     376
     377RTDECL(bool) RTMpOnPairIsConcurrentExecSupported(void)
     378{
     379    return true;
     380}
     381
     382
    298383/**
    299384 * Wrapper between the native solaris per-cpu callback and PFNRTWORKER
    300385 * for the RTMpOnSpecific API.
    301386 *
     387 * @returns Solaris error code.
    302388 * @param   uArgs       Pointer to the RTMPARGS package.
    303389 * @param   uIgnored1   Ignored.
    304390 * @param   uIgnored2   Ignored.
    305  *
    306  * @returns Solaris error code.
    307391 */
    308392static int rtMpSolOnSpecificCpuWrapper(void *uArg, void *uIgnored1, void *uIgnored2)
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