diff options
author | Richard Braun <rbraun@sceen.net> | 2018-01-30 20:44:24 +0100 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2018-01-30 20:44:24 +0100 |
commit | 9967e907feda967f237c30430f47357bc91332f5 (patch) | |
tree | afad99fa69ba8cd0aa38c7bc695667520805d4c5 /kern/thread.h | |
parent | bc6e853d4b27055056eebfd871aaf0fc60405b0f (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/thread.h')
-rw-r--r-- | kern/thread.h | 45 |
1 files changed, 1 insertions, 44 deletions
diff --git a/kern/thread.h b/kern/thread.h index 4761e1ec..8084c114 100644 --- a/kern/thread.h +++ b/kern/thread.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2017 Richard Braun. + * Copyright (c) 2012-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 @@ -41,7 +41,6 @@ #include <kern/atomic.h> #include <kern/init.h> -#include <kern/condition.h> #include <kern/cpumap.h> #include <kern/kernel.h> #include <kern/macros.h> @@ -442,48 +441,6 @@ thread_sleepq_return(struct sleepq *sleepq) } /* - * Condition variable related functions. - */ - -static inline void -thread_set_last_cond(struct condition *last_cond) -{ - struct thread *thread; - - thread = thread_self(); - assert(thread->last_cond == NULL); - thread->last_cond = last_cond; -} - -static inline struct condition * -thread_pull_last_cond(void) -{ - struct condition *last_cond; - struct thread *thread; - - thread = thread_self(); - last_cond = thread->last_cond; - - if (last_cond != NULL) { - thread->last_cond = NULL; - } - - return last_cond; -} - -static inline void -thread_wakeup_last_cond(void) -{ - struct condition *last_cond; - - last_cond = thread_pull_last_cond(); - - if (last_cond != NULL) { - condition_wakeup(last_cond); - } -} - -/* * Turnstile lending functions. */ |