You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2023/07/31 14:50:21 UTC
[nuttx] 05/12: sched: inherit parent priority by default
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit b2a9c6a3e563ad4f57b0539b6f99dad3ec2a8c3c
Author: yangyalei <ya...@xiaomi.com>
AuthorDate: Sun Jun 25 14:37:31 2023 +0800
sched: inherit parent priority by default
fix ltp pthread_cond_wait_1 test question, child should inherit parent
priority by default.
nsh> ltp_pthread_cond_wait_1
Error: the policy or priority not correct
Signed-off-by: yangyalei <ya...@xiaomi.com>
---
sched/pthread/pthread_create.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/sched/pthread/pthread_create.c b/sched/pthread/pthread_create.c
index a158af4518..df054c9cd2 100644
--- a/sched/pthread/pthread_create.c
+++ b/sched/pthread/pthread_create.c
@@ -185,14 +185,21 @@ int nx_pthread_create(pthread_trampoline_t trampoline, FAR pthread_t *thread,
pid_t pid;
int ret;
bool group_joined = false;
+ pthread_attr_t default_attr = g_default_pthread_attr;
DEBUGASSERT(trampoline != NULL);
+ parent = this_task();
+ DEBUGASSERT(parent != NULL);
+
/* If attributes were not supplied, use the default attributes */
if (!attr)
{
- attr = &g_default_pthread_attr;
+ /* Inherit parent priority by default */
+
+ default_attr.priority = parent->sched_priority;
+ attr = &default_attr;
}
/* Allocate a TCB for the new task. */
@@ -395,9 +402,6 @@ int nx_pthread_create(pthread_trampoline_t trampoline, FAR pthread_t *thread,
}
#endif
- parent = this_task();
- DEBUGASSERT(parent != NULL);
-
/* Configure the TCB for a pthread receiving on parameter
* passed by value
*/