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