Deleted Added
full compact
ksched.c (164936) ksched.c (170307)
1/*-
2 * Copyright (c) 1996, 1997
3 * HD Associates, Inc. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 20 unchanged lines hidden (view full) ---

29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 */
32
33/* ksched: Soft real time scheduling based on "rtprio".
34 */
35
36#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1996, 1997
3 * HD Associates, Inc. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 20 unchanged lines hidden (view full) ---

29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 */
32
33/* ksched: Soft real time scheduling based on "rtprio".
34 */
35
36#include <sys/cdefs.h>
37__FBSDID("$FreeBSD: head/sys/kern/ksched.c 164936 2006-12-06 06:34:57Z julian $");
37__FBSDID("$FreeBSD: head/sys/kern/ksched.c 170307 2007-06-05 00:00:57Z jeff $");
38
39#include "opt_posix.h"
40
41#include <sys/param.h>
42#include <sys/systm.h>
43#include <sys/lock.h>
44#include <sys/mutex.h>
45#include <sys/proc.h>

--- 53 unchanged lines hidden (view full) ---

99#define P1B_PRIO_MAX rtpprio_to_p4prio(RTP_PRIO_MIN)
100
101static __inline int
102getscheduler(struct ksched *ksched, struct thread *td, int *policy)
103{
104 struct rtprio rtp;
105 int e = 0;
106
38
39#include "opt_posix.h"
40
41#include <sys/param.h>
42#include <sys/systm.h>
43#include <sys/lock.h>
44#include <sys/mutex.h>
45#include <sys/proc.h>

--- 53 unchanged lines hidden (view full) ---

99#define P1B_PRIO_MAX rtpprio_to_p4prio(RTP_PRIO_MIN)
100
101static __inline int
102getscheduler(struct ksched *ksched, struct thread *td, int *policy)
103{
104 struct rtprio rtp;
105 int e = 0;
106
107 mtx_lock_spin(&sched_lock);
108 pri_to_rtp(td, &rtp);
107 pri_to_rtp(td, &rtp);
109 mtx_unlock_spin(&sched_lock);
110 switch (rtp.type)
111 {
112 case RTP_PRIO_FIFO:
113 *policy = SCHED_FIFO;
114 break;
115
116 case RTP_PRIO_REALTIME:
117 *policy = SCHED_RR;

--- 28 unchanged lines hidden (view full) ---

146}
147
148int
149ksched_getparam(struct ksched *ksched,
150 struct thread *td, struct sched_param *param)
151{
152 struct rtprio rtp;
153
108 switch (rtp.type)
109 {
110 case RTP_PRIO_FIFO:
111 *policy = SCHED_FIFO;
112 break;
113
114 case RTP_PRIO_REALTIME:
115 *policy = SCHED_RR;

--- 28 unchanged lines hidden (view full) ---

144}
145
146int
147ksched_getparam(struct ksched *ksched,
148 struct thread *td, struct sched_param *param)
149{
150 struct rtprio rtp;
151
154 mtx_lock_spin(&sched_lock);
155 pri_to_rtp(td, &rtp);
152 pri_to_rtp(td, &rtp);
156 mtx_unlock_spin(&sched_lock);
157 if (RTP_PRIO_IS_REALTIME(rtp.type))
158 param->sched_priority = rtpprio_to_p4prio(rtp.prio);
159
160 return 0;
161}
162
163/*
164 * XXX The priority and scheduler modifications should

--- 16 unchanged lines hidden (view full) ---

181
182 if (param->sched_priority >= P1B_PRIO_MIN &&
183 param->sched_priority <= P1B_PRIO_MAX)
184 {
185 rtp.prio = p4prio_to_rtpprio(param->sched_priority);
186 rtp.type = (policy == SCHED_FIFO)
187 ? RTP_PRIO_FIFO : RTP_PRIO_REALTIME;
188
153 if (RTP_PRIO_IS_REALTIME(rtp.type))
154 param->sched_priority = rtpprio_to_p4prio(rtp.prio);
155
156 return 0;
157}
158
159/*
160 * XXX The priority and scheduler modifications should

--- 16 unchanged lines hidden (view full) ---

177
178 if (param->sched_priority >= P1B_PRIO_MIN &&
179 param->sched_priority <= P1B_PRIO_MAX)
180 {
181 rtp.prio = p4prio_to_rtpprio(param->sched_priority);
182 rtp.type = (policy == SCHED_FIFO)
183 ? RTP_PRIO_FIFO : RTP_PRIO_REALTIME;
184
189 mtx_lock_spin(&sched_lock);
190 rtp_to_pri(&rtp, td);
185 rtp_to_pri(&rtp, td);
191 mtx_unlock_spin(&sched_lock);
192 }
193 else
194 e = EPERM;
195
196
197 break;
198
199 case SCHED_OTHER:
200 {
201 rtp.type = RTP_PRIO_NORMAL;
202 rtp.prio = p4prio_to_rtpprio(param->sched_priority);
186 }
187 else
188 e = EPERM;
189
190
191 break;
192
193 case SCHED_OTHER:
194 {
195 rtp.type = RTP_PRIO_NORMAL;
196 rtp.prio = p4prio_to_rtpprio(param->sched_priority);
203 mtx_lock_spin(&sched_lock);
204 rtp_to_pri(&rtp, td);
197 rtp_to_pri(&rtp, td);
205 mtx_unlock_spin(&sched_lock);
206 }
207 break;
208
209 default:
210 e = EINVAL;
211 break;
212 }
213

--- 72 unchanged lines hidden ---
198 }
199 break;
200
201 default:
202 e = EINVAL;
203 break;
204 }
205

--- 72 unchanged lines hidden ---