summaryrefslogtreecommitdiff
path: root/rts/RtsAPI.c
diff options
context:
space:
mode:
authorDuncan Coutts <duncan@well-typed.com>2012-07-03 19:48:11 +0100
committerMikolaj Konarski <mikolaj@well-typed.com>2012-07-10 17:53:44 +0200
commit38397354574eb09e8d8f29e56e7e2943363fc0d0 (patch)
tree99621843ac7bd4772735d66f83375daa339de46f /rts/RtsAPI.c
parent54c98b687a5e23f3371604dc4918dfb3106a74f8 (diff)
downloadhaskell-38397354574eb09e8d8f29e56e7e2943363fc0d0.tar.gz
Emit the task-tracking events
Based on initial patches by Mikolaj Konarski <mikolaj@well-typed.com> Use the new task tracing functions traceTaskCreate/Migrate/Delete. There are two key places. One is for worker tasks which have a relatively simple life cycle. Worker tasks are created and deleted by the RTS. The other case is bound tasks which are either created by the RTS, or appear as foreign C threads making calls into the RTS. For bound threads we do the tracing in rts_lock/unlock, which actually covers both threads coming in from outside, and also bound threads made by the RTS.
Diffstat (limited to 'rts/RtsAPI.c')
-rw-r--r--rts/RtsAPI.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/rts/RtsAPI.c b/rts/RtsAPI.c
index 0463f15ad8..c0896f7c6a 100644
--- a/rts/RtsAPI.c
+++ b/rts/RtsAPI.c
@@ -553,6 +553,14 @@ rts_lock (void)
cap = NULL;
waitForReturnCapability(&cap, task);
+
+ if (task->incall->prev_stack == NULL) {
+ // This is a new outermost call from C into Haskell land.
+ // Until the corresponding call to rts_unlock, this task
+ // is doing work on behalf of the RTS.
+ traceTaskCreate(task, cap);
+ }
+
return (Capability *)cap;
}
@@ -586,4 +594,11 @@ rts_unlock (Capability *cap)
// Finally, we can release the Task to the free list.
boundTaskExiting(task);
RELEASE_LOCK(&cap->lock);
+
+ if (task->incall == NULL) {
+ // This is the end of an outermost call from C into Haskell land.
+ // From here on, the task goes back to C land and we should not count
+ // it as doing work on behalf of the RTS.
+ traceTaskDelete(task);
+ }
}