ksched.c (160285) | ksched.c (163709) |
---|---|
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 160285 2006-07-12 05:54:17Z davidxu $"); | 37__FBSDID("$FreeBSD: head/sys/kern/ksched.c 163709 2006-10-26 21:42:22Z jb $"); |
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> --- 55 unchanged lines hidden (view full) --- 101 102static __inline int 103getscheduler(struct ksched *ksched, struct thread *td, int *policy) 104{ 105 struct rtprio rtp; 106 int e = 0; 107 108 mtx_lock_spin(&sched_lock); | 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> --- 55 unchanged lines hidden (view full) --- 101 102static __inline int 103getscheduler(struct ksched *ksched, struct thread *td, int *policy) 104{ 105 struct rtprio rtp; 106 int e = 0; 107 108 mtx_lock_spin(&sched_lock); |
109#ifdef KSE |
|
109 pri_to_rtp(td->td_ksegrp, &rtp); | 110 pri_to_rtp(td->td_ksegrp, &rtp); |
111#else 112 pri_to_rtp(td, &rtp); 113#endif |
|
110 mtx_unlock_spin(&sched_lock); 111 switch (rtp.type) 112 { 113 case RTP_PRIO_FIFO: 114 *policy = SCHED_FIFO; 115 break; 116 117 case RTP_PRIO_REALTIME: --- 30 unchanged lines hidden (view full) --- 148 149int 150ksched_getparam(struct ksched *ksched, 151 struct thread *td, struct sched_param *param) 152{ 153 struct rtprio rtp; 154 155 mtx_lock_spin(&sched_lock); | 114 mtx_unlock_spin(&sched_lock); 115 switch (rtp.type) 116 { 117 case RTP_PRIO_FIFO: 118 *policy = SCHED_FIFO; 119 break; 120 121 case RTP_PRIO_REALTIME: --- 30 unchanged lines hidden (view full) --- 152 153int 154ksched_getparam(struct ksched *ksched, 155 struct thread *td, struct sched_param *param) 156{ 157 struct rtprio rtp; 158 159 mtx_lock_spin(&sched_lock); |
160#ifdef KSE |
|
156 pri_to_rtp(td->td_ksegrp, &rtp); | 161 pri_to_rtp(td->td_ksegrp, &rtp); |
162#else 163 pri_to_rtp(td, &rtp); 164#endif |
|
157 mtx_unlock_spin(&sched_lock); 158 if (RTP_PRIO_IS_REALTIME(rtp.type)) 159 param->sched_priority = rtpprio_to_p4prio(rtp.prio); 160 161 return 0; 162} 163 164/* --- 4 unchanged lines hidden (view full) --- 169 * 170 */ 171int 172ksched_setscheduler(struct ksched *ksched, 173 struct thread *td, int policy, const struct sched_param *param) 174{ 175 int e = 0; 176 struct rtprio rtp; | 165 mtx_unlock_spin(&sched_lock); 166 if (RTP_PRIO_IS_REALTIME(rtp.type)) 167 param->sched_priority = rtpprio_to_p4prio(rtp.prio); 168 169 return 0; 170} 171 172/* --- 4 unchanged lines hidden (view full) --- 177 * 178 */ 179int 180ksched_setscheduler(struct ksched *ksched, 181 struct thread *td, int policy, const struct sched_param *param) 182{ 183 int e = 0; 184 struct rtprio rtp; |
185#ifdef KSE |
|
177 struct ksegrp *kg = td->td_ksegrp; | 186 struct ksegrp *kg = td->td_ksegrp; |
187#endif |
|
178 179 switch(policy) 180 { 181 case SCHED_RR: 182 case SCHED_FIFO: 183 184 if (param->sched_priority >= P1B_PRIO_MIN && 185 param->sched_priority <= P1B_PRIO_MAX) 186 { 187 rtp.prio = p4prio_to_rtpprio(param->sched_priority); 188 rtp.type = (policy == SCHED_FIFO) 189 ? RTP_PRIO_FIFO : RTP_PRIO_REALTIME; 190 191 mtx_lock_spin(&sched_lock); | 188 189 switch(policy) 190 { 191 case SCHED_RR: 192 case SCHED_FIFO: 193 194 if (param->sched_priority >= P1B_PRIO_MIN && 195 param->sched_priority <= P1B_PRIO_MAX) 196 { 197 rtp.prio = p4prio_to_rtpprio(param->sched_priority); 198 rtp.type = (policy == SCHED_FIFO) 199 ? RTP_PRIO_FIFO : RTP_PRIO_REALTIME; 200 201 mtx_lock_spin(&sched_lock); |
202#ifdef KSE |
|
192 rtp_to_pri(&rtp, kg); 193 FOREACH_THREAD_IN_GROUP(kg, td) { /* XXXKSE */ 194 if (TD_IS_RUNNING(td)) { 195 td->td_flags |= TDF_NEEDRESCHED; 196 } else if (TD_ON_RUNQ(td)) { 197 if (td->td_priority > kg->kg_user_pri) { 198 sched_prio(td, kg->kg_user_pri); 199 } 200 } 201 } | 203 rtp_to_pri(&rtp, kg); 204 FOREACH_THREAD_IN_GROUP(kg, td) { /* XXXKSE */ 205 if (TD_IS_RUNNING(td)) { 206 td->td_flags |= TDF_NEEDRESCHED; 207 } else if (TD_ON_RUNQ(td)) { 208 if (td->td_priority > kg->kg_user_pri) { 209 sched_prio(td, kg->kg_user_pri); 210 } 211 } 212 } |
213#else 214 rtp_to_pri(&rtp, td); 215#endif |
|
202 mtx_unlock_spin(&sched_lock); 203 } 204 else 205 e = EPERM; 206 207 208 break; 209 210 case SCHED_OTHER: 211 { 212 rtp.type = RTP_PRIO_NORMAL; 213 rtp.prio = p4prio_to_rtpprio(param->sched_priority); 214 mtx_lock_spin(&sched_lock); | 216 mtx_unlock_spin(&sched_lock); 217 } 218 else 219 e = EPERM; 220 221 222 break; 223 224 case SCHED_OTHER: 225 { 226 rtp.type = RTP_PRIO_NORMAL; 227 rtp.prio = p4prio_to_rtpprio(param->sched_priority); 228 mtx_lock_spin(&sched_lock); |
229#ifdef KSE |
|
215 rtp_to_pri(&rtp, kg); 216 217 /* XXX Simply revert to whatever we had for last 218 * normal scheduler priorities. 219 * This puts a requirement 220 * on the scheduling code: You must leave the 221 * scheduling info alone. 222 */ 223 FOREACH_THREAD_IN_GROUP(kg, td) { 224 if (TD_IS_RUNNING(td)) { 225 td->td_flags |= TDF_NEEDRESCHED; 226 } else if (TD_ON_RUNQ(td)) { 227 if (td->td_priority > kg->kg_user_pri) { 228 sched_prio(td, kg->kg_user_pri); 229 } 230 } 231 232 } | 230 rtp_to_pri(&rtp, kg); 231 232 /* XXX Simply revert to whatever we had for last 233 * normal scheduler priorities. 234 * This puts a requirement 235 * on the scheduling code: You must leave the 236 * scheduling info alone. 237 */ 238 FOREACH_THREAD_IN_GROUP(kg, td) { 239 if (TD_IS_RUNNING(td)) { 240 td->td_flags |= TDF_NEEDRESCHED; 241 } else if (TD_ON_RUNQ(td)) { 242 if (td->td_priority > kg->kg_user_pri) { 243 sched_prio(td, kg->kg_user_pri); 244 } 245 } 246 247 } |
248#else 249 rtp_to_pri(&rtp, td); 250#endif |
|
233 mtx_unlock_spin(&sched_lock); 234 } 235 break; 236 237 default: 238 e = EINVAL; 239 break; 240 } --- 73 unchanged lines hidden --- | 251 mtx_unlock_spin(&sched_lock); 252 } 253 break; 254 255 default: 256 e = EINVAL; 257 break; 258 } --- 73 unchanged lines hidden --- |