diff options
author | Richard Braun <rbraun@sceen.net> | 2017-03-04 15:07:39 +0100 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2017-03-04 15:21:33 +0100 |
commit | cb00e8534c520e112b3f9b677cb0a639328df243 (patch) | |
tree | 36b233c63739499832084cb0afac1d7e85262098 /kern/thread.h | |
parent | 5604e40e64ef079f9815077b1d98621acf212869 (diff) |
kern/sleepq: new module
This module provides simple generic sleep queues that can be used to
implement higher level synchronization facilities such as mutexes and
condition variables.
Diffstat (limited to 'kern/thread.h')
-rw-r--r-- | kern/thread.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/kern/thread.h b/kern/thread.h index 21be2ab7..1542e7ae 100644 --- a/kern/thread.h +++ b/kern/thread.h @@ -367,6 +367,29 @@ thread_schedule(void) } /* + * Sleep queue lending functions. + */ + +static inline struct sleepq * +thread_sleepq_lend(void) +{ + struct sleepq *sleepq; + + sleepq = thread_self()->priv_sleepq; + assert(sleepq != NULL); + thread_self()->priv_sleepq = NULL; + return sleepq; +} + +static inline void +thread_sleepq_return(struct sleepq *sleepq) +{ + assert(sleepq != NULL); + assert(thread_self()->priv_sleepq == NULL); + thread_self()->priv_sleepq = sleepq; +} + +/* * Migration control functions. * * Functions that change the migration state are implicit compiler barriers. |