[PATCH] posix: Get real priority in pthread_getattr_np()
Heinz Junkes
junkes at fhi-berlin.mpg.de
Wed May 13 15:10:15 UTC 2020
Thanks for the good ideas.
I have now replaced the accesses to the internal thread structure (real_priority, current_priority) with API - calls.
One of the calls is from the pthread-library and therefore needs --enable-posix when creating the BSP.
Calls used
pthread_getschedparam
rtems_task_set_priority
Heinz
> On 12. May 2020, at 07:28, Sebastian Huber <sebastian.huber at embedded-brains.de> wrote:
>
> This is in line with pthread_setschedparam() and
> pthread_getschedparam().
>
> Update #2514.
> ---
> cpukit/posix/src/pthreadgetattrnp.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/cpukit/posix/src/pthreadgetattrnp.c b/cpukit/posix/src/pthreadgetattrnp.c
> index a449ad48eb..eae29d1de7 100644
> --- a/cpukit/posix/src/pthreadgetattrnp.c
> +++ b/cpukit/posix/src/pthreadgetattrnp.c
> @@ -40,6 +40,7 @@ int pthread_getattr_np(
> ISR_lock_Context lock_context;
> Thread_CPU_budget_algorithms budget_algorithm;
> const Scheduler_Control *scheduler;
> + Priority_Control priority;
> bool ok;
>
> if ( attr == NULL ) {
> @@ -66,15 +67,12 @@ int pthread_getattr_np(
> }
>
> scheduler = _Thread_Scheduler_get_home( the_thread );
> - attr->schedparam.sched_priority = _POSIX_Priority_From_core(
> - scheduler,
> - _Thread_Get_priority( the_thread )
> - );
> _POSIX_Threads_Get_sched_param_sporadic(
> the_thread,
> scheduler,
> &attr->schedparam
> );
> + priority = the_thread->Real_priority.priority;
>
> if ( _Thread_Is_joinable( the_thread ) ) {
> attr->detachstate = PTHREAD_CREATE_JOINABLE;
> @@ -97,6 +95,10 @@ int pthread_getattr_np(
> attr->is_initialized = true;
> attr->contentionscope = PTHREAD_SCOPE_PROCESS;
> attr->cputime_clock_allowed = 1;
> + attr->schedparam.sched_priority = _POSIX_Priority_From_core(
> + scheduler,
> + priority
> + );
> attr->schedpolicy =
> _POSIX_Thread_Translate_to_sched_policy( budget_algorithm );
>
> --
> 2.26.1
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2542 bytes
Desc: not available
URL: <http://lists.rtems.org/pipermail/devel/attachments/20200513/189bf7ed/attachment.bin>
More information about the devel
mailing list