summaryrefslogtreecommitdiff
path: root/nuttx/sched/sem_waitirq.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-07-20 13:19:07 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-07-20 13:19:07 +0000
commit610a6c9a4d50657d5f04d3247a229795e599be3b (patch)
treee03560a19826bb362dfe3b21743ff232b940e272 /nuttx/sched/sem_waitirq.c
parent622a6cc576f1e5b97abcb78441ed04674217bfe6 (diff)
downloadpx4-nuttx-610a6c9a4d50657d5f04d3247a229795e599be3b.tar.gz
px4-nuttx-610a6c9a4d50657d5f04d3247a229795e599be3b.tar.bz2
px4-nuttx-610a6c9a4d50657d5f04d3247a229795e599be3b.zip
Fix for sem_timedwait.c
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3803 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/sched/sem_waitirq.c')
-rw-r--r--nuttx/sched/sem_waitirq.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/nuttx/sched/sem_waitirq.c b/nuttx/sched/sem_waitirq.c
index 317a37a06..409cf780a 100644
--- a/nuttx/sched/sem_waitirq.c
+++ b/nuttx/sched/sem_waitirq.c
@@ -73,15 +73,16 @@
* Function: sem_waitirq
*
* Description:
- * This function is called when a signal is received by a
- * task that is waiting on a semaphore. According to the
- * POSIX spec, "...the calling thread shall not return
- * from the call to [sem_wait] until it either locks the
- * semaphore or the call is interrupted by a signal."
+ * This function is called when a signal is received by a task that is
+ * waiting on a semaphore. According to the POSIX spec, "...the calling
+ * thread shall not return from the call to [sem_wait] until it either
+ * locks the semaphore or the call is interrupted by a signal."
*
* Parameters:
- * wtcb - A pointer to the TCB of the task that is waiting
- * on a semphare, but has received a signal instead.
+ * wtcb - A pointer to the TCB of the task that is waiting on a
+ * semphaphore, but has received a signal or timeout instead.
+ * errcode - EINTR if the semaphore wait was awakened by a signal;
+ * ETIMEDOUT if awakened by a timeout
*
* Return Value:
* None
@@ -90,7 +91,7 @@
*
****************************************************************************/
-void sem_waitirq(FAR _TCB *wtcb)
+void sem_waitirq(FAR _TCB *wtcb, int errcode)
{
irqstate_t saved_state;
@@ -101,8 +102,8 @@ void sem_waitirq(FAR _TCB *wtcb)
saved_state = irqsave();
- /* It is possible that an interrupt/context switch beat us to the
- * punch and already changed the task's state.
+ /* It is possible that an interrupt/context switch beat us to the punch
+ * and already changed the task's state.
*/
if (wtcb->task_state == TSTATE_WAIT_SEM)
@@ -116,10 +117,10 @@ void sem_waitirq(FAR _TCB *wtcb)
sem_canceled(wtcb, sem);
- /* And increment the count on the semaphore. This releases the
- * count that was taken by sem_post(). This count decremented
- * the semaphore count to negative and caused the thread to be
- * blocked in the first place.
+ /* And increment the count on the semaphore. This releases the count
+ * that was taken by sem_post(). This count decremented the semaphore
+ * count to negative and caused the thread to be blocked in the first
+ * place.
*/
sem->semcount++;
@@ -130,7 +131,7 @@ void sem_waitirq(FAR _TCB *wtcb)
/* Mark the errno value for the thread. */
- wtcb->pterrno = EINTR;
+ wtcb->pterrno = errcode;
/* Restart the task. */