summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-09-11 09:00:10 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-09-11 09:00:10 -0600
commitea18135ad3478be6d774bb74d00713d3b7d86cd1 (patch)
treecb0871a917da554e0c551bd8bd35fd6f23b54903
parent43108346e9ef40deb13ff1c5a817aa4764ab5891 (diff)
downloadpx4-nuttx-ea18135ad3478be6d774bb74d00713d3b7d86cd1.tar.gz
px4-nuttx-ea18135ad3478be6d774bb74d00713d3b7d86cd1.tar.bz2
px4-nuttx-ea18135ad3478be6d774bb74d00713d3b7d86cd1.zip
When a privileged thread exits, we have to use the kernel alloctor to free memory; when an unprivileged thread exits, we don't have to do anything... heap memory will be cleaned up when the address environment is torn down
-rwxr-xr-xnuttx/configs/ea3131/locked/mklocked.sh1
-rw-r--r--nuttx/include/nuttx/lib.h5
-rw-r--r--nuttx/libc/misc/lib_stream.c29
-rw-r--r--nuttx/sched/init/os_start.c11
4 files changed, 23 insertions, 23 deletions
diff --git a/nuttx/configs/ea3131/locked/mklocked.sh b/nuttx/configs/ea3131/locked/mklocked.sh
index c8c3f9a76..26d23e40e 100755
--- a/nuttx/configs/ea3131/locked/mklocked.sh
+++ b/nuttx/configs/ea3131/locked/mklocked.sh
@@ -194,7 +194,6 @@ if [ $answer = y ]; then
fi
echo "EXTERN(up_initialize)" >>ld-locked.inc
-echo "EXTERN(lib_initialize)" >>ld-locked.inc
echo "EXTERN(sched_setupidlefiles)" >>ld-locked.inc
echo "EXTERN(task_create)" >>ld-locked.inc
diff --git a/nuttx/include/nuttx/lib.h b/nuttx/include/nuttx/lib.h
index 5b151ed9e..a5d289858 100644
--- a/nuttx/include/nuttx/lib.h
+++ b/nuttx/include/nuttx/lib.h
@@ -65,10 +65,11 @@ extern "C"
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
+/* Hook for library initialization. No is needed now, however */
-/* Functions contained in lib_init.c ****************************************/
+#define lib_initialize()
-void weak_function lib_initialize(void);
+/* Functions contained in lib_streams.c *************************************/
#if CONFIG_NFILE_STREAMS > 0
struct task_group_s;
diff --git a/nuttx/libc/misc/lib_stream.c b/nuttx/libc/misc/lib_stream.c
index 5b42f0c01..f15215723 100644
--- a/nuttx/libc/misc/lib_stream.c
+++ b/nuttx/libc/misc/lib_stream.c
@@ -70,18 +70,6 @@
****************************************************************************/
/****************************************************************************
- * Name: lib_initialize
- *
- * Description:
- * General library initialization hook
- *
- ****************************************************************************/
-
-void weak_const_function lib_initialize(void)
-{
-}
-
-/****************************************************************************
* Name: lib_stream_initialize
*
* Description:
@@ -174,7 +162,24 @@ void lib_stream_release(FAR struct task_group_s *group)
if (list->sl_streams[i].fs_bufstart)
{
+#ifndef CONFIG_ARCH_ADDRENV
+ /* Release memory from the user heap */
+
sched_ufree(list->sl_streams[i].fs_bufstart);
+#else
+ /* If the exiting group is unprivileged, then it has an address
+ * environment. Don't bother to release the memory in this case...
+ * There is no point sense the memory lies in the user heap which
+ * will be destroyed anyway. But if this is a privileged group,
+ * when we still have to release the memory using the kernel
+ * allocator.
+ */
+
+ if ((group->tg_flags & GROUP_FLAG_PRIVILEGED) != 0)
+ {
+ sched_ufree(list->sl_streams[i].fs_bufstart);
+ }
+#endif
}
}
#endif
diff --git a/nuttx/sched/init/os_start.c b/nuttx/sched/init/os_start.c
index 05278111a..62f150c92 100644
--- a/nuttx/sched/init/os_start.c
+++ b/nuttx/sched/init/os_start.c
@@ -485,16 +485,11 @@ void os_start(void)
up_initialize();
- /* Initialize the C libraries (if included in the link). This
- * is done last because the libraries may depend on the above.
+ /* Initialize the C libraries. This is done last because the libraries
+ * may depend on the above.
*/
-#ifdef CONFIG_HAVE_WEAKFUNCTIONS
- if (lib_initialize != NULL)
-#endif
- {
- lib_initialize();
- }
+ lib_initialize();
/* IDLE Group Initialization **********************************************/
#ifdef HAVE_TASK_GROUP