summaryrefslogtreecommitdiff
path: root/rts/ThreadLabels.c
diff options
context:
space:
mode:
authorSimon Marlow <simonmar@microsoft.com>2006-06-16 10:33:42 +0000
committerSimon Marlow <simonmar@microsoft.com>2006-06-16 10:33:42 +0000
commitb1953bbb1ed3cb16497e5447db7487f0c2d9e41a (patch)
treedf9e129c57b586a952634dc080939b621ae64cf8 /rts/ThreadLabels.c
parent1e3d53b4707a6c9c7c99cdaa54e3646b840f5cc9 (diff)
downloadhaskell-b1953bbb1ed3cb16497e5447db7487f0c2d9e41a.tar.gz
Asynchronous exception support for SMP
This patch makes throwTo work with -threaded, and also refactors large parts of the concurrency support in the RTS to clean things up. We have some new files: RaiseAsync.{c,h} asynchronous exception support Threads.{c,h} general threading-related utils Some of the contents of these new files used to be in Schedule.c, which is smaller and cleaner as a result of the split. Asynchronous exception support in the presence of multiple running Haskell threads is rather tricky. In fact, to my annoyance there are still one or two bugs to track down, but the majority of the tests run now.
Diffstat (limited to 'rts/ThreadLabels.c')
-rw-r--r--rts/ThreadLabels.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/rts/ThreadLabels.c b/rts/ThreadLabels.c
index 9b9f1723ff..72cd5d3c4b 100644
--- a/rts/ThreadLabels.c
+++ b/rts/ThreadLabels.c
@@ -8,8 +8,10 @@
* ---------------------------------------------------------------------------*/
#include "PosixSource.h"
+#include "Rts.h"
#include "ThreadLabels.h"
#include "RtsUtils.h"
+#include "Hash.h"
#include <stdlib.h>
@@ -47,4 +49,19 @@ removeThreadLabel(StgWord key)
stgFree(old);
}
}
+
+void
+labelThread(StgPtr tso, char *label)
+{
+ int len;
+ void *buf;
+
+ /* Caveat: Once set, you can only set the thread name to "" */
+ len = strlen(label)+1;
+ buf = stgMallocBytes(len * sizeof(char), "Schedule.c:labelThread()");
+ strncpy(buf,label,len);
+ /* Update will free the old memory for us */
+ updateThreadLabel(((StgTSO *)tso)->id,buf);
+}
+
#endif /* DEBUG */