summaryrefslogtreecommitdiff
path: root/nuttx/arch/z16/src/common/up_usestack.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-03-20 20:27:08 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-03-20 20:27:08 +0000
commitae6758d5518a0e92f10476592dc156af38f36244 (patch)
treef7e4cbe989ad3df45b6e062b8457e45c81556350 /nuttx/arch/z16/src/common/up_usestack.c
parentfce497aecaf6826d6fec3cfcb761abeac7fe72bf (diff)
downloadpx4-nuttx-ae6758d5518a0e92f10476592dc156af38f36244.tar.gz
px4-nuttx-ae6758d5518a0e92f10476592dc156af38f36244.tar.bz2
px4-nuttx-ae6758d5518a0e92f10476592dc156af38f36244.zip
In the kernel build, allocate the stacks for kernel threads from the kernel heap so that they are protected from medddling by the applications
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5766 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/arch/z16/src/common/up_usestack.c')
-rw-r--r--nuttx/arch/z16/src/common/up_usestack.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/nuttx/arch/z16/src/common/up_usestack.c b/nuttx/arch/z16/src/common/up_usestack.c
index 6396ce9c2..7b5effc45 100644
--- a/nuttx/arch/z16/src/common/up_usestack.c
+++ b/nuttx/arch/z16/src/common/up_usestack.c
@@ -1,7 +1,7 @@
/****************************************************************************
* arch/z16/common/up_usestack.c
*
- * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2008-2009, 2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -94,12 +94,16 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size)
size_t top_of_stack;
size_t size_of_stack;
+ /* Is there already a stack allocated? */
+
if (tcb->stack_alloc_ptr)
{
- sched_ufree(tcb->stack_alloc_ptr);
+ /* Yes.. Release the old stack allocation */
+
+ up_release_stack(tcb, tcb->flags & TCB_FLAG_TTYPE_MASK);
}
- /* Save the stack allocation */
+ /* Save the new stack allocation */
tcb->stack_alloc_ptr = stack;