summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/src/pthreadsetschedparam.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2009-06-24 06:38:52 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2009-06-24 06:38:52 +0000
commit2212a2adf9f760bd01ebaed18664569a302adc9b (patch)
tree22e0bc1c0f38ded2fc2093369d7b90dc9fafa6ff /cpukit/posix/src/pthreadsetschedparam.c
parent2009-06-24 Joel Sherrill <joel.sherrill@oarcorp.com> (diff)
downloadrtems-2212a2adf9f760bd01ebaed18664569a302adc9b.tar.bz2
2009-06-24 Joel Sherrill <joel.sherrill@oarcorp.com>
* posix/Makefile.am, posix/include/rtems/posix/priority.h, posix/include/rtems/posix/pthread.h, posix/inline/rtems/posix/priority.inl, posix/src/killinfo.c, posix/src/pthread.c, posix/src/pthreadcreate.c, posix/src/pthreadsetschedparam.c: Various modifications to improve binary code coverage analysis. Some of these are to mark code as debug only. Some are to break conditional expressions into multiple lines. Some are to move inline methods that are not time critical into subroutines to make them easier to test. Inlining them multiple times means that their logic paths are spread across multiple methods. This explodes the test cases required. * posix/src/psxpriorityisvalid.c, posix/src/psxtransschedparam.c: New files.
Diffstat (limited to 'cpukit/posix/src/pthreadsetschedparam.c')
-rw-r--r--cpukit/posix/src/pthreadsetschedparam.c46
1 files changed, 9 insertions, 37 deletions
diff --git a/cpukit/posix/src/pthreadsetschedparam.c b/cpukit/posix/src/pthreadsetschedparam.c
index 8d5ffb1888..e95659f2db 100644
--- a/cpukit/posix/src/pthreadsetschedparam.c
+++ b/cpukit/posix/src/pthreadsetschedparam.c
@@ -36,54 +36,26 @@ int pthread_setschedparam(
Thread_CPU_budget_algorithms budget_algorithm;
Thread_CPU_budget_algorithm_callout budget_callout;
Objects_Locations location;
+ int rc;
/*
* Check all the parameters
*/
-
if ( !param )
return EINVAL;
- if ( !_POSIX_Priority_Is_valid( param->sched_priority ) )
- return EINVAL;
-
- budget_algorithm = THREAD_CPU_BUDGET_ALGORITHM_NONE;
- budget_callout = NULL;
-
- switch ( policy ) {
- case SCHED_OTHER:
- budget_algorithm = THREAD_CPU_BUDGET_ALGORITHM_RESET_TIMESLICE;
- break;
-
- case SCHED_FIFO:
- budget_algorithm = THREAD_CPU_BUDGET_ALGORITHM_NONE;
- break;
-
- case SCHED_RR:
- budget_algorithm = THREAD_CPU_BUDGET_ALGORITHM_EXHAUST_TIMESLICE;
- break;
-
- case SCHED_SPORADIC:
- budget_algorithm = THREAD_CPU_BUDGET_ALGORITHM_CALLOUT;
- budget_callout = _POSIX_Threads_Sporadic_budget_callout;
-
- if ( _Timespec_To_ticks( &param->ss_replenish_period ) <
- _Timespec_To_ticks( &param->ss_initial_budget ) )
- return EINVAL;
-
- if ( !_POSIX_Priority_Is_valid( param->ss_low_priority ) )
- return EINVAL;
-
- break;
-
- default:
- return EINVAL;
- }
+ rc = _POSIX_Thread_Translate_sched_param(
+ policy,
+ param,
+ &budget_algorithm,
+ &budget_callout
+ );
+ if ( rc )
+ return rc;
/*
* Actually change the scheduling policy and parameters
*/
-
the_thread = _POSIX_Threads_Get( thread, &location );
switch ( location ) {