summaryrefslogtreecommitdiff
path: root/nuttx/sched
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-03-16 17:37:40 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-03-16 17:37:40 +0000
commita45f710f8fdb5b9cf11fbdcb2a74cb5007ea79fd (patch)
tree8e50d03ca5238eb88b8cc8125f8db19ba72436a9 /nuttx/sched
parentd980ce2cdc1816e4d5df9a1c2ff9e647c6cb7540 (diff)
downloadpx4-nuttx-a45f710f8fdb5b9cf11fbdcb2a74cb5007ea79fd.tar.gz
px4-nuttx-a45f710f8fdb5b9cf11fbdcb2a74cb5007ea79fd.tar.bz2
px4-nuttx-a45f710f8fdb5b9cf11fbdcb2a74cb5007ea79fd.zip
Fix bad conditional logic in mkconfig.c; Add user-mode pthread start-up logic
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5748 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/sched')
-rw-r--r--nuttx/sched/pthread_create.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/nuttx/sched/pthread_create.c b/nuttx/sched/pthread_create.c
index 3fcb7eea1..09f98220b 100644
--- a/nuttx/sched/pthread_create.c
+++ b/nuttx/sched/pthread_create.c
@@ -185,11 +185,19 @@ static void pthread_start(void)
pjoin->started = true;
(void)pthread_givesemaphore(&pjoin->data_sem);
- /* Pass control to the thread entry point. */
+ /* Pass control to the thread entry point. In the kernel build this has to
+ * be handled differently if we are starting a user-space pthread; we have
+ * to switch to user-mode before calling into the pthread.
+ */
+#ifdef CONFIG_NUTTX_KERNEL
+ up_pthread_start(ptcb->cmn.entry.pthread, ptcb->arg);
+ exit_status = NULL;
+#else
exit_status = (*ptcb->cmn.entry.pthread)(ptcb->arg);
+#endif
- /* The thread has returned */
+ /* The thread has returned (should never happen in the kernel mode case) */
pthread_exit(exit_status);
}