summaryrefslogtreecommitdiff
path: root/nuttx/sched/group
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-09-03 14:58:24 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-09-03 14:58:24 -0600
commitc6e48b65d0729bc4fffbf57dac4fb8c97a35fd63 (patch)
tree8704f2481d566dd90cc40d89e8753381d4589521 /nuttx/sched/group
parentffa0635358e2080f6608ec41e172e4ba0873f91a (diff)
downloadpx4-nuttx-c6e48b65d0729bc4fffbf57dac4fb8c97a35fd63.tar.gz
px4-nuttx-c6e48b65d0729bc4fffbf57dac4fb8c97a35fd63.tar.bz2
px4-nuttx-c6e48b65d0729bc4fffbf57dac4fb8c97a35fd63.zip
Fix more places where the user-mode allocator is used to allocate kernel thread resources -- before the user-mode allocator even exists
Diffstat (limited to 'nuttx/sched/group')
-rw-r--r--nuttx/sched/group/group.h21
-rw-r--r--nuttx/sched/group/group_create.c9
-rw-r--r--nuttx/sched/group/group_free.c4
-rw-r--r--nuttx/sched/group/group_malloc.c8
4 files changed, 16 insertions, 26 deletions
diff --git a/nuttx/sched/group/group.h b/nuttx/sched/group/group.h
index 4f74d4156..2dc74e709 100644
--- a/nuttx/sched/group/group.h
+++ b/nuttx/sched/group/group.h
@@ -95,7 +95,7 @@ void weak_function task_initialize(void);
/* Task group data structure management */
#ifdef HAVE_TASK_GROUP
-int group_allocate(FAR struct task_tcb_s *tcb);
+int group_allocate(FAR struct task_tcb_s *tcb, uint8_t ttype);
int group_initialize(FAR struct task_tcb_s *tcb);
#ifndef CONFIG_DISABLE_PTHREAD
int group_bind(FAR struct pthread_tcb_s *tcb);
@@ -114,25 +114,6 @@ int group_foreachchild(FAR struct task_group_s *group,
int group_killchildren(FAR struct task_tcb_s *tcb);
#endif
-/* Group memory management */
-
-#if (defined(CONFIG_BUILD_PROTECTED) || defined(CONFIG_BUILD_KERNEL)) && \
- defined(CONFIG_MM_KERNEL_HEAP)
- /* Functions to pick the correct allocator based on group privileges */
-
-FAR void *group_malloc(FAR struct task_group_s *group, size_t nbytes);
-FAR void *group_zalloc(FAR struct task_group_s *group, size_t nbytes);
-void group_free(FAR struct task_group_s *group, FAR void *mem);
-
-#else
- /* There is only one allocator */
-
-# define group_malloc(g,n) kumm_malloc(size)
-# define group_zalloc(g,n) kumm_zalloc(size)
-# define group_free(g,m) kumm_free(size)
-
-#endif
-
#ifdef CONFIG_ARCH_ADDRENV
/* Group address environment management */
diff --git a/nuttx/sched/group/group_create.c b/nuttx/sched/group/group_create.c
index fce7beee8..7d84e3e20 100644
--- a/nuttx/sched/group/group_create.c
+++ b/nuttx/sched/group/group_create.c
@@ -46,8 +46,8 @@
#include <nuttx/kmalloc.h>
-#include "group/group.h"
#include "environ/environ.h"
+#include "group/group.h"
#ifdef HAVE_TASK_GROUP
@@ -164,7 +164,8 @@ static void group_assigngid(FAR struct task_group_s *group)
* group membership.
*
* Parameters:
- * tcb - The tcb in need of the task group.
+ * tcb - The tcb in need of the task group.
+ * ttype - Type of the thread that is the parent of the group
*
* Return Value:
* 0 (OK) on success; a negated errno value on failure.
@@ -175,7 +176,7 @@ static void group_assigngid(FAR struct task_group_s *group)
*
*****************************************************************************/
-int group_allocate(FAR struct task_tcb_s *tcb)
+int group_allocate(FAR struct task_tcb_s *tcb, uint8_t ttype)
{
FAR struct task_group_s *group;
int ret;
@@ -196,7 +197,7 @@ int group_allocate(FAR struct task_tcb_s *tcb)
* of the group must be created for privileged access.
*/
- if ((tcb->cmn.flags & TCB_FLAG_TTYPE_MASK) == TCB_FLAG_TTYPE_KERNEL)
+ if ((ttype & TCB_FLAG_TTYPE_MASK) == TCB_FLAG_TTYPE_KERNEL)
{
group->tg_flags |= GROUP_FLAG_PRIVILEGED;
}
diff --git a/nuttx/sched/group/group_free.c b/nuttx/sched/group/group_free.c
index f71bebdcc..631482e06 100644
--- a/nuttx/sched/group/group_free.c
+++ b/nuttx/sched/group/group_free.c
@@ -39,6 +39,8 @@
#include <sys/types.h>
+#include <assert.h>
+
#include <nuttx/sched.h>
#include <nuttx/kmalloc.h>
@@ -82,6 +84,8 @@
void group_free(FAR struct task_group_s *group, FAR void *mem)
{
+ DEBUGASSERT(group && mem);
+
/* Check the group is privileged */
if ((group->tg_flags & GROUP_FLAG_PRIVILEGED) != 0)
diff --git a/nuttx/sched/group/group_malloc.c b/nuttx/sched/group/group_malloc.c
index d00b5c2c0..3ca23a5b6 100644
--- a/nuttx/sched/group/group_malloc.c
+++ b/nuttx/sched/group/group_malloc.c
@@ -39,6 +39,8 @@
#include <sys/types.h>
+#include <assert.h>
+
#include <nuttx/sched.h>
#include <nuttx/kmalloc.h>
@@ -76,8 +78,8 @@
*
* Description:
* Allocate memory appropriate for the group type. If the memory is
- * part of a privileged, then it should be allocated so that it is
- * only accessed by privileged code; Otherwise, it is a user mode
+ * part of a privileged group, then it should be allocated so that it
+ * is only accessible by privileged code; Otherwise, it is a user mode
* group and must be allocated so that it accessible by unprivileged
* code.
*
@@ -85,6 +87,8 @@
FAR void *group_malloc(FAR struct task_group_s *group, size_t nbytes)
{
+ DEBUGASSERT(group);
+
/* Check the group type */
if ((group->tg_flags & GROUP_FLAG_PRIVILEGED) != 0)