diff options
Diffstat (limited to 'rts/Task.c')
-rw-r--r-- | rts/Task.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/rts/Task.c b/rts/Task.c index d72d8a9085..36dd0a94b9 100644 --- a/rts/Task.c +++ b/rts/Task.c @@ -325,6 +325,34 @@ discardTasksExcept (Task *keep) RELEASE_LOCK(&all_tasks_mutex); } +// +// After the capabilities[] array has moved, we have to adjust all +// (Capability *) pointers to point to the new array. The old array +// is still valid at this point. +// +void updateCapabilityRefs (void) +{ + Task *task; + InCall *incall; + + ACQUIRE_LOCK(&all_tasks_mutex); + + for (task = all_tasks; task != NULL; task=task->all_link) { + if (task->cap != NULL) { + task->cap = &capabilities[task->cap->no]; + } + + for (incall = task->incall; incall != NULL; incall = incall->prev_stack) { + if (incall->suspended_cap != NULL) { + incall->suspended_cap = &capabilities[incall->suspended_cap->no]; + } + } + } + + RELEASE_LOCK(&all_tasks_mutex); +} + + void taskTimeStamp (Task *task USED_IF_THREADS) { |