summaryrefslogtreecommitdiff
path: root/nuttx/sched
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2013-05-09 14:23:34 -0600
committerGregory Nutt <gnutt@nuttx.org>2013-05-09 14:23:34 -0600
commit17cfb7007f3f4e253d3533ee87349ce1b8e4885e (patch)
treefb175af19fa6835f8929ee075ff16acfeb49f904 /nuttx/sched
parent4495dfb36135744a6f903e32ac2215b1f3ab0452 (diff)
downloadpx4-nuttx-17cfb7007f3f4e253d3533ee87349ce1b8e4885e.tar.gz
px4-nuttx-17cfb7007f3f4e253d3533ee87349ce1b8e4885e.tar.bz2
px4-nuttx-17cfb7007f3f4e253d3533ee87349ce1b8e4885e.zip
Various changes and bigfixes for problems detected by CppCheck
Diffstat (limited to 'nuttx/sched')
-rw-r--r--nuttx/sched/task_spawn.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/nuttx/sched/task_spawn.c b/nuttx/sched/task_spawn.c
index 2456d777c..70f20e0b4 100644
--- a/nuttx/sched/task_spawn.c
+++ b/nuttx/sched/task_spawn.c
@@ -111,6 +111,8 @@ static int task_spawn_exec(FAR pid_t *pidp, FAR const char *name,
main_t entry, FAR const posix_spawnattr_t *attr,
FAR char * const *argv)
{
+ size_t stacksize;
+ int priority;
int pid;
int ret = OK;
@@ -121,9 +123,32 @@ static int task_spawn_exec(FAR pid_t *pidp, FAR const char *name,
sched_lock();
+ /* Use the default task priority and stack size if no attributes are provided */
+
+ if (attr)
+ {
+ priority = attr->priority;
+ stacksize = attr->stacksize;
+ }
+ else
+ {
+ struct sched_param param;
+
+ /* Set the default priority to the same priority as this task */
+
+ ret = sched_getparam(0, &param);
+ if (ret < 0)
+ {
+ goto errout;
+ }
+
+ priority = param.sched_priority;
+ stacksize = CONFIG_TASK_SPAWN_DEFAULT_STACKSIZE;
+ }
+
/* Start the task */
- pid = TASK_CREATE(name, attr->priority, attr->stacksize, entry, argv);
+ pid = TASK_CREATE(name, priority, stacksize, entry, argv);
if (pid < 0)
{
ret = errno;