source: rtems/cpukit/posix/src/psxtransschedparam.c @ e24760ae

4.104.115
Last change on this file since e24760ae 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
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 ( (param->sched_ss_repl_period.tv_sec == 0) &&
53         (param->sched_ss_repl_period.tv_nsec == 0) )
54      return EINVAL;
55
56    if ( (param->sched_ss_init_budget.tv_sec == 0) &&
57         (param->sched_ss_init_budget.tv_nsec == 0) )
58      return EINVAL;
59
60    if ( _Timespec_To_ticks( &param->sched_ss_repl_period ) <
61         _Timespec_To_ticks( &param->sched_ss_init_budget ) )
62      return EINVAL;
63
64    if ( !_POSIX_Priority_Is_valid( param->sched_ss_low_priority ) )
65      return EINVAL;
66
67    *budget_algorithm  = THREAD_CPU_BUDGET_ALGORITHM_CALLOUT;
68    *budget_callout = _POSIX_Threads_Sporadic_budget_callout;
69    return 0;
70  }
71
72  return EINVAL;
73}
Note: See TracBrowser for help on using the repository browser.