summaryrefslogtreecommitdiff
path: root/nuttx/sched/pthread_condtimedwait.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-02-06 15:43:28 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-02-06 15:43:28 +0000
commitf7b7532a4114b831f5ef66ed992d28e65fb3973f (patch)
tree929ad375fc60be5b08f35b49ff681db96d97b842 /nuttx/sched/pthread_condtimedwait.c
parentd8a1b61690862777b137ec182a0d62dcf4ee8db2 (diff)
downloadpx4-nuttx-f7b7532a4114b831f5ef66ed992d28e65fb3973f.tar.gz
px4-nuttx-f7b7532a4114b831f5ef66ed992d28e65fb3973f.tar.bz2
px4-nuttx-f7b7532a4114b831f5ef66ed992d28e65fb3973f.zip
Changed needed to fix issues with task_restart()
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5615 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/sched/pthread_condtimedwait.c')
-rw-r--r--nuttx/sched/pthread_condtimedwait.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/nuttx/sched/pthread_condtimedwait.c b/nuttx/sched/pthread_condtimedwait.c
index 3914f40ff..37534dacf 100644
--- a/nuttx/sched/pthread_condtimedwait.c
+++ b/nuttx/sched/pthread_condtimedwait.c
@@ -1,7 +1,7 @@
/****************************************************************************
* sched/pthread_condtimedwait.c
*
- * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007-2009, 2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -46,6 +46,7 @@
#include <signal.h>
#include <time.h>
#include <errno.h>
+#include <assert.h>
#include <wdog.h>
#include <debug.h>
@@ -179,15 +180,17 @@ static void pthread_condtimedout(int argc, uint32_t pid, uint32_t signo)
int pthread_cond_timedwait(FAR pthread_cond_t *cond, FAR pthread_mutex_t *mutex,
FAR const struct timespec *abstime)
{
- WDOG_ID wdog;
- int ticks;
- int mypid = (int)getpid();
- irqstate_t int_state;
- int ret = OK;
- int status;
+ FAR struct tcb_s *rtcb = (FAR struct tcb_s *)g_readytorun.head;
+ int ticks;
+ int mypid = (int)getpid();
+ irqstate_t int_state;
+ int ret = OK;
+ int status;
sdbg("cond=0x%p mutex=0x%p abstime=0x%p\n", cond, mutex, abstime);
+ DEBUGASSERT(rtcb->waitdog == NULL);
+
/* Make sure that non-NULL references were provided. */
if (!cond || !mutex)
@@ -215,8 +218,8 @@ int pthread_cond_timedwait(FAR pthread_cond_t *cond, FAR pthread_mutex_t *mutex,
{
/* Create a watchdog */
- wdog = wd_create();
- if (!wdog)
+ rtcb->waitdog = wd_create();
+ if (!rtcb->waitdog)
{
ret = EINVAL;
}
@@ -280,7 +283,7 @@ int pthread_cond_timedwait(FAR pthread_cond_t *cond, FAR pthread_mutex_t *mutex,
{
/* Start the watchdog */
- wd_start(wdog, ticks, (wdentry_t)pthread_condtimedout,
+ wd_start(rtcb->waitdog, ticks, (wdentry_t)pthread_condtimedout,
2, (uint32_t)mypid, (uint32_t)SIGCONDTIMEDOUT);
/* Take the condition semaphore. Do not restore interrupts
@@ -343,7 +346,8 @@ int pthread_cond_timedwait(FAR pthread_cond_t *cond, FAR pthread_mutex_t *mutex,
/* We no longer need the watchdog */
- wd_delete(wdog);
+ wd_delete(rtcb->waitdog);
+ rtcb->waitdog = NULL;
}
}