diff options
author | Esa Ilari Vuokko <ei@vuokko.info> | 2006-08-23 19:46:04 +0000 |
---|---|---|
committer | Esa Ilari Vuokko <ei@vuokko.info> | 2006-08-23 19:46:04 +0000 |
commit | 88b35c172f9434fd98b700f706074d142914a8bb (patch) | |
tree | 69dad172652bfbb112ab2ef8afc964c0112b662b /rts | |
parent | 52589e05f86d593bc3e6ea3f1a0b8f6ceae94fe6 (diff) | |
download | haskell-88b35c172f9434fd98b700f706074d142914a8bb.tar.gz |
Add closeMutex and use it on clean up
Diffstat (limited to 'rts')
-rw-r--r-- | rts/Capability.c | 3 | ||||
-rw-r--r-- | rts/Schedule.c | 1 | ||||
-rw-r--r-- | rts/Stable.c | 3 | ||||
-rw-r--r-- | rts/Storage.c | 4 | ||||
-rw-r--r-- | rts/Task.c | 4 | ||||
-rw-r--r-- | rts/Typeable.c | 2 | ||||
-rw-r--r-- | rts/posix/OSThreads.c | 5 | ||||
-rw-r--r-- | rts/win32/OSThreads.c | 10 |
8 files changed, 31 insertions, 1 deletions
diff --git a/rts/Capability.c b/rts/Capability.c index 2384262ae9..e384e1eddd 100644 --- a/rts/Capability.c +++ b/rts/Capability.c @@ -671,6 +671,9 @@ shutdownCapability (Capability *cap, Task *task) } // 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); } /* ---------------------------------------------------------------------------- diff --git a/rts/Schedule.c b/rts/Schedule.c index b9b4325c0f..49e25be329 100644 --- a/rts/Schedule.c +++ b/rts/Schedule.c @@ -2584,6 +2584,7 @@ exitScheduler( void ) boundTaskExiting(task); stopTaskManager(); } + closeMutex(&sched_mutex); #endif } diff --git a/rts/Stable.c b/rts/Stable.c index 2c4157b431..813c6c8b47 100644 --- a/rts/Stable.c +++ b/rts/Stable.c @@ -169,6 +169,9 @@ exitStablePtrTable(void) stgFree(stable_ptr_table); stable_ptr_table = NULL; SPT_size = 0; +#ifdef THREADED_RTS + closeMutex(&stable_mutex); +#endif } /* diff --git a/rts/Storage.c b/rts/Storage.c index 3594f7197f..0c9c60e580 100644 --- a/rts/Storage.c +++ b/rts/Storage.c @@ -279,6 +279,10 @@ freeStorage (void) stgFree(generations[g].steps); stgFree(generations); freeAllMBlocks(); +#if defined(THREADED_RTS) + closeMutex(&sm_mutex); + closeMutex(&atomic_modify_mutvar_mutex); +#endif } /* ----------------------------------------------------------------------------- diff --git a/rts/Task.c b/rts/Task.c index 3be5b283d7..a03ed87651 100644 --- a/rts/Task.c +++ b/rts/Task.c @@ -77,6 +77,10 @@ stopTaskManager (void) 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); diff --git a/rts/Typeable.c b/rts/Typeable.c index e07c764c55..4c4d460d66 100644 --- a/rts/Typeable.c +++ b/rts/Typeable.c @@ -20,7 +20,7 @@ void exitTypeableStore()
{
#ifdef THREADED_RTS
- /* TODO: Free Mutex! */
+ closeMutex(&typeableStoreLock);
#endif
if(typeableStore!=0) {
freeStablePtr((StgStablePtr)typeableStore);
diff --git a/rts/posix/OSThreads.c b/rts/posix/OSThreads.c index cff37824cb..b30d08545d 100644 --- a/rts/posix/OSThreads.c +++ b/rts/posix/OSThreads.c @@ -106,6 +106,11 @@ initMutex(Mutex* pMut) #endif return; } +void +closeMutex(Mutex* pMut) +{ + pthread_mutex_destroy(pMut); +} void newThreadLocalKey (ThreadLocalKey *key) diff --git a/rts/win32/OSThreads.c b/rts/win32/OSThreads.c index c772be38f4..00effdaaac 100644 --- a/rts/win32/OSThreads.c +++ b/rts/win32/OSThreads.c @@ -116,6 +116,11 @@ initMutex (Mutex* pMut) { InitializeCriticalSectionAndSpinCount(pMut,4000); } +void +closeMutex (Mutex* pMut) +{ + DeleteCriticalSection(pMut); +} #else void initMutex (Mutex* pMut) @@ -127,6 +132,11 @@ initMutex (Mutex* pMut) *pMut = h; return; } +void +closeMutex (Mutex* pMut) +{ + CloseHandle(*pMut); +} #endif void |