sporadic server debugged and working. This required minor changes in all

sporadic server related routines.
This commit is contained in:
Joel Sherrill
1996-08-07 22:06:08 +00:00
parent ecc912f466
commit 2014063fec
2 changed files with 80 additions and 40 deletions

View File

@@ -52,6 +52,8 @@ void _POSIX_Threads_Sporadic_budget_TSR(
void *argument void *argument
) )
{ {
unsigned32 ticks;
unsigned32 new_priority;
Thread_Control *the_thread; Thread_Control *the_thread;
POSIX_API_Control *api; POSIX_API_Control *api;
@@ -59,18 +61,26 @@ void _POSIX_Threads_Sporadic_budget_TSR(
api = the_thread->API_Extensions[ THREAD_API_POSIX ]; api = the_thread->API_Extensions[ THREAD_API_POSIX ];
the_thread->cpu_time_budget = ticks = _POSIX_Timespec_to_interval( &api->schedparam.ss_initial_budget );
_POSIX_Timespec_to_interval( &api->schedparam.ss_initial_budget );
_Thread_Change_priority( if ( !ticks )
the_thread, ticks = 1;
_POSIX_Priority_To_core( api->schedparam.sched_priority )
);
_Watchdog_Insert_ticks( the_thread->cpu_time_budget = ticks;
&api->Sporadic_timer,
_POSIX_Timespec_to_interval( &api->schedparam.ss_replenish_period ) new_priority = _POSIX_Priority_To_core( api->ss_high_priority );
); the_thread->real_priority = new_priority;
if ( the_thread->resource_count == 0 ||
the_thread->current_priority > new_priority )
_Thread_Change_priority( the_thread, new_priority );
ticks = _POSIX_Timespec_to_interval( &api->schedparam.ss_replenish_period );
if ( !ticks )
ticks = 1;
_Watchdog_Insert_ticks( &api->Sporadic_timer, ticks );
} }
/*PAGE /*PAGE
@@ -83,17 +93,24 @@ void _POSIX_Threads_Sporadic_budget_callout(
) )
{ {
POSIX_API_Control *api; POSIX_API_Control *api;
unsigned32 new_priority;
api = _Thread_Executing->API_Extensions[ THREAD_API_POSIX ]; api = the_thread->API_Extensions[ THREAD_API_POSIX ];
/* XXX really should be based on MAX_U32 */ /*
* This will prevent the thread from consuming its entire "budget"
* while at low priority.
*/
the_thread->cpu_time_budget = 0xFFFFFFFF;
_Thread_Change_priority( the_thread->cpu_time_budget = 0xFFFFFFFF; /* XXX should be based on MAX_U32 */
the_thread,
_POSIX_Priority_To_core( api->schedparam.ss_low_priority ) new_priority = _POSIX_Priority_To_core( api->schedparam.ss_low_priority );
); the_thread->real_priority = new_priority;
if ( the_thread->resource_count == 0 ||
the_thread->current_priority > new_priority )
_Thread_Change_priority( the_thread, new_priority );
} }
/*PAGE /*PAGE
@@ -464,7 +481,7 @@ int pthread_attr_setschedparam(
const struct sched_param *param const struct sched_param *param
) )
{ {
if ( !attr || !attr->is_initialized ) if ( !attr || !attr->is_initialized || !param )
return EINVAL; return EINVAL;
attr->schedparam = *param; attr->schedparam = *param;
@@ -481,7 +498,7 @@ int pthread_attr_getschedparam(
struct sched_param *param struct sched_param *param
) )
{ {
if ( !attr || !attr->is_initialized ) if ( !attr || !attr->is_initialized || !param )
return EINVAL; return EINVAL;
*param = attr->schedparam; *param = attr->schedparam;
@@ -516,6 +533,8 @@ int pthread_getschedparam(
api = the_thread->API_Extensions[ THREAD_API_POSIX ]; api = the_thread->API_Extensions[ THREAD_API_POSIX ];
*policy = api->schedpolicy; *policy = api->schedpolicy;
*param = api->schedparam; *param = api->schedparam;
param->sched_priority =
_POSIX_Priority_From_core( the_thread->current_priority );
_Thread_Enable_dispatch(); _Thread_Enable_dispatch();
return 0; return 0;
} }
@@ -618,6 +637,7 @@ int pthread_setschedparam(
break; break;
case SCHED_SPORADIC: case SCHED_SPORADIC:
api->ss_high_priority = api->schedparam.sched_priority;
_POSIX_Threads_Sporadic_budget_TSR( 0, the_thread ); _POSIX_Threads_Sporadic_budget_TSR( 0, the_thread );
break; break;
} }

View File

@@ -52,6 +52,8 @@ void _POSIX_Threads_Sporadic_budget_TSR(
void *argument void *argument
) )
{ {
unsigned32 ticks;
unsigned32 new_priority;
Thread_Control *the_thread; Thread_Control *the_thread;
POSIX_API_Control *api; POSIX_API_Control *api;
@@ -59,18 +61,26 @@ void _POSIX_Threads_Sporadic_budget_TSR(
api = the_thread->API_Extensions[ THREAD_API_POSIX ]; api = the_thread->API_Extensions[ THREAD_API_POSIX ];
the_thread->cpu_time_budget = ticks = _POSIX_Timespec_to_interval( &api->schedparam.ss_initial_budget );
_POSIX_Timespec_to_interval( &api->schedparam.ss_initial_budget );
_Thread_Change_priority( if ( !ticks )
the_thread, ticks = 1;
_POSIX_Priority_To_core( api->schedparam.sched_priority )
);
_Watchdog_Insert_ticks( the_thread->cpu_time_budget = ticks;
&api->Sporadic_timer,
_POSIX_Timespec_to_interval( &api->schedparam.ss_replenish_period ) new_priority = _POSIX_Priority_To_core( api->ss_high_priority );
); the_thread->real_priority = new_priority;
if ( the_thread->resource_count == 0 ||
the_thread->current_priority > new_priority )
_Thread_Change_priority( the_thread, new_priority );
ticks = _POSIX_Timespec_to_interval( &api->schedparam.ss_replenish_period );
if ( !ticks )
ticks = 1;
_Watchdog_Insert_ticks( &api->Sporadic_timer, ticks );
} }
/*PAGE /*PAGE
@@ -83,17 +93,24 @@ void _POSIX_Threads_Sporadic_budget_callout(
) )
{ {
POSIX_API_Control *api; POSIX_API_Control *api;
unsigned32 new_priority;
api = _Thread_Executing->API_Extensions[ THREAD_API_POSIX ]; api = the_thread->API_Extensions[ THREAD_API_POSIX ];
/* XXX really should be based on MAX_U32 */ /*
* This will prevent the thread from consuming its entire "budget"
* while at low priority.
*/
the_thread->cpu_time_budget = 0xFFFFFFFF;
_Thread_Change_priority( the_thread->cpu_time_budget = 0xFFFFFFFF; /* XXX should be based on MAX_U32 */
the_thread,
_POSIX_Priority_To_core( api->schedparam.ss_low_priority ) new_priority = _POSIX_Priority_To_core( api->schedparam.ss_low_priority );
); the_thread->real_priority = new_priority;
if ( the_thread->resource_count == 0 ||
the_thread->current_priority > new_priority )
_Thread_Change_priority( the_thread, new_priority );
} }
/*PAGE /*PAGE
@@ -464,7 +481,7 @@ int pthread_attr_setschedparam(
const struct sched_param *param const struct sched_param *param
) )
{ {
if ( !attr || !attr->is_initialized ) if ( !attr || !attr->is_initialized || !param )
return EINVAL; return EINVAL;
attr->schedparam = *param; attr->schedparam = *param;
@@ -481,7 +498,7 @@ int pthread_attr_getschedparam(
struct sched_param *param struct sched_param *param
) )
{ {
if ( !attr || !attr->is_initialized ) if ( !attr || !attr->is_initialized || !param )
return EINVAL; return EINVAL;
*param = attr->schedparam; *param = attr->schedparam;
@@ -516,6 +533,8 @@ int pthread_getschedparam(
api = the_thread->API_Extensions[ THREAD_API_POSIX ]; api = the_thread->API_Extensions[ THREAD_API_POSIX ];
*policy = api->schedpolicy; *policy = api->schedpolicy;
*param = api->schedparam; *param = api->schedparam;
param->sched_priority =
_POSIX_Priority_From_core( the_thread->current_priority );
_Thread_Enable_dispatch(); _Thread_Enable_dispatch();
return 0; return 0;
} }
@@ -618,6 +637,7 @@ int pthread_setschedparam(
break; break;
case SCHED_SPORADIC: case SCHED_SPORADIC:
api->ss_high_priority = api->schedparam.sched_priority;
_POSIX_Threads_Sporadic_budget_TSR( 0, the_thread ); _POSIX_Threads_Sporadic_budget_TSR( 0, the_thread );
break; break;
} }