From 0d1e492702bd8c95e68d6e18aa50195e206164ba Mon Sep 17 00:00:00 2001 From: Gaetan Perrot Date: Fri, 29 Mar 2024 22:52:30 +0900 Subject: [PATCH] fixup! posix: Implement set and get inheritsched APIs for pthread attr --- lib/posix/options/pthread.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/lib/posix/options/pthread.c b/lib/posix/options/pthread.c index 5d3c69d03bc8be3..e7fe47fb030ded6 100644 --- a/lib/posix/options/pthread.c +++ b/lib/posix/options/pthread.c @@ -638,18 +638,13 @@ int pthread_create(pthread_t *th, const pthread_attr_t *_attr, void *(*threadrou t->attr = *(struct posix_thread_attr *)_attr; } - struct posix_thread *self = NULL; + if (t->attr.inheritsched == PTHREAD_INHERIT_SCHED) { + int pol; - K_SPINLOCK(&pthread_pool_lock) { - self = to_posix_thread(pthread_self()); - if (self == NULL) { -- K_SPINLOCK_BREAK; - } - if (self->attr.inheritsched == PTHREAD_INHERIT_SCHED) { - t->attr.priority = self->attr.priority; - t->attr.schedpolicy = self->attr.schedpolicy; - t->attr.inheritsched = self->attr.inheritsched; - } + t->attr.priority = + zephyr_to_posix_priority(k_thread_priority_get(k_current_get()), &pol); + t->attr.schedpolicy = pol; + } /* spawn the thread */ k_thread_create(