[PATCH 2/4] posix: Provide get thread attributes by default

Sebastian Huber sebastian.huber at embedded-brains.de
Wed Oct 24 06:10:05 UTC 2018


Update #2514.
---
 cpukit/Makefile.am                           | 6 +++---
 cpukit/include/rtems/posix/pthreadattrimpl.h | 8 ++++++--
 cpukit/posix/src/psxtransschedparam.c        | 4 ++++
 3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/cpukit/Makefile.am b/cpukit/Makefile.am
index 8d68c622a1..78db4b2e0d 100644
--- a/cpukit/Makefile.am
+++ b/cpukit/Makefile.am
@@ -544,6 +544,7 @@ librtemscpu_a_SOURCES += posix/src/pspininit.c
 librtemscpu_a_SOURCES += posix/src/pspinlock.c
 librtemscpu_a_SOURCES += posix/src/pspinunlock.c
 librtemscpu_a_SOURCES += posix/src/psxpriorityisvalid.c
+librtemscpu_a_SOURCES += posix/src/psxtransschedparam.c
 librtemscpu_a_SOURCES += posix/src/pthreadattrdefault.c
 librtemscpu_a_SOURCES += posix/src/pthreadattrdestroy.c
 librtemscpu_a_SOURCES += posix/src/pthreadattrgetaffinitynp.c
@@ -568,7 +569,9 @@ librtemscpu_a_SOURCES += posix/src/pthreadattrsetstackaddr.c
 librtemscpu_a_SOURCES += posix/src/pthreadattrsetstack.c
 librtemscpu_a_SOURCES += posix/src/pthreadattrsetstacksize.c
 librtemscpu_a_SOURCES += posix/src/pthreadgetaffinitynp.c
+librtemscpu_a_SOURCES += posix/src/pthreadgetattrnp.c
 librtemscpu_a_SOURCES += posix/src/pthreadgetnamenp.c
+librtemscpu_a_SOURCES += posix/src/pthreadgetschedparam.c
 librtemscpu_a_SOURCES += posix/src/pthreadonce.c
 librtemscpu_a_SOURCES += posix/src/pthreadsetaffinitynp.c
 librtemscpu_a_SOURCES += posix/src/pthreadsetnamenp.c
@@ -1045,7 +1048,6 @@ librtemscpu_a_SOURCES += posix/src/psxpriorityisvalid.c
 librtemscpu_a_SOURCES += posix/src/psxsemaphore.c
 librtemscpu_a_SOURCES += posix/src/psxtimercreate.c
 librtemscpu_a_SOURCES += posix/src/psxtimerdelete.c
-librtemscpu_a_SOURCES += posix/src/psxtransschedparam.c
 librtemscpu_a_SOURCES += posix/src/pthreadatfork.c
 librtemscpu_a_SOURCES += posix/src/pthread.c
 librtemscpu_a_SOURCES += posix/src/pthreadconcurrency.c
@@ -1053,9 +1055,7 @@ librtemscpu_a_SOURCES += posix/src/pthreadcreate.c
 librtemscpu_a_SOURCES += posix/src/pthreaddetach.c
 librtemscpu_a_SOURCES += posix/src/pthreadequal.c
 librtemscpu_a_SOURCES += posix/src/pthreadexit.c
-librtemscpu_a_SOURCES += posix/src/pthreadgetattrnp.c
 librtemscpu_a_SOURCES += posix/src/pthreadgetcpuclockid.c
-librtemscpu_a_SOURCES += posix/src/pthreadgetschedparam.c
 librtemscpu_a_SOURCES += posix/src/pthreadinitthreads.c
 librtemscpu_a_SOURCES += posix/src/pthreadjoin.c
 librtemscpu_a_SOURCES += posix/src/pthreadkill.c
diff --git a/cpukit/include/rtems/posix/pthreadattrimpl.h b/cpukit/include/rtems/posix/pthreadattrimpl.h
index 12b8559181..cd4b3528a2 100644
--- a/cpukit/include/rtems/posix/pthreadattrimpl.h
+++ b/cpukit/include/rtems/posix/pthreadattrimpl.h
@@ -65,13 +65,13 @@ RTEMS_INLINE_ROUTINE void _POSIX_Threads_Initialize_attributes(
   );
 }
 
-#if defined(RTEMS_POSIX_API)
 RTEMS_INLINE_ROUTINE void _POSIX_Threads_Get_sched_param_sporadic(
   const Thread_Control    *the_thread,
   const Scheduler_Control *scheduler,
   struct sched_param      *param
 )
 {
+#if defined(RTEMS_POSIX_API)
   const POSIX_API_Control *api;
 
   api = the_thread->API_Extensions[ THREAD_API_POSIX ];
@@ -82,8 +82,12 @@ RTEMS_INLINE_ROUTINE void _POSIX_Threads_Get_sched_param_sporadic(
   param->sched_ss_repl_period = api->Sporadic.sched_ss_repl_period;
   param->sched_ss_init_budget = api->Sporadic.sched_ss_init_budget;
   param->sched_ss_max_repl = api->Sporadic.sched_ss_max_repl;
-}
+#else
+  (void) the_thread;
+  (void) scheduler;
+  (void) param;
 #endif
+}
 
 /** @} */
 
diff --git a/cpukit/posix/src/psxtransschedparam.c b/cpukit/posix/src/psxtransschedparam.c
index 0b4ce2823e..614c5fb71f 100644
--- a/cpukit/posix/src/psxtransschedparam.c
+++ b/cpukit/posix/src/psxtransschedparam.c
@@ -30,8 +30,10 @@ int _POSIX_Thread_Translate_to_sched_policy(
   switch ( budget_algorithm ) {
     case THREAD_CPU_BUDGET_ALGORITHM_RESET_TIMESLICE:
       return SCHED_OTHER;
+#if defined(RTEMS_POSIX_API)
     case THREAD_CPU_BUDGET_ALGORITHM_EXHAUST_TIMESLICE:
       return SCHED_RR;
+#endif
     case THREAD_CPU_BUDGET_ALGORITHM_CALLOUT:
       return SCHED_SPORADIC;
     default:
@@ -60,10 +62,12 @@ int _POSIX_Thread_Translate_sched_param(
     return 0;
   }
 
+#if defined(RTEMS_POSIX_API)
   if ( policy == SCHED_RR ) {
     *budget_algorithm = THREAD_CPU_BUDGET_ALGORITHM_EXHAUST_TIMESLICE;
     return 0;
   }
+#endif
 
   if ( policy == SCHED_SPORADIC ) {
     if ( (param->sched_ss_repl_period.tv_sec == 0) &&
-- 
2.16.4




More information about the devel mailing list