summaryrefslogtreecommitdiff
path: root/kern/sleepq.h
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2018-01-30 20:44:24 +0100
committerRichard Braun <rbraun@sceen.net>2018-01-30 20:44:24 +0100
commit9967e907feda967f237c30430f47357bc91332f5 (patch)
treeafad99fa69ba8cd0aa38c7bc695667520805d4c5 /kern/sleepq.h
parentbc6e853d4b27055056eebfd871aaf0fc60405b0f (diff)
Fix condition variable broadcasting
The broadcast implementation is based on an invalid assumption, namely that the first mutex_unlock call following condition_wait would be invoked on the same mutex. Fixing this while guarding against the thundering herd effect requires augmenting mutexes with a pointer to the condition variable they may be associated with. Since the size of mutexes is currently more important than broadcast scalability, the implementation is simplified into one which suffers from the thundering herd effect.
Diffstat (limited to 'kern/sleepq.h')
-rw-r--r--kern/sleepq.h17
1 files changed, 2 insertions, 15 deletions
diff --git a/kern/sleepq.h b/kern/sleepq.h
index 007e3f2f..213925cb 100644
--- a/kern/sleepq.h
+++ b/kern/sleepq.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017 Richard Braun.
+ * Copyright (c) 2017-2018 Richard Braun.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -125,25 +125,12 @@ int sleepq_timedwait(struct sleepq *sleepq, const char *wchan, uint64_t ticks);
* At least one thread is awaken if any threads are waiting on the sleep
* queue.
*
- * A broadcast differs only by also making all currently waiting threads
- * pending for wake-up. As with sleepq_signal, a single thread may be
- * awaken. The rationale is to force users to implement "chained waking"
- * in order to avoid the thundering herd effect.
+ * Broadcasting a sleep queue wakes up all waiting threads.
*/
void sleepq_signal(struct sleepq *sleepq);
void sleepq_broadcast(struct sleepq *sleepq);
/*
- * Wake up a pending thread.
- *
- * This function may only wake up a thread pending for wake-up after a
- * broadcast. It is used to chain wake-ups to avoid the thundering herd
- * effect. If there are no threads pending for wake-up, this function
- * does nothing.
- */
-void sleepq_wakeup(struct sleepq *sleepq);
-
-/*
* This init operation provides :
* - sleepq creation
* - module fully initialized