1 | /* |
---|
2 | * COPYRIGHT (c) 1989-2007. |
---|
3 | * On-Line Applications Research Corporation (OAR). |
---|
4 | * |
---|
5 | * The license and distribution terms for this file may be |
---|
6 | * found in the file LICENSE in this distribution or at |
---|
7 | * http://www.rtems.com/license/LICENSE. |
---|
8 | * |
---|
9 | * $Id$ |
---|
10 | */ |
---|
11 | |
---|
12 | #if HAVE_CONFIG_H |
---|
13 | #include "config.h" |
---|
14 | #endif |
---|
15 | |
---|
16 | #include <sched.h> |
---|
17 | #include <errno.h> |
---|
18 | |
---|
19 | #include <rtems/system.h> |
---|
20 | #include <rtems/score/tod.h> |
---|
21 | #include <rtems/score/thread.h> |
---|
22 | #include <rtems/seterr.h> |
---|
23 | #include <rtems/posix/priority.h> |
---|
24 | #include <rtems/posix/time.h> |
---|
25 | |
---|
26 | /*PAGE |
---|
27 | * |
---|
28 | * 13.3.1 Set Scheduling Parameters, P1003.1b-1993, p. 252 |
---|
29 | * |
---|
30 | */ |
---|
31 | |
---|
32 | int sched_setparam( |
---|
33 | pid_t pid, |
---|
34 | const struct sched_param *param |
---|
35 | ) |
---|
36 | { |
---|
37 | rtems_set_errno_and_return_minus_one( ENOSYS ); |
---|
38 | } |
---|
39 | |
---|
40 | /*PAGE |
---|
41 | * |
---|
42 | * 13.3.2 Set Scheduling Parameters, P1003.1b-1993, p. 253 |
---|
43 | */ |
---|
44 | |
---|
45 | int sched_getparam( |
---|
46 | pid_t pid, |
---|
47 | const struct sched_param *param |
---|
48 | ) |
---|
49 | { |
---|
50 | rtems_set_errno_and_return_minus_one( ENOSYS ); |
---|
51 | } |
---|
52 | |
---|
53 | /*PAGE |
---|
54 | * |
---|
55 | * 13.3.3 Set Scheduling Policy and Scheduling Parameters, |
---|
56 | * P1003.1b-1993, p. 254 |
---|
57 | */ |
---|
58 | |
---|
59 | int sched_setscheduler( |
---|
60 | pid_t pid, |
---|
61 | int policy, |
---|
62 | const struct sched_param *param |
---|
63 | ) |
---|
64 | { |
---|
65 | rtems_set_errno_and_return_minus_one( ENOSYS ); |
---|
66 | } |
---|
67 | |
---|
68 | /*PAGE |
---|
69 | * |
---|
70 | * 13.3.4 Get Scheduling Policy, P1003.1b-1993, p. 256 |
---|
71 | */ |
---|
72 | |
---|
73 | int sched_getscheduler( |
---|
74 | pid_t pid |
---|
75 | ) |
---|
76 | { |
---|
77 | rtems_set_errno_and_return_minus_one( ENOSYS ); |
---|
78 | } |
---|
79 | |
---|
80 | /*PAGE |
---|
81 | * |
---|
82 | * 13.3.6 Get Scheduling Parameter Limits, P1003.1b-1993, p. 258 |
---|
83 | */ |
---|
84 | |
---|
85 | int sched_get_priority_max( |
---|
86 | int policy |
---|
87 | ) |
---|
88 | { |
---|
89 | switch ( policy ) { |
---|
90 | case SCHED_OTHER: |
---|
91 | case SCHED_FIFO: |
---|
92 | case SCHED_RR: |
---|
93 | case SCHED_SPORADIC: |
---|
94 | break; |
---|
95 | |
---|
96 | default: |
---|
97 | rtems_set_errno_and_return_minus_one( EINVAL ); |
---|
98 | } |
---|
99 | |
---|
100 | return POSIX_SCHEDULER_MAXIMUM_PRIORITY; |
---|
101 | } |
---|
102 | |
---|
103 | /*PAGE |
---|
104 | * |
---|
105 | * 13.3.6 Get Scheduling Parameter Limits, P1003.1b-1993, p. 258 |
---|
106 | */ |
---|
107 | |
---|
108 | int sched_get_priority_min( |
---|
109 | int policy |
---|
110 | ) |
---|
111 | { |
---|
112 | switch ( policy ) { |
---|
113 | case SCHED_OTHER: |
---|
114 | case SCHED_FIFO: |
---|
115 | case SCHED_RR: |
---|
116 | case SCHED_SPORADIC: |
---|
117 | break; |
---|
118 | |
---|
119 | default: |
---|
120 | rtems_set_errno_and_return_minus_one( EINVAL ); |
---|
121 | } |
---|
122 | |
---|
123 | return POSIX_SCHEDULER_MINIMUM_PRIORITY; |
---|
124 | } |
---|
125 | |
---|
126 | /*PAGE |
---|
127 | * |
---|
128 | * 13.3.6 Get Scheduling Parameter Limits, P1003.1b-1993, p. 258 |
---|
129 | */ |
---|
130 | |
---|
131 | int sched_rr_get_interval( |
---|
132 | pid_t pid, |
---|
133 | struct timespec *interval |
---|
134 | ) |
---|
135 | { |
---|
136 | /* |
---|
137 | * Only supported for the "calling process" (i.e. this node). |
---|
138 | */ |
---|
139 | |
---|
140 | if ( pid && pid != getpid() ) |
---|
141 | rtems_set_errno_and_return_minus_one( ESRCH ); |
---|
142 | |
---|
143 | if ( !interval ) |
---|
144 | rtems_set_errno_and_return_minus_one( EINVAL ); |
---|
145 | |
---|
146 | _Timespec_From_ticks( _Thread_Ticks_per_timeslice, interval ); |
---|
147 | return 0; |
---|
148 | } |
---|
149 | |
---|
150 | /*PAGE |
---|
151 | * |
---|
152 | * 13.3.5 Yield Processor, P1003.1b-1993, p. 257 |
---|
153 | */ |
---|
154 | |
---|
155 | int sched_yield( void ) |
---|
156 | { |
---|
157 | _Thread_Disable_dispatch(); |
---|
158 | _Thread_Yield_processor(); |
---|
159 | _Thread_Enable_dispatch(); |
---|
160 | return 0; |
---|
161 | } |
---|