aboutsummaryrefslogtreecommitdiffstats
path: root/src/chsem.c
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2007-11-30 09:00:50 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2007-11-30 09:00:50 +0000
commitc303a8a06e68fb30c082a4f1a4fcc675ff0bd39e (patch)
treefbaf137ef85a62d1977d14e412409e645fd048ca /src/chsem.c
parentf6e46bac2e7d9a62b54deac25b09b7f26bee40b1 (diff)
downloadChibiOS-c303a8a06e68fb30c082a4f1a4fcc675ff0bd39e.tar.gz
ChibiOS-c303a8a06e68fb30c082a4f1a4fcc675ff0bd39e.tar.bz2
ChibiOS-c303a8a06e68fb30c082a4f1a4fcc675ff0bd39e.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@121 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'src/chsem.c')
-rw-r--r--src/chsem.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/chsem.c b/src/chsem.c
index 61fff37a1..01ec80649 100644
--- a/src/chsem.c
+++ b/src/chsem.c
@@ -82,33 +82,35 @@ void chSemResetI(Semaphore *sp, t_cnt n) {
/**
* Performs a wait operation on a semaphore.
* @param sp pointer to a \p Semaphore structure
+ * @return the function can return \p RDY_OK or \p RDY_RESET.
*/
-void chSemWait(Semaphore *sp) {
+t_msg chSemWait(Semaphore *sp) {
+ t_msg msg;
chSysLock();
- if (--sp->s_cnt < 0) {
- fifo_insert(currp, &sp->s_queue);
- currp->p_semp = sp;
- chSchGoSleepS(PRWTSEM);
- }
+ msg = chSemWaitS(sp);
chSysUnlock();
+ return msg;
}
/**
* Performs a wait operation on a semaphore.
* @param sp pointer to a \p Semaphore structure
+ * @return the function can return \p RDY_OK or \p RDY_RESET.
* @note This function must be called with interrupts disabled.
* @note This function cannot be called by an interrupt handler.
*/
-void chSemWaitS(Semaphore *sp) {
+t_msg chSemWaitS(Semaphore *sp) {
if (--sp->s_cnt < 0) {
fifo_insert(currp, &sp->s_queue);
currp->p_semp = sp;
chSchGoSleepS(PRWTSEM);
+ return currp->p_rdymsg;
}
+ return RDY_OK;
}
#ifdef CH_USE_SEMAPHORES_TIMEOUT
@@ -126,7 +128,7 @@ static void wakeup(void *p) {
* Performs a wait operation on a semaphore with timeout specification.
* @param sp pointer to a \p Semaphore structure
* @param time the number of ticks before the operation fails
- * @return the function can return \p RDY_OK. \p RDY_TIMEOUT or \p RDY_RESET.
+ * @return the function can return \p RDY_OK, \p RDY_TIMEOUT or \p RDY_RESET.
*/
t_msg chSemWaitTimeout(Semaphore *sp, t_time time) {
t_msg msg;
@@ -143,7 +145,7 @@ t_msg chSemWaitTimeout(Semaphore *sp, t_time time) {
* Performs a wait operation on a semaphore with timeout specification.
* @param sp pointer to a \p Semaphore structure
* @param time the number of ticks before the operation fails
- * @return the function can return \p RDY_OK. \p RDY_TIMEOUT or \p RDY_RESET.
+ * @return the function can return \p RDY_OK, \p RDY_TIMEOUT or \p RDY_RESET.
* @note This function must be called with interrupts disabled.
* @note This function cannot be called by an interrupt handler.
* @note The function is available only if the \p CH_USE_SEMAPHORES_TIMEOUT