VirtualBox

Ignore:
Timestamp:
Aug 29, 2013 5:16:42 PM (11 years ago)
Author:
vboxsync
Message:

r0drv/solaris/timer: Fix specific periodic timers, one-shot any-cpu timers.
Fixed R0 timer testcase to not do unsupported and potentially dangerous tests on Solaris.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r0drv/solaris/timer-r0drv-solaris.c

    r48148 r48165  
    137137    PRTTIMER pTimer = (PRTTIMER)pvArg;
    138138    AssertPtrReturnVoid(pTimer);
     139    Assert(!RTThreadPreemptIsEnabled(NIL_RTTHREAD));
     140
     141    if (pTimer->fSuspended)
     142        return;
    139143
    140144    if (pTimer->pSingleTimer)
    141145    {
     146        /* For specific periodic timers, we might fire on the wrong CPU between cyclic_add() and cyclic_bind().
     147           Ignore these shots while we are temporarily rebinding to the right CPU. */
     148        if (   pTimer->fSpecificCpu
     149            && pTimer->interval != 0
     150            && pTimer->iCpu != RTMpCpuId())          /* ASSUMES: index == cpuid */
     151        {
     152            return;
     153        }
     154
     155        /* Allow RTTimer to be restarted for one-shot timers. */
     156        if (pTimer->interval == 0)
     157            pTimer->fSuspended = true;
    142158        uint64_t u64Tick = ++pTimer->pSingleTimer->u64Tick;
    143159        pTimer->pfnTimer(pTimer, pTimer->pvUser, u64Tick);
     
    203219        return VERR_CPU_NOT_FOUND;
    204220
    205     if ((fFlags & RTTIMER_FLAGS_CPU_ALL) == RTTIMER_FLAGS_CPU_ALL && u64NanoInterval == 0)
     221    /* One-shot omni timers are not supported by the cyclic system. */
     222    if (   (fFlags & RTTIMER_FLAGS_CPU_ALL) == RTTIMER_FLAGS_CPU_ALL
     223        && u64NanoInterval == 0)
     224    {
    206225        return VERR_NOT_SUPPORTED;
    207 
    208     /* One-shot timers are not supported by the cyclic system. */
    209     if (u64NanoInterval == 0)
     226    }
     227
     228    /* One-shot specific timers are not supported. See rtTimerSolCallbackWrapper(). */
     229    if (   (fFlags & RTTIMER_FLAGS_CPU_ALL) != RTTIMER_FLAGS_CPU_ALL
     230        && (fFlags & RTTIMER_FLAGS_CPU_SPECIFIC)
     231        && u64NanoInterval == 0)
     232    {
    210233        return VERR_NOT_SUPPORTED;
     234    }
    211235
    212236    /*
     
    274298        return VERR_TIMER_ACTIVE;
    275299
    276     /* One-shot timers are not supported by the cyclic system. */
    277     if (pTimer->interval == 0)
    278         return VERR_NOT_SUPPORTED;
    279 
    280300    pTimer->fSuspended = false;
    281301    if (pTimer->fAllCpu)
    282302    {
     303        Assert(pTimer->interval);
    283304        PRTR0OMNITIMERSOL pOmniTimer = RTMemAllocZ(sizeof(RTR0OMNITIMERSOL));
    284305        if (RT_UNLIKELY(!pOmniTimer))
     
    338359        pSingleTimer->hFireTime.cyt_when = u64First + RTTimeNanoTS();
    339360        if (pTimer->interval == 0)
    340         {
    341             /** @todo use gethrtime_max instead of LLONG_MAX? */
    342             AssertCompileSize(pSingleTimer->hFireTime.cyt_interval, sizeof(long long));
    343             pSingleTimer->hFireTime.cyt_interval = LLONG_MAX - pSingleTimer->hFireTime.cyt_when;
    344         }
     361            pSingleTimer->hFireTime.cyt_interval = INT64_MAX - pSingleTimer->hFireTime.cyt_when;
    345362        else
    346363            pSingleTimer->hFireTime.cyt_interval = pTimer->interval;
    347 
    348         /* Disable interrupts to prevent timer firing between cyclic_add() and cyclic_bind(). */
    349         RTCCUINTREG uEflags = ASMIntDisableFlags();
    350364
    351365        pTimer->hCyclicId = cyclic_add(&pSingleTimer->hHandler, &pSingleTimer->hFireTime);
     
    353367            cyclic_bind(pTimer->hCyclicId, cpu[iCpu], NULL /* cpupart */);
    354368
    355         ASMSetFlags(uEflags);
    356369        mutex_exit(&cpu_lock);
    357370    }
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