VirtualBox

Changeset 53347 in vbox for trunk/src/VBox/Runtime/r0drv


Ignore:
Timestamp:
Nov 18, 2014 4:09:52 PM (10 years ago)
Author:
vboxsync
Message:

Runtime/r0drv/solaris: Implemented RTTimerChangeInterval() and fix RTTimerStop() to be callable from the timer callback. RTTimerDestroy() is still not callable from the timer callback.

File:
1 edited

Legend:

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

    r52822 r53347  
    225225    pCyclicHandler->cyh_level = CY_LOCK_LEVEL;
    226226
    227     uint64_t u64Now = RTTimeNanoTS();
     227    uint64_t u64Now = RTTimeSystemNanoTS();
    228228    if (pTimer->pOmniTimer->u64When < u64Now)
    229229        pCyclicTime->cyt_when = u64Now + pTimer->interval / 2;
     
    308308     */
    309309    RTTimerStop(pTimer);
     310
     311    /** @remarks Do -not- call this function from a timer callback,
     312     *           cyclic_remove() will deadlock the system. */
     313    if (pTimer->pSingleTimer)
     314    {
     315        mutex_enter(&cpu_lock);
     316        cyclic_remove(pTimer->hCyclicId);
     317        mutex_exit(&cpu_lock);
     318        RTMemFree(pTimer->pSingleTimer);
     319    }
     320    else if (pTimer->pOmniTimer)
     321    {
     322        mutex_enter(&cpu_lock);
     323        cyclic_remove(pTimer->hCyclicId);
     324        mutex_exit(&cpu_lock);
     325        RTMemFree(pTimer->pOmniTimer->au64Ticks);
     326        RTMemFree(pTimer->pOmniTimer);
     327    }
     328
    310329    ASMAtomicWriteU32(&pTimer->u32Magic, ~RTTIMER_MAGIC);
    311330    RTMemFree(pTimer);
     
    342361         */
    343362        pTimer->pOmniTimer = pOmniTimer;
    344         pOmniTimer->u64When     = pTimer->interval + RTTimeNanoTS();
     363        pOmniTimer->u64When     = pTimer->interval + RTTimeSystemNanoTS();
    345364
    346365        cyc_omni_handler_t hOmni;
     
    382401        }
    383402
    384         pSingleTimer->hFireTime.cyt_when = u64First + RTTimeNanoTS();
     403        pSingleTimer->hFireTime.cyt_when = u64First + RTTimeSystemNanoTS();
    385404        if (pTimer->interval == 0)
    386405        {
     
    414433        return VERR_TIMER_SUSPENDED;
    415434
    416     pTimer->fSuspended = true;
    417     if (pTimer->pSingleTimer)
    418     {
    419         mutex_enter(&cpu_lock);
    420         cyclic_remove(pTimer->hCyclicId);
    421         mutex_exit(&cpu_lock);
    422         RTMemFree(pTimer->pSingleTimer);
    423     }
    424     else if (pTimer->pOmniTimer)
    425     {
    426         mutex_enter(&cpu_lock);
    427         cyclic_remove(pTimer->hCyclicId);
    428         mutex_exit(&cpu_lock);
    429         RTMemFree(pTimer->pOmniTimer->au64Ticks);
    430         RTMemFree(pTimer->pOmniTimer);
    431     }
    432 
    433     return VINF_SUCCESS;
     435    /*
     436     * Solaris does not allow removing cyclics from the timer callback but it does allow
     437     * reprogramming the cyclic. Reprogram such that it never expires.
     438     */
     439    int rc = RTTimerChangeInterval(pTimer, CY_INFINITY);
     440    if (RT_SUCCESS(rc))
     441        pTimer->fSuspended = true;
     442    return rc;
    434443}
    435444
     
    439448    RTTIMER_ASSERT_VALID_RET(pTimer);
    440449
    441     /** @todo implement me! */
    442 
    443     return VERR_NOT_SUPPORTED;
     450    if (pTimer->hCyclicId != CYCLIC_NONE)
     451    {
     452        uint64_t uNanoTS = RTTimeSystemNanoTS();
     453        if (   u64NanoInterval >= CY_INFINITY
     454            || uNanoTS >= CY_INFINITY - u64NanoInterval)
     455            cyclic_reprogram(pTimer->hCyclicId, CY_INFINITY);
     456        else
     457            cyclic_reprogram(pTimer->hCyclicId, (hrtime_t)(u64NanoInterval + uNanoTS));
     458
     459        return VINF_SUCCESS;
     460    }
     461    return VERR_INVALID_STATE;
    444462}
    445463
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