summaryrefslogtreecommitdiff
path: root/rts/sm/Compact.c
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2010-03-09 14:31:11 +0000
committerSimon Marlow <marlowsd@gmail.com>2010-03-09 14:31:11 +0000
commit7effbbbbdfe7eb05c6402fa9337e358e7e9fadde (patch)
treed5896a7858db38265b77fc799fc54d5151737aab /rts/sm/Compact.c
parent4e8b07dbc753a5132c574926468ba886728c9049 (diff)
downloadhaskell-7effbbbbdfe7eb05c6402fa9337e358e7e9fadde.tar.gz
Split part of the Task struct into a separate struct InCall
The idea is that this leaves Tasks and OSThread in one-to-one correspondence. The part of a Task that represents a call into Haskell from C is split into a separate struct InCall, pointed to by the Task and the TSO bound to it. A given OSThread/Task thus always uses the same mutex and condition variable, rather than getting a new one for each callback. Conceptually it is simpler, although there are more types and indirections in a few places now. This improves callback performance by removing some of the locks that we had to take when making in-calls. Now we also keep the current Task in a thread-local variable if supported by the OS and gcc (currently only Linux).
Diffstat (limited to 'rts/sm/Compact.c')
-rw-r--r--rts/sm/Compact.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/rts/sm/Compact.c b/rts/sm/Compact.c
index 315eda732d..e55ae2b7c2 100644
--- a/rts/sm/Compact.c
+++ b/rts/sm/Compact.c
@@ -1014,10 +1014,14 @@ compact(StgClosure *static_objects)
// the task list
{
Task *task;
+ InCall *incall;
for (task = all_tasks; task != NULL; task = task->all_link) {
- if (task->tso) {
- thread_(&task->tso);
- }
+ for (incall = task->incall; incall != NULL;
+ incall = incall->prev_stack) {
+ if (incall->tso) {
+ thread_(&incall->tso);
+ }
+ }
}
}