VirtualBox

Changeset 22130 in vbox


Ignore:
Timestamp:
Aug 10, 2009 12:24:35 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
50898
Message:

spinlock-r0drv-[solaris|linux].c: More preemption assertions.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r0drv/linux/spinlock-r0drv-linux.c

    r21349 r22130  
    3535#include "the-linux-kernel.h"
    3636#include "internal/iprt.h"
     37#include <iprt/spinlock.h>
    3738
    38 #include <iprt/spinlock.h>
    39 #include <iprt/err.h>
    40 #include <iprt/alloc.h>
    4139#include <iprt/assert.h>
    4240#include <iprt/asm.h>
     41#include <iprt/err.h>
     42#include <iprt/mem.h>
     43#include <iprt/mp.h>
     44#include <iprt/thread.h>
    4345#include "internal/magics.h"
    4446
     
    134136{
    135137    PRTSPINLOCKINTERNAL pSpinlockInt = (PRTSPINLOCKINTERNAL)Spinlock;
     138    RT_ASSERT_PREEMPT_CPUID_VAR();
    136139    AssertMsg(pSpinlockInt && pSpinlockInt->u32Magic == RTSPINLOCK_MAGIC,
    137140              ("pSpinlockInt=%p u32Magic=%08x\n", pSpinlockInt, pSpinlockInt ? (int)pSpinlockInt->u32Magic : 0));
     
    139142
    140143    spin_lock(&pSpinlockInt->Spinlock);
     144
     145#ifdef RT_MORE_STRICT
     146    {
     147        RTCPUID const idAssertCpuNow = RTMpCpuId(); /* Spinlocks are not preemptible, so we cannot be rescheduled. */
     148        AssertMsg(idAssertCpu == idAssertCpuNow || idAssertCpu == NIL_RTCPUID,  ("%#x, %#x\n", idAssertCpu, idAssertCpuNow));
     149        pTmp->flFlags = idAssertCpuNow;
     150    }
     151#endif
    141152}
    142153RT_EXPORT_SYMBOL(RTSpinlockAcquire);
     
    146157{
    147158    PRTSPINLOCKINTERNAL pSpinlockInt = (PRTSPINLOCKINTERNAL)Spinlock;
     159#ifdef RT_MORE_STRICT
     160    RTCPUID const idAssertCpu = pTmp->flFlags;
     161    pTmp->flFlags = 0;
     162    RT_ASSERT_PREEMPT_CPUID();
     163#endif
    148164    AssertMsg(pSpinlockInt && pSpinlockInt->u32Magic == RTSPINLOCK_MAGIC,
    149165              ("pSpinlockInt=%p u32Magic=%08x\n", pSpinlockInt, pSpinlockInt ? (int)pSpinlockInt->u32Magic : 0));
     
    151167
    152168    spin_unlock(&pSpinlockInt->Spinlock);
     169
     170#ifdef RT_MORE_STRICT
     171    if (!RTThreadPreemptIsEnabled(NIL_RTTHREAD))
     172        RT_ASSERT_PREEMPT_CPUID();
     173#endif
    153174}
    154175RT_EXPORT_SYMBOL(RTSpinlockRelease);
  • trunk/src/VBox/Runtime/r0drv/solaris/spinlock-r0drv-solaris.c

    r22129 r22130  
    141141
    142142    mutex_enter(&pSpinlockInt->Mtx);
    143     RT_ASSERT_PREEMPT_CPUID();
     143
    144144#ifdef RT_MORE_STRICT
    145     /* Spinlocks are not preemptible, so we cannot be rescheduled. */
    146     pTmp->uFlags = idAssertCpu != NIL_RTCPUID ? idAssertCpu : RTMpCpuId();
     145    {
     146        RTCPUID const idAssertCpuNow = RTMpCpuId(); /* Spinlocks are not preemptible, so we cannot be rescheduled. */
     147        AssertMsg(idAssertCpu == idAssertCpuNow || idAssertCpu == NIL_RTCPUID,  ("%#x, %#x\n", idAssertCpu, idAssertCpuNow));
     148        pTmp->uFlags = idAssertCpuNow;
     149    }
    147150#endif
    148151}
     
    155158    RTCPUID const idAssertCpu = pTmp->uFlags;
    156159    pTmp->uFlags = 0;
     160    RT_ASSERT_PREEMPT_CPUID();
    157161#endif
    158162    AssertPtr(pSpinlockInt);
    159163    Assert(pSpinlockInt->u32Magic == RTSPINLOCK_MAGIC);
    160     RT_ASSERT_PREEMPT_CPUID();
    161164    NOREF(pTmp);
    162165
    163166    mutex_exit(&pSpinlockInt->Mtx);
     167
     168#ifdef RT_MORE_STRICT
     169    if (!RTThreadPreemptIsEnabled(NIL_RTTHREAD))
     170        RT_ASSERT_PREEMPT_CPUID();
     171#endif
    164172}
    165173
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