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

4.104.115
Last change on this file since 3bacb250 was 3bacb250, checked in by Ralf Corsepius <ralf.corsepius@…>, on 04/03/10 at 05:55:59

Reflect POSIX sched_parm changes.

  • Property mode set to 100644
File size: 1.9 KB
RevLine 
[2212a2ad]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
[3ba0750]36  if ( policy == SCHED_OTHER ) {
37    *budget_algorithm = THREAD_CPU_BUDGET_ALGORITHM_RESET_TIMESLICE;
38    return 0;
39  }
[2212a2ad]40
[3ba0750]41  if ( policy == SCHED_FIFO ) {
42    *budget_algorithm = THREAD_CPU_BUDGET_ALGORITHM_NONE;
43    return 0;
44  }
[2212a2ad]45
[3ba0750]46  if ( policy == SCHED_RR ) {
47    *budget_algorithm = THREAD_CPU_BUDGET_ALGORITHM_EXHAUST_TIMESLICE;
48    return 0;
49  }
[2212a2ad]50
[3ba0750]51  if ( policy == SCHED_SPORADIC ) {
[3bacb250]52    if ( (param->sched_ss_repl_period.tv_sec == 0) &&
53         (param->sched_ss_repl_period.tv_nsec == 0) )
[770db69]54      return EINVAL;
55
[3bacb250]56    if ( (param->sched_ss_init_budget.tv_sec == 0) &&
57         (param->sched_ss_init_budget.tv_nsec == 0) )
[770db69]58      return EINVAL;
59
[3bacb250]60    if ( _Timespec_To_ticks( &param->sched_ss_repl_period ) <
61         _Timespec_To_ticks( &param->sched_ss_init_budget ) )
[3ba0750]62      return EINVAL;
[2212a2ad]63
[3bacb250]64    if ( !_POSIX_Priority_Is_valid( param->sched_ss_low_priority ) )
[2212a2ad]65      return EINVAL;
[1de949a8]66
[3ba0750]67    *budget_algorithm  = THREAD_CPU_BUDGET_ALGORITHM_CALLOUT;
68    *budget_callout = _POSIX_Threads_Sporadic_budget_callout;
69    return 0;
[2212a2ad]70  }
[3ba0750]71
72  return EINVAL;
[2212a2ad]73}
Note: See TracBrowser for help on using the repository browser.