Exemple #1
0
void
MXUser_DestroyRWLock(MXUserRWLock *lock)  // IN:
{
   if (LIKELY(lock != NULL)) {
      MXUserValidateHeader(&lock->header, MXUSER_TYPE_RW);

      if (Atomic_Read(&lock->holderCount) != 0) {
         MXUserDumpAndPanic(&lock->header,
                            "%s: Destroy on an acquired read-write lock\n",
                            __FUNCTION__);
      }

      if (LIKELY(lock->useNative)) {
         int err = MXUserNativeRWDestroy(&lock->nativeLock);

         if (UNLIKELY(err != 0)) {
            MXUserDumpAndPanic(&lock->header, "%s: Internal error (%d)\n",
                               __FUNCTION__, err);
         }
      }

      lock->header.signature = 0;  // just in case...

      MXRecLockDestroy(&lock->recursiveLock);

      MXUserRemoveFromList(&lock->header);

      if (vmx86_stats) {
         MXUserStats *stats = Atomic_ReadPtr(&lock->statsMem);

         if (LIKELY(stats != NULL)) {
            MXUserAcquisitionStatsTearDown(&stats->acquisitionStats);
            MXUserHistoTearDown(Atomic_ReadPtr(&stats->acquisitionHisto));

            MXUserBasicStatsTearDown(&stats->heldStats);
            MXUserHistoTearDown(Atomic_ReadPtr(&stats->heldHisto));

            free(stats);
         }
      }

      HashTable_FreeUnsafe(lock->holderTable);
      free(lock->header.name);
      lock->header.name = NULL;
      free(lock);
   }
}
Exemple #2
0
void
MXUser_DestroyExclLock(MXUserExclLock *lock)  // IN:
{
   if (lock != NULL) {
      MXUserValidateHeader(&lock->header, MXUSER_TYPE_EXCL);

      if (MXRecLockCount(&lock->recursiveLock) > 0) {
         MXUserDumpAndPanic(&lock->header,
                            "%s: Destroy of an acquired exclusive lock\n",
                            __FUNCTION__);
      }

      lock->header.signature = 0;  // just in case...

      MXRecLockDestroy(&lock->recursiveLock);

      MXUserRemoveFromList(&lock->header);

      if (vmx86_stats) {
         MXUserStats *stats = Atomic_ReadPtr(&lock->statsMem);

         if (LIKELY(stats != NULL)) {
            MXUserAcquisitionStatsTearDown(&stats->acquisitionStats);
            MXUserHistoTearDown(Atomic_ReadPtr(&stats->acquisitionHisto));

            MXUserBasicStatsTearDown(&stats->heldStats);
            MXUserHistoTearDown(Atomic_ReadPtr(&stats->heldHisto));

            free(stats);
         }
      }

      free(lock->header.name);
      lock->header.name = NULL;
      free(lock);
   }
}
void
MXUserAcquisitionStatsTearDown(MXUserAcquisitionStats *stats)  // IN/OUT:
{
    MXUserBasicStatsTearDown(&stats->basicStats);
}