You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ma...@apache.org on 2020/10/22 07:46:09 UTC
[incubator-nuttx] 01/01: Revert "sched: Call up_[use|create]_stack
after nxtask_setup_scheduler"
This is an automated email from the ASF dual-hosted git repository.
masayuki pushed a commit to branch revert-2000-stack
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 693378267a07e9b4794fb02c04459a49e31389ab
Author: Masayuki Ishikawa <ma...@gmail.com>
AuthorDate: Thu Oct 22 16:45:59 2020 +0900
Revert "sched: Call up_[use|create]_stack after nxtask_setup_scheduler"
This reverts commit 6eba1ad90a3f49fc085e280d5e517a4656689732.
---
sched/pthread/pthread_create.c | 42 +++++++++++++++++++++---------------------
sched/task/task_init.c | 18 +++++++++---------
2 files changed, 30 insertions(+), 30 deletions(-)
diff --git a/sched/pthread/pthread_create.c b/sched/pthread/pthread_create.c
index c531d00..1b836f5 100644
--- a/sched/pthread/pthread_create.c
+++ b/sched/pthread/pthread_create.c
@@ -289,6 +289,27 @@ int pthread_create(FAR pthread_t *thread, FAR const pthread_attr_t *attr,
pjoin->detached = true;
}
+ if (attr->stackaddr)
+ {
+ /* Use pre-allocated stack */
+
+ ret = up_use_stack((FAR struct tcb_s *)ptcb, attr->stackaddr,
+ attr->stacksize);
+ }
+ else
+ {
+ /* Allocate the stack for the TCB */
+
+ ret = up_create_stack((FAR struct tcb_s *)ptcb, attr->stacksize,
+ TCB_FLAG_TTYPE_PTHREAD);
+ }
+
+ if (ret != OK)
+ {
+ errcode = ENOMEM;
+ goto errout_with_join;
+ }
+
/* Should we use the priority and scheduler specified in the pthread
* attributes? Or should we use the current thread's priority and
* scheduler?
@@ -410,27 +431,6 @@ int pthread_create(FAR pthread_t *thread, FAR const pthread_attr_t *attr,
}
#endif
- if (attr->stackaddr)
- {
- /* Use pre-allocated stack */
-
- ret = up_use_stack((FAR struct tcb_s *)ptcb, attr->stackaddr,
- attr->stacksize);
- }
- else
- {
- /* Allocate the stack for the TCB */
-
- ret = up_create_stack((FAR struct tcb_s *)ptcb, attr->stacksize,
- TCB_FLAG_TTYPE_PTHREAD);
- }
-
- if (ret != OK)
- {
- errcode = ENOMEM;
- goto errout_with_join;
- }
-
/* Configure the TCB for a pthread receiving on parameter
* passed by value
*/
diff --git a/sched/task/task_init.c b/sched/task/task_init.c
index 7d9904a..b187b74 100644
--- a/sched/task/task_init.c
+++ b/sched/task/task_init.c
@@ -108,15 +108,6 @@ int nxtask_init(FAR struct task_tcb_s *tcb, const char *name, int priority,
goto errout_with_group;
}
- /* Initialize the task control block */
-
- ret = nxtask_setup_scheduler(tcb, priority, nxtask_start,
- entry, ttype);
- if (ret < OK)
- {
- goto errout_with_group;
- }
-
if (stack)
{
/* Use pre-allocated stack */
@@ -135,6 +126,15 @@ int nxtask_init(FAR struct task_tcb_s *tcb, const char *name, int priority,
goto errout_with_group;
}
+ /* Initialize the task control block */
+
+ ret = nxtask_setup_scheduler(tcb, priority, nxtask_start,
+ entry, ttype);
+ if (ret < OK)
+ {
+ goto errout_with_group;
+ }
+
/* Setup to pass parameters to the new task */
nxtask_setup_arguments(tcb, name, argv);