From 610a6c9a4d50657d5f04d3247a229795e599be3b Mon Sep 17 00:00:00 2001 From: patacongo Date: Wed, 20 Jul 2011 13:19:07 +0000 Subject: Fix for sem_timedwait.c git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3803 42af7a65-404d-4744-a932-0658087f49c3 --- nuttx/sched/sem_waitirq.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'nuttx/sched/sem_waitirq.c') 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. */ -- cgit v1.2.3