summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--includes/rts/OSThreads.h2
-rw-r--r--rts/Task.c2
-rw-r--r--rts/posix/OSThreads.c7
-rw-r--r--rts/sm/GC.c17
-rw-r--r--rts/win32/OSThreads.c3
-rw-r--r--testsuite/tests/rts/testwsdeque.c2
6 files changed, 19 insertions, 14 deletions
diff --git a/includes/rts/OSThreads.h b/includes/rts/OSThreads.h
index e99be8acd2..a3ed47c19b 100644
--- a/includes/rts/OSThreads.h
+++ b/includes/rts/OSThreads.h
@@ -171,7 +171,7 @@ extern void yieldThread ( void );
typedef void OSThreadProcAttr OSThreadProc(void *);
-extern int createOSThread ( OSThreadId* tid,
+extern int createOSThread ( OSThreadId* tid, char *name,
OSThreadProc *startProc, void *param);
extern rtsBool osThreadIsAlive ( OSThreadId id );
extern void interruptOSThread (OSThreadId id);
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 */
diff --git a/testsuite/tests/rts/testwsdeque.c b/testsuite/tests/rts/testwsdeque.c
index 51aeec1ca4..e6f644c5de 100644
--- a/testsuite/tests/rts/testwsdeque.c
+++ b/testsuite/tests/rts/testwsdeque.c
@@ -149,7 +149,7 @@ int main(int argc, char*argv[])
}
for (n=0; n < THREADS; n++) {
- createOSThread(&ids[n], thief, (void*)(StgWord)n);
+ createOSThread(&ids[n], "thief", thief, (void*)(StgWord)n);
}
for (n=0; n < SCRATCH_SIZE; n++) {