source: rtems/cpukit/posix/src/psxtransschedparam.c @ 3ba0750

4.104.11
Last change on this file since 3ba0750 was 3ba0750, checked in by Joel Sherrill <joel.sherrill@…>, on Jul 6, 2009 at 5:59:34 PM

2009-07-06 Joel Sherrill <joel.sherrill@…>

  • posix/src/psxtransschedparam.c: Restructure to avoid untestable code being generated by switch.
  • Property mode set to 100644
File size: 1.6 KB
Line 
1/*  COPYRIGHT (c) 1989-2009.
2 *  On-Line Applications Research Corporation (OAR).
3 *
4 *  The license and distribution terms for this file may be
5 *  found in the file LICENSE in this distribution or at
6 *  http://www.rtems.com/license/LICENSE.
7 *
8 *  $Id$
9 */
10
11#if HAVE_CONFIG_H
12#include "config.h"
13#endif
14
15#include <pthread.h>
16#include <errno.h>
17
18#include <rtems/system.h>
19#include <rtems/posix/pthread.h>
20#include <rtems/posix/priority.h>
21#include <rtems/posix/time.h>
22
23int _POSIX_Thread_Translate_sched_param(
24  int                                  policy,
25  struct sched_param                  *param,
26  Thread_CPU_budget_algorithms        *budget_algorithm,
27  Thread_CPU_budget_algorithm_callout *budget_callout
28)
29{
30  if ( !_POSIX_Priority_Is_valid( param->sched_priority ) )
31    return EINVAL;
32
33  *budget_algorithm = THREAD_CPU_BUDGET_ALGORITHM_NONE;
34  *budget_callout = NULL;
35
36  if ( policy == SCHED_OTHER ) {
37    *budget_algorithm = THREAD_CPU_BUDGET_ALGORITHM_RESET_TIMESLICE;
38    return 0;
39  }
40
41  if ( policy == SCHED_FIFO ) {
42    *budget_algorithm = THREAD_CPU_BUDGET_ALGORITHM_NONE;
43    return 0;
44  }
45
46  if ( policy == SCHED_RR ) {
47    *budget_algorithm = THREAD_CPU_BUDGET_ALGORITHM_EXHAUST_TIMESLICE;
48    return 0;
49  }
50
51  if ( policy == SCHED_SPORADIC ) {
52    if ( _Timespec_To_ticks( &param->ss_replenish_period ) <
53         _Timespec_To_ticks( &param->ss_initial_budget ) )
54      return EINVAL;
55
56    if ( !_POSIX_Priority_Is_valid( param->ss_low_priority ) )
57      return EINVAL;
58   
59    *budget_algorithm  = THREAD_CPU_BUDGET_ALGORITHM_CALLOUT;
60    *budget_callout = _POSIX_Threads_Sporadic_budget_callout;
61    return 0;
62  }
63
64  return EINVAL;
65}
Note: See TracBrowser for help on using the repository browser.