summaryrefslogtreecommitdiffstats
path: root/cpukit/posix
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1996-08-07 22:06:08 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1996-08-07 22:06:08 +0000
commit2014063feca4eb2f1a54437ed343621a3167597d (patch)
tree6526e2eddbed9afa50c667b53e5a375956cbc7f9 /cpukit/posix
parentadded more error cases to complete testing of pthread_equal when (diff)
downloadrtems-2014063feca4eb2f1a54437ed343621a3167597d.tar.bz2
sporadic server debugged and working. This required minor changes in all
sporadic server related routines.
Diffstat (limited to 'cpukit/posix')
-rw-r--r--cpukit/posix/src/pthread.c60
1 files changed, 40 insertions, 20 deletions
diff --git a/cpukit/posix/src/pthread.c b/cpukit/posix/src/pthread.c
index b6d8ecc0ed..3741c09a15 100644
--- a/cpukit/posix/src/pthread.c
+++ b/cpukit/posix/src/pthread.c
@@ -52,6 +52,8 @@ void _POSIX_Threads_Sporadic_budget_TSR(
void *argument
)
{
+ unsigned32 ticks;
+ unsigned32 new_priority;
Thread_Control *the_thread;
POSIX_API_Control *api;
@@ -59,18 +61,26 @@ void _POSIX_Threads_Sporadic_budget_TSR(
api = the_thread->API_Extensions[ THREAD_API_POSIX ];
- the_thread->cpu_time_budget =
- _POSIX_Timespec_to_interval( &api->schedparam.ss_initial_budget );
+ ticks = _POSIX_Timespec_to_interval( &api->schedparam.ss_initial_budget );
- _Thread_Change_priority(
- the_thread,
- _POSIX_Priority_To_core( api->schedparam.sched_priority )
- );
+ if ( !ticks )
+ ticks = 1;
+
+ the_thread->cpu_time_budget = ticks;
- _Watchdog_Insert_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
@@ -82,18 +92,25 @@ void _POSIX_Threads_Sporadic_budget_callout(
Thread_Control *the_thread
)
{
- 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,
- _POSIX_Priority_To_core( api->schedparam.ss_low_priority )
- );
+ the_thread->cpu_time_budget = 0xFFFFFFFF; /* XXX should be based on MAX_U32 */
+
+ 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
@@ -464,7 +481,7 @@ int pthread_attr_setschedparam(
const struct sched_param *param
)
{
- if ( !attr || !attr->is_initialized )
+ if ( !attr || !attr->is_initialized || !param )
return EINVAL;
attr->schedparam = *param;
@@ -481,7 +498,7 @@ int pthread_attr_getschedparam(
struct sched_param *param
)
{
- if ( !attr || !attr->is_initialized )
+ if ( !attr || !attr->is_initialized || !param )
return EINVAL;
*param = attr->schedparam;
@@ -516,6 +533,8 @@ int pthread_getschedparam(
api = the_thread->API_Extensions[ THREAD_API_POSIX ];
*policy = api->schedpolicy;
*param = api->schedparam;
+ param->sched_priority =
+ _POSIX_Priority_From_core( the_thread->current_priority );
_Thread_Enable_dispatch();
return 0;
}
@@ -618,6 +637,7 @@ int pthread_setschedparam(
break;
case SCHED_SPORADIC:
+ api->ss_high_priority = api->schedparam.sched_priority;
_POSIX_Threads_Sporadic_budget_TSR( 0, the_thread );
break;
}