summaryrefslogtreecommitdiff
path: root/rts/Capability.c
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2019-09-27 15:48:41 +0000
committerBen Gamari <ben@smart-cactus.org>2020-10-24 21:00:36 -0400
commitf6b4b492d9c112c30ddc0bda2338b143b56faf4c (patch)
treec063d0b3adeeb3d434f20d0f459078c3bc122a39 /rts/Capability.c
parent2781d68c5d94fd87435d6316c2d4118171e97b14 (diff)
downloadhaskell-f6b4b492d9c112c30ddc0bda2338b143b56faf4c.tar.gz
rts: Clarify locking behavior of releaseCapability_
Diffstat (limited to 'rts/Capability.c')
-rw-r--r--rts/Capability.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/rts/Capability.c b/rts/Capability.c
index 07141009a1..f13d076ca5 100644
--- a/rts/Capability.c
+++ b/rts/Capability.c
@@ -505,6 +505,9 @@ giveCapabilityToTask (Capability *cap USED_IF_DEBUG, Task *task)
* The current Task (cap->task) releases the Capability. The Capability is
* marked free, and if there is any work to do, an appropriate Task is woken up.
*
+ * The caller must hold cap->lock and will still hold it after
+ * releaseCapability returns.
+ *
* N.B. May need to take all_tasks_mutex.
*
* ------------------------------------------------------------------------- */
@@ -520,6 +523,7 @@ releaseCapability_ (Capability* cap,
ASSERT_PARTIAL_CAPABILITY_INVARIANTS(cap,task);
ASSERT_RETURNING_TASKS(cap,task);
+ ASSERT_LOCK_HELD(&cap->lock);
cap->running_task = NULL;