diff options
author | Simon Marlow <marlowsd@gmail.com> | 2014-10-10 14:26:19 +0100 |
---|---|---|
committer | Simon Marlow <marlowsd@gmail.com> | 2014-10-10 14:31:59 +0100 |
commit | 674c631ea111233daa929ef63500d75ba0db8858 (patch) | |
tree | db42f94960c86876b73785f2c1946aeff871308e /rts | |
parent | d3f56ec6a6ead847233fee5dfad7979c2d63fc3d (diff) | |
download | haskell-674c631ea111233daa929ef63500d75ba0db8858.tar.gz |
Name worker threads using pthread_setname_np
This helps identify threads in gdb particularly in processes with a
lot of threads.
Diffstat (limited to 'rts')
-rw-r--r-- | rts/Task.c | 2 | ||||
-rw-r--r-- | rts/posix/OSThreads.c | 7 | ||||
-rw-r--r-- | rts/sm/GC.c | 17 | ||||
-rw-r--r-- | rts/win32/OSThreads.c | 3 |
4 files changed, 17 insertions, 12 deletions
diff --git a/rts/Task.c b/rts/Task.c index 0370711692..42893fe903 100644 --- a/rts/Task.c +++ b/rts/Task.c @@ -462,7 +462,7 @@ startWorkerTask (Capability *cap) ASSERT_LOCK_HELD(&cap->lock); cap->running_task = task; - r = createOSThread(&tid, (OSThreadProc*)workerStart, task); + r = createOSThread(&tid, "ghc_worker", (OSThreadProc*)workerStart, task); if (r != 0) { sysErrorBelch("failed to create OS thread"); stg_exit(EXIT_FAILURE); diff --git a/rts/posix/OSThreads.c b/rts/posix/OSThreads.c index e627babd98..e880b891d6 100644 --- a/rts/posix/OSThreads.c +++ b/rts/posix/OSThreads.c @@ -129,11 +129,14 @@ shutdownThread(void) } int -createOSThread (OSThreadId* pId, OSThreadProc *startProc, void *param) +createOSThread (OSThreadId* pId, char *name, + OSThreadProc *startProc, void *param) { int result = pthread_create(pId, NULL, (void *(*)(void *))startProc, param); - if(!result) + if (!result) { pthread_detach(*pId); + pthread_setname_np(*pId, name); + } return result; } diff --git a/rts/sm/GC.c b/rts/sm/GC.c index dabcd722d7..19d9ab23bc 100644 --- a/rts/sm/GC.c +++ b/rts/sm/GC.c @@ -670,6 +670,15 @@ GarbageCollect (nat collect_gen, if (major_gc) { gcCAFs(); } #endif + // Update the stable pointer hash table. + updateStableTables(major_gc); + + // unlock the StablePtr table. Must be before scheduleFinalizers(), + // because a finalizer may call hs_free_fun_ptr() or + // hs_free_stable_ptr(), both of which access the StablePtr table. + stableUnlock(); + + // Must be after stableUnlock(), because it might free stable ptrs. if (major_gc) { checkUnload (gct->scavenged_static_objects); } @@ -696,14 +705,6 @@ GarbageCollect (nat collect_gen, } } - // Update the stable pointer hash table. - updateStableTables(major_gc); - - // unlock the StablePtr table. Must be before scheduleFinalizers(), - // because a finalizer may call hs_free_fun_ptr() or - // hs_free_stable_ptr(), both of which access the StablePtr table. - stableUnlock(); - // Start any pending finalizers. Must be after // updateStableTables() and stableUnlock() (see #4221). RELEASE_SM_LOCK; diff --git a/rts/win32/OSThreads.c b/rts/win32/OSThreads.c index e336bd20cc..c3d3af64d2 100644 --- a/rts/win32/OSThreads.c +++ b/rts/win32/OSThreads.c @@ -98,7 +98,8 @@ shutdownThread() } int -createOSThread (OSThreadId* pId, OSThreadProc *startProc, void *param) +createOSThread (OSThreadId* pId, char *name STG_UNUSED, + OSThreadProc *startProc, void *param) { HANDLE h; h = CreateThread ( NULL, /* default security attributes */ |