diff options
author | Simon Marlow <marlowsd@gmail.com> | 2011-12-06 15:12:07 +0000 |
---|---|---|
committer | Simon Marlow <marlowsd@gmail.com> | 2011-12-06 16:00:27 +0000 |
commit | 92e7d6c92fdd14de424524564376d3522f2a40cc (patch) | |
tree | 5715d44012b452f5020ca14331a1fe50d5fd9600 /rts/Task.c | |
parent | 8b75acd3ca25165536f18976c8d80cb62ad613e4 (diff) | |
download | haskell-92e7d6c92fdd14de424524564376d3522f2a40cc.tar.gz |
Allow the number of capabilities to be increased at runtime (#3729)
At present the number of capabilities can only be *increased*, not
decreased. The latter presents a few more challenges!
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) { |