diff options
author | dgilbert <dgilbert@us.ibm.com> | 2011-06-03 12:54:41 -0500 |
---|---|---|
committer | A. Patrick Williams III <iawillia@us.ibm.com> | 2011-06-17 12:23:52 -0500 |
commit | 609d6810b8bc92dc979f8bbb8e7e7d7b7b5d9490 (patch) | |
tree | cd517ec2e10a95638e675b037bb24e2d01296ef4 /src/include/kernel | |
parent | f64ba52098e248e62b4ddb14c0a027c21066e9e2 (diff) | |
download | talos-hostboot-609d6810b8bc92dc979f8bbb8e7e7d7b7b5d9490.tar.gz talos-hostboot-609d6810b8bc92dc979f8bbb8e7e7d7b7b5d9490.zip |
Initial futex support
Change-Id: I51a4f1117085ce23c7993c1a38e4124596636726
Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/141
Tested-by: Jenkins Server
Reviewed-by: Douglas R. Gilbert <dgilbert@us.ibm.com>
Reviewed-by: Thi N. Tran <thi@us.ibm.com>
Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/include/kernel')
-rw-r--r-- | src/include/kernel/cpu.H | 4 | ||||
-rw-r--r-- | src/include/kernel/futexmgr.H | 89 | ||||
-rw-r--r-- | src/include/kernel/syscalls.H | 15 | ||||
-rw-r--r-- | src/include/kernel/usermutex.H | 18 |
4 files changed, 97 insertions, 29 deletions
diff --git a/src/include/kernel/cpu.H b/src/include/kernel/cpu.H index 87e769743..0f36dd941 100644 --- a/src/include/kernel/cpu.H +++ b/src/include/kernel/cpu.H @@ -9,7 +9,7 @@ #include <kernel/types.h> #include <arch/ppc.H> #include <builtins.h> -#include <sys/mutex.h> +#include <sys/sync.h> // Thread ID support only, Power7 (4 threads). #define KERNEL_MAX_SUPPORTED_CPUS (4 * 8 * 4) // Sockets, cores, threads. @@ -36,7 +36,7 @@ struct cpu_t task_t* idle_task; /** XSCOM mutex to serialize access per CPU */ - mutex_t xscom_mutex; + mutex_t * xscom_mutex; }; /** @fn getCpuId diff --git a/src/include/kernel/futexmgr.H b/src/include/kernel/futexmgr.H new file mode 100644 index 000000000..824175136 --- /dev/null +++ b/src/include/kernel/futexmgr.H @@ -0,0 +1,89 @@ +#ifndef FUTEXMGR +#define FUTEXMGR + +/** + * @file futexmgr.H + * @brief Declaration for kernel side futex management + */ + +#include <stdint.h> +#include <util/locked/list.H> +#include <kernel/spinlock.H> + +struct task_t; + + +/** + * @class FutexManager + * Kernel internal management of fuxtexs + */ +class FutexManager +{ + public: + + /** + * Put the current processes on a wait queue + * @param[in] i_task pointer to the current task structure + * @param[in] i_addr Futex address + * @param[in] i_val Value that *i_addr should contain + * @returns [0 | error code] if *i_addr != i_val returns EWOULDBLOCK + */ + static uint64_t wait(task_t * i_task, uint64_t * i_addr, uint64_t i_val); + + /** + * Wakeup threads + * @param[in] i_addr pointer to a futex + * @param[in] i_count The max number of threads to wake + * @returns The number of threads awoken + */ + static uint64_t wake(uint64_t * i_addr, uint64_t i_count); + + protected: + + /** + * Ctor + */ + FutexManager() {}; + + /** + * Dtor + */ + ~FutexManager() {}; + + private: // functions + + /** + * Put the current processes on a wait queue + * @param[in] i_task pointer to the current task structure + * @param[in] i_addr Futex address + * @param[in] i_val Value that *i_addr should contain + * @returns [0 | error code] if *i_addr != i_val returns EWOULDBLOCK + */ + uint64_t _wait(task_t * i_task, uint64_t * i_addr, uint64_t i_val); + + /** + * Wakeup threads + * @param[in] i_addr pointer to a futex + * @param[in] i_count The max number of threads to wake + * @returns The number of threads awoken + */ + uint64_t _wake(uint64_t * i_addr, uint64_t i_count); + + private: // data + + struct _FutexWait_t + { + _FutexWait_t * next; ///< next _FutexWait_t in list + _FutexWait_t * prev; ///< prev _FutexWait_t in list + uint64_t * key; ///< search key is futex address + task_t* task; ///< task on wait list + }; + + typedef Util::Locked::List<_FutexWait_t, uint64_t *> FutexList_t; + + Spinlock iv_lock; ///< lock + FutexList_t iv_list; ///< List of waiting tasks for all futexes +}; + +#endif + diff --git a/src/include/kernel/syscalls.H b/src/include/kernel/syscalls.H index 1b87c5019..26e2bdf75 100644 --- a/src/include/kernel/syscalls.H +++ b/src/include/kernel/syscalls.H @@ -24,15 +24,6 @@ namespace Systemcalls /** task_end() */ TASK_END, - /** mutex_create() */ - MUTEX_CREATE, - /** mutex_destroy() */ - MUTEX_DESTROY, - /** mutex_lock() */ - MUTEX_LOCK_CONTESTED, - /** mutex_unlock() */ - MUTEX_UNLOCK_CONTESTED, - /** msgq_create() */ MSGQ_CREATE, /** msgq_destroy() */ @@ -59,6 +50,12 @@ namespace Systemcalls /** nanosleep() */ TIME_NANOSLEEP, + /** futex_wait() */ + FUTEX_WAIT, + + /** futex_wake() */ + FUTEX_WAKE, + SYSCALL_MAX }; diff --git a/src/include/kernel/usermutex.H b/src/include/kernel/usermutex.H deleted file mode 100644 index c9f631579..000000000 --- a/src/include/kernel/usermutex.H +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef __KERNEL_USERMUTEX_H -#define __KERNEL_USERMUTEX_H - -#include <util/locked/queue.H> -#include <kernel/spinlock.H> -#include <kernel/task.H> - -struct UserMutex -{ - uint64_t value; - bool unlock_pend; - Spinlock lock; - Util::Locked::Queue<task_t> waiting; - - UserMutex() : value(0), unlock_pend(false) {}; -}; - -#endif |