source: rtems/cpukit/posix/src/psxtransschedparam.c @ 1de949a8

4.104.11
Last change on this file since 1de949a8 was 1de949a8, checked in by Ralf Corsepius <ralf.corsepius@…>, on Nov 30, 2009 at 3:49:52 PM

Whitespace removal.

  • 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->ss_replenish_period.tv_sec == 0) &&
53         (param->ss_replenish_period.tv_nsec == 0) )
54      return EINVAL;
55
56    if ( (param->ss_initial_budget.tv_sec == 0) &&
57         (param->ss_initial_budget.tv_nsec == 0) )
58      return EINVAL;
59
60    if ( _Timespec_To_ticks( &param->ss_replenish_period ) <
61         _Timespec_To_ticks( &param->ss_initial_budget ) )
62      return EINVAL;
63
64    if ( !_POSIX_Priority_Is_valid( param->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.