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