// Mutexes
//
extern void initMutex ( Mutex* pMut );
+extern void closeMutex ( Mutex* pMut );
//
// Thread-local storage
}
// we now have the Capability, its run queue and spare workers
// list are both empty.
+
+ // We end up here only in THREADED_RTS
+ closeMutex(&cap->lock);
}
/* ----------------------------------------------------------------------------
boundTaskExiting(task);
stopTaskManager();
}
+ closeMutex(&sched_mutex);
#endif
}
stgFree(stable_ptr_table);
stable_ptr_table = NULL;
SPT_size = 0;
+#ifdef THREADED_RTS
+ closeMutex(&stable_mutex);
+#endif
}
/*
stgFree(generations[g].steps);
stgFree(generations);
freeAllMBlocks();
+#if defined(THREADED_RTS)
+ closeMutex(&sm_mutex);
+ closeMutex(&atomic_modify_mutvar_mutex);
+#endif
}
/* -----------------------------------------------------------------------------
for (task = task_free_list; task != NULL; task = next) {
next = task->next;
stgFree(task);
+#if defined(THREADED_RTS)
+ closeCondition(&task->cond);
+ closeMutex(&task->lock);
+#endif
}
task_free_list = NULL;
RELEASE_LOCK(&sched_mutex);
exitTypeableStore()\r
{\r
#ifdef THREADED_RTS\r
- /* TODO: Free Mutex! */\r
+ closeMutex(&typeableStoreLock);\r
#endif\r
if(typeableStore!=0) {\r
freeStablePtr((StgStablePtr)typeableStore);\r
#endif
return;
}
+void
+closeMutex(Mutex* pMut)
+{
+ pthread_mutex_destroy(pMut);
+}
void
newThreadLocalKey (ThreadLocalKey *key)
{
InitializeCriticalSectionAndSpinCount(pMut,4000);
}
+void
+closeMutex (Mutex* pMut)
+{
+ DeleteCriticalSection(pMut);
+}
#else
void
initMutex (Mutex* pMut)
*pMut = h;
return;
}
+void
+closeMutex (Mutex* pMut)
+{
+ CloseHandle(*pMut);
+}
#endif
void