1 /*-------------------------------------------------------------
3 cond.h -- Thread subsystem V
6 Michael Wiedenbauer (shagkur)
7 Dave Murphy (WinterMute)
9 This software is provided 'as-is', without any express or implied
10 warranty. In no event will the authors be held liable for any
11 damages arising from the use of this software.
13 Permission is granted to anyone to use this software for any
14 purpose, including commercial applications, and to alter it and
15 redistribute it freely, subject to the following restrictions:
17 1. The origin of this software must not be misrepresented; you
18 must not claim that you wrote the original software. If you use
19 this software in a product, an acknowledgment in the product
20 documentation would be appreciated but is not required.
22 2. Altered source versions must be plainly marked as such, and
23 must not be misrepresented as being the original software.
25 3. This notice may not be removed or altered from any source
28 -------------------------------------------------------------*/
35 \brief Thread subsystem V
42 #define LWP_COND_NULL 0xffffffff
49 /*! \typedef u32 cond_t
50 \brief typedef for the condition variable handle
55 /*! \fn s32 LWP_CondInit(cond_t *cond)
56 \brief Initialize condition variable
57 \param[out] cond pointer to the cond_t handle
59 \return 0 on success, <0 on error
61 s32
LWP_CondInit(cond_t
*cond
);
64 /*! \fn s32 LWP_CondWait(cond_t cond,mutex_t mutex)
65 \brief Wait on condition variable.
66 \param[in] cond handle to the cond_t structure
67 \param[in] mutex handle to the mutex_t structure
69 \return 0 on success, <0 on error
71 s32
LWP_CondWait(cond_t cond
,mutex_t mutex
);
74 /*! \fn s32 LWP_CondSignal(cond_t cond)
75 \brief Signal a specific thread waiting on this condition variable to wake up.
76 \param[in] cond handle to the cond_t structure
78 \return 0 on success, <0 on error
80 s32
LWP_CondSignal(cond_t cond
);
83 /*! \fn s32 LWP_CondBroadcast(cond_t cond)
84 \brief Broadcast all threads waiting on this condition variable to wake up.
85 \param[in] cond handle to the cond_t structure
87 \return 0 on success, <0 on error
89 s32
LWP_CondBroadcast(cond_t cond
);
92 /*! \fn s32 LWP_CondTimedWait(cond_t cond,mutex_t mutex,const struct timespec *abstime)
93 \brief Timed wait on a conditionvariable.
94 \param[in] cond handle to the cond_t structure
95 \param[in] mutex handle to the mutex_t structure
96 \param[in] abstime pointer to a timespec structure holding the abs time for the timeout.
98 \return 0 on success, <0 on error
100 s32
LWP_CondTimedWait(cond_t cond
,mutex_t mutex
,const struct timespec
*abstime
);
103 /*! \fn s32 LWP_CondDestroy(cond_t cond)
104 \brief Destroy condition variable, release all threads and handles blocked on that condition variable.
105 \param[in] cond handle to the cond_t structure
107 \return 0 on success, <0 on error
109 s32
LWP_CondDestroy(cond_t cond
);