forked from Imagelibrary/rtems
posix: Remove POSIX_API_Control::schedparam
Move sporadic server scheduler parameters to POSIX_API_Control::Sporadic. Remove redundant scheduler priority parameter. Update #2514.
This commit is contained in:
@@ -24,6 +24,8 @@
|
||||
|
||||
#include <rtems/score/basedefs.h>
|
||||
#include <rtems/score/assert.h>
|
||||
#include <rtems/posix/priorityimpl.h>
|
||||
#include <rtems/posix/threadsup.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -61,6 +63,22 @@ RTEMS_INLINE_ROUTINE void _POSIX_Threads_Initialize_attributes(
|
||||
);
|
||||
}
|
||||
|
||||
RTEMS_INLINE_ROUTINE void _POSIX_Threads_Get_sched_param_sporadic(
|
||||
const Thread_Control *the_thread,
|
||||
const POSIX_API_Control *api,
|
||||
const Scheduler_Control *scheduler,
|
||||
struct sched_param *param
|
||||
)
|
||||
{
|
||||
param->sched_ss_low_priority = _POSIX_Priority_From_core(
|
||||
scheduler,
|
||||
api->Sporadic.Low_priority.priority
|
||||
);
|
||||
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;
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -54,12 +54,12 @@ RTEMS_INLINE_ROUTINE void _POSIX_Threads_Sporadic_timer_insert(
|
||||
)
|
||||
{
|
||||
the_thread->cpu_time_budget =
|
||||
_Timespec_To_ticks( &api->schedparam.sched_ss_init_budget );
|
||||
_Timespec_To_ticks( &api->Sporadic.sched_ss_init_budget );
|
||||
|
||||
_Watchdog_Per_CPU_insert_ticks(
|
||||
&api->Sporadic.Timer,
|
||||
_Per_CPU_Get(),
|
||||
_Timespec_To_ticks( &api->schedparam.sched_ss_repl_period )
|
||||
_Timespec_To_ticks( &api->Sporadic.sched_ss_repl_period )
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -46,9 +46,6 @@ typedef struct {
|
||||
/** The scheduler policy. */
|
||||
int schedpolicy;
|
||||
|
||||
/** The scheduler parameters */
|
||||
struct sched_param schedparam;
|
||||
|
||||
/**
|
||||
* @brief Control block for the sporadic server scheduling policy.
|
||||
*/
|
||||
@@ -67,6 +64,23 @@ typedef struct {
|
||||
* policy.
|
||||
*/
|
||||
Priority_Node Low_priority;
|
||||
|
||||
/**
|
||||
* @brief Replenishment period for sporadic server.
|
||||
*/
|
||||
struct timespec sched_ss_repl_period;
|
||||
|
||||
/**
|
||||
* @brief Initial budget for sporadic server.
|
||||
*/
|
||||
struct timespec sched_ss_init_budget;
|
||||
|
||||
/**
|
||||
* @brief Maximum pending replenishments.
|
||||
*
|
||||
* Only used by pthread_getschedparam() and pthread_getattr_np().
|
||||
*/
|
||||
int sched_ss_max_repl;
|
||||
} Sporadic;
|
||||
|
||||
/** This is the set of signals which are currently unblocked. */
|
||||
|
||||
@@ -126,12 +126,6 @@ static bool _POSIX_Threads_Create_extension(
|
||||
|
||||
api = created->API_Extensions[ THREAD_API_POSIX ];
|
||||
|
||||
/* XXX check all fields are touched */
|
||||
api->schedparam.sched_priority = _POSIX_Priority_From_core(
|
||||
_Thread_Scheduler_get_home( created ),
|
||||
_Thread_Get_priority( created )
|
||||
);
|
||||
|
||||
/*
|
||||
* If the thread is not a posix thread, then all posix signals are blocked
|
||||
* by default.
|
||||
|
||||
@@ -241,8 +241,14 @@ int pthread_create(
|
||||
api->created_with_explicit_scheduler =
|
||||
( the_attr->inheritsched == PTHREAD_EXPLICIT_SCHED );
|
||||
api->schedpolicy = the_attr->schedpolicy;
|
||||
api->schedparam = the_attr->schedparam;
|
||||
|
||||
_Priority_Node_set_priority( &api->Sporadic.Low_priority, core_low_prio );
|
||||
api->Sporadic.sched_ss_repl_period =
|
||||
the_attr->schedparam.sched_ss_repl_period;
|
||||
api->Sporadic.sched_ss_init_budget =
|
||||
the_attr->schedparam.sched_ss_init_budget;
|
||||
api->Sporadic.sched_ss_max_repl =
|
||||
the_attr->schedparam.sched_ss_max_repl;
|
||||
|
||||
if ( schedpolicy == SCHED_SPORADIC ) {
|
||||
_POSIX_Threads_Sporadic_timer( &api->Sporadic.Timer );
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
#include <string.h>
|
||||
|
||||
#include <rtems/posix/pthreadimpl.h>
|
||||
#include <rtems/posix/pthreadattrimpl.h>
|
||||
#include <rtems/posix/priorityimpl.h>
|
||||
#include <rtems/score/schedulerimpl.h>
|
||||
#include <rtems/score/threadimpl.h>
|
||||
|
||||
@@ -32,10 +34,11 @@ int pthread_getattr_np(
|
||||
pthread_attr_t *attr
|
||||
)
|
||||
{
|
||||
Thread_Control *the_thread;
|
||||
ISR_lock_Context lock_context;
|
||||
POSIX_API_Control *api;
|
||||
bool ok;
|
||||
Thread_Control *the_thread;
|
||||
ISR_lock_Context lock_context;
|
||||
POSIX_API_Control *api;
|
||||
const Scheduler_Control *scheduler;
|
||||
bool ok;
|
||||
|
||||
if ( attr == NULL ) {
|
||||
return EINVAL;
|
||||
@@ -65,7 +68,18 @@ int pthread_getattr_np(
|
||||
}
|
||||
|
||||
attr->schedpolicy = api->schedpolicy;
|
||||
attr->schedparam = api->schedparam;
|
||||
|
||||
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,
|
||||
api,
|
||||
scheduler,
|
||||
&attr->schedparam
|
||||
);
|
||||
attr->cputime_clock_allowed = 1;
|
||||
|
||||
if ( _Thread_Is_joinable( the_thread ) ) {
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <errno.h>
|
||||
|
||||
#include <rtems/posix/pthreadimpl.h>
|
||||
#include <rtems/posix/pthreadattrimpl.h>
|
||||
#include <rtems/posix/priorityimpl.h>
|
||||
#include <rtems/score/schedulerimpl.h>
|
||||
#include <rtems/score/threadimpl.h>
|
||||
@@ -57,9 +58,8 @@ int pthread_getschedparam(
|
||||
_Thread_Wait_acquire_critical( the_thread, &queue_context );
|
||||
|
||||
*policy = api->schedpolicy;
|
||||
*param = api->schedparam;
|
||||
|
||||
scheduler = _Thread_Scheduler_get_home( the_thread );
|
||||
_POSIX_Threads_Get_sched_param_sporadic( the_thread, api, scheduler, param );
|
||||
priority = the_thread->Real_priority.priority;
|
||||
|
||||
_Thread_Wait_release( the_thread, &queue_context );
|
||||
|
||||
@@ -41,28 +41,28 @@ static int _POSIX_Set_sched_param(
|
||||
{
|
||||
const Scheduler_Control *scheduler;
|
||||
POSIX_API_Control *api;
|
||||
int normal_prio;
|
||||
int low_prio;
|
||||
int high_prio;
|
||||
bool valid;
|
||||
Priority_Control core_normal_prio;
|
||||
Priority_Control core_low_prio;
|
||||
|
||||
if ( policy == SCHED_SPORADIC ) {
|
||||
low_prio = param->sched_ss_low_priority;
|
||||
high_prio = param->sched_priority;
|
||||
} else {
|
||||
low_prio = param->sched_priority;
|
||||
high_prio = low_prio;
|
||||
}
|
||||
normal_prio = param->sched_priority;
|
||||
|
||||
scheduler = _Thread_Scheduler_get_home( the_thread );
|
||||
|
||||
core_normal_prio = _POSIX_Priority_To_core( scheduler, low_prio, &valid );
|
||||
core_normal_prio = _POSIX_Priority_To_core( scheduler, normal_prio, &valid );
|
||||
if ( !valid ) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
core_low_prio = _POSIX_Priority_To_core( scheduler, high_prio, &valid );
|
||||
if ( policy == SCHED_SPORADIC ) {
|
||||
low_prio = param->sched_ss_low_priority;
|
||||
} else {
|
||||
low_prio = normal_prio;
|
||||
}
|
||||
|
||||
core_low_prio = _POSIX_Priority_To_core( scheduler, low_prio, &valid );
|
||||
if ( !valid ) {
|
||||
return EINVAL;
|
||||
}
|
||||
@@ -95,13 +95,16 @@ static int _POSIX_Set_sched_param(
|
||||
}
|
||||
|
||||
api->schedpolicy = policy;
|
||||
api->schedparam = *param;
|
||||
|
||||
the_thread->budget_algorithm = budget_algorithm;
|
||||
the_thread->budget_callout = budget_callout;
|
||||
|
||||
_Priority_Node_set_priority( &api->Sporadic.Low_priority, core_low_prio );
|
||||
api->Sporadic.sched_ss_repl_period = param->sched_ss_repl_period;
|
||||
api->Sporadic.sched_ss_init_budget = param->sched_ss_init_budget;
|
||||
api->Sporadic.sched_ss_max_repl = param->sched_ss_max_repl;
|
||||
|
||||
if ( policy == SCHED_SPORADIC ) {
|
||||
_Priority_Node_set_priority( &api->Sporadic.Low_priority, core_low_prio );
|
||||
_POSIX_Threads_Sporadic_timer_insert( the_thread, api );
|
||||
} else {
|
||||
the_thread->cpu_time_budget =
|
||||
|
||||
@@ -62,11 +62,7 @@ static int attribute_compare(
|
||||
if ( attr1->schedpolicy != attr2->schedpolicy )
|
||||
return 1;
|
||||
|
||||
if (memcmp(
|
||||
&attr1->schedparam,
|
||||
&attr2->schedparam,
|
||||
sizeof(struct sched_param)
|
||||
))
|
||||
if ( attr1->schedparam.sched_priority != attr2->schedparam.sched_priority )
|
||||
return 1;
|
||||
|
||||
#if HAVE_DECL_PTHREAD_ATTR_SETGUARDSIZE
|
||||
|
||||
Reference in New Issue
Block a user