posix: Provide get thread attributes by default

Update #2514.
This commit is contained in:
Sebastian Huber
2018-10-24 07:40:23 +02:00
parent 522d4b9186
commit c1ce9a20f3
3 changed files with 13 additions and 5 deletions

View File

@@ -544,6 +544,7 @@ librtemscpu_a_SOURCES += posix/src/pspininit.c
librtemscpu_a_SOURCES += posix/src/pspinlock.c librtemscpu_a_SOURCES += posix/src/pspinlock.c
librtemscpu_a_SOURCES += posix/src/pspinunlock.c librtemscpu_a_SOURCES += posix/src/pspinunlock.c
librtemscpu_a_SOURCES += posix/src/psxpriorityisvalid.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/pthreadattrdefault.c
librtemscpu_a_SOURCES += posix/src/pthreadattrdestroy.c librtemscpu_a_SOURCES += posix/src/pthreadattrdestroy.c
librtemscpu_a_SOURCES += posix/src/pthreadattrgetaffinitynp.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/pthreadattrsetstack.c
librtemscpu_a_SOURCES += posix/src/pthreadattrsetstacksize.c librtemscpu_a_SOURCES += posix/src/pthreadattrsetstacksize.c
librtemscpu_a_SOURCES += posix/src/pthreadgetaffinitynp.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/pthreadgetnamenp.c
librtemscpu_a_SOURCES += posix/src/pthreadgetschedparam.c
librtemscpu_a_SOURCES += posix/src/pthreadonce.c librtemscpu_a_SOURCES += posix/src/pthreadonce.c
librtemscpu_a_SOURCES += posix/src/pthreadsetaffinitynp.c librtemscpu_a_SOURCES += posix/src/pthreadsetaffinitynp.c
librtemscpu_a_SOURCES += posix/src/pthreadsetnamenp.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/psxsemaphore.c
librtemscpu_a_SOURCES += posix/src/psxtimercreate.c librtemscpu_a_SOURCES += posix/src/psxtimercreate.c
librtemscpu_a_SOURCES += posix/src/psxtimerdelete.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/pthreadatfork.c
librtemscpu_a_SOURCES += posix/src/pthread.c librtemscpu_a_SOURCES += posix/src/pthread.c
librtemscpu_a_SOURCES += posix/src/pthreadconcurrency.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/pthreaddetach.c
librtemscpu_a_SOURCES += posix/src/pthreadequal.c librtemscpu_a_SOURCES += posix/src/pthreadequal.c
librtemscpu_a_SOURCES += posix/src/pthreadexit.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/pthreadgetcpuclockid.c
librtemscpu_a_SOURCES += posix/src/pthreadgetschedparam.c
librtemscpu_a_SOURCES += posix/src/pthreadinitthreads.c librtemscpu_a_SOURCES += posix/src/pthreadinitthreads.c
librtemscpu_a_SOURCES += posix/src/pthreadjoin.c librtemscpu_a_SOURCES += posix/src/pthreadjoin.c
librtemscpu_a_SOURCES += posix/src/pthreadkill.c librtemscpu_a_SOURCES += posix/src/pthreadkill.c

View File

@@ -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( RTEMS_INLINE_ROUTINE void _POSIX_Threads_Get_sched_param_sporadic(
const Thread_Control *the_thread, const Thread_Control *the_thread,
const Scheduler_Control *scheduler, const Scheduler_Control *scheduler,
struct sched_param *param struct sched_param *param
) )
{ {
#if defined(RTEMS_POSIX_API)
const POSIX_API_Control *api; const POSIX_API_Control *api;
api = the_thread->API_Extensions[ THREAD_API_POSIX ]; 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_repl_period = api->Sporadic.sched_ss_repl_period;
param->sched_ss_init_budget = api->Sporadic.sched_ss_init_budget; param->sched_ss_init_budget = api->Sporadic.sched_ss_init_budget;
param->sched_ss_max_repl = api->Sporadic.sched_ss_max_repl; param->sched_ss_max_repl = api->Sporadic.sched_ss_max_repl;
} #else
(void) the_thread;
(void) scheduler;
(void) param;
#endif #endif
}
/** @} */ /** @} */

View File

@@ -30,8 +30,10 @@ int _POSIX_Thread_Translate_to_sched_policy(
switch ( budget_algorithm ) { switch ( budget_algorithm ) {
case THREAD_CPU_BUDGET_ALGORITHM_RESET_TIMESLICE: case THREAD_CPU_BUDGET_ALGORITHM_RESET_TIMESLICE:
return SCHED_OTHER; return SCHED_OTHER;
#if defined(RTEMS_POSIX_API)
case THREAD_CPU_BUDGET_ALGORITHM_EXHAUST_TIMESLICE: case THREAD_CPU_BUDGET_ALGORITHM_EXHAUST_TIMESLICE:
return SCHED_RR; return SCHED_RR;
#endif
case THREAD_CPU_BUDGET_ALGORITHM_CALLOUT: case THREAD_CPU_BUDGET_ALGORITHM_CALLOUT:
return SCHED_SPORADIC; return SCHED_SPORADIC;
default: default:
@@ -60,10 +62,12 @@ int _POSIX_Thread_Translate_sched_param(
return 0; return 0;
} }
#if defined(RTEMS_POSIX_API)
if ( policy == SCHED_RR ) { if ( policy == SCHED_RR ) {
*budget_algorithm = THREAD_CPU_BUDGET_ALGORITHM_EXHAUST_TIMESLICE; *budget_algorithm = THREAD_CPU_BUDGET_ALGORITHM_EXHAUST_TIMESLICE;
return 0; return 0;
} }
#endif
if ( policy == SCHED_SPORADIC ) { if ( policy == SCHED_SPORADIC ) {
if ( (param->sched_ss_repl_period.tv_sec == 0) && if ( (param->sched_ss_repl_period.tv_sec == 0) &&