kern_switch.c (134417) | kern_switch.c (134586) |
---|---|
1/* 2 * Copyright (c) 2001 Jake Burkholder <jake@FreeBSD.org> 3 * 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 --- 72 unchanged lines hidden (view full) --- 81 82The result of this scheme is that the M available KSEs are always 83queued at the priorities they have inherrited from the M highest priority 84threads for that KSEGROUP. If this situation changes, the KSEs are 85reassigned to keep this true. 86***/ 87 88#include <sys/cdefs.h> | 1/* 2 * Copyright (c) 2001 Jake Burkholder <jake@FreeBSD.org> 3 * 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 --- 72 unchanged lines hidden (view full) --- 81 82The result of this scheme is that the M available KSEs are always 83queued at the priorities they have inherrited from the M highest priority 84threads for that KSEGROUP. If this situation changes, the KSEs are 85reassigned to keep this true. 86***/ 87 88#include <sys/cdefs.h> |
89__FBSDID("$FreeBSD: head/sys/kern/kern_switch.c 134417 2004-08-28 01:04:44Z peter $"); | 89__FBSDID("$FreeBSD: head/sys/kern/kern_switch.c 134586 2004-09-01 02:11:28Z julian $"); |
90 91#include "opt_full_preemption.h" 92 93#include <sys/param.h> 94#include <sys/systm.h> 95#include <sys/kdb.h> 96#include <sys/kernel.h> 97#include <sys/ktr.h> --- 111 unchanged lines hidden (view full) --- 209 /* 210 * If we found one, assign it the kse, otherwise idle the kse. 211 */ 212 if (td) { 213 kg->kg_last_assigned = td; 214 td->td_kse = ke; 215 ke->ke_thread = td; 216 CTR2(KTR_RUNQ, "kse_reassign: ke%p -> td%p", ke, td); | 90 91#include "opt_full_preemption.h" 92 93#include <sys/param.h> 94#include <sys/systm.h> 95#include <sys/kdb.h> 96#include <sys/kernel.h> 97#include <sys/ktr.h> --- 111 unchanged lines hidden (view full) --- 209 /* 210 * If we found one, assign it the kse, otherwise idle the kse. 211 */ 212 if (td) { 213 kg->kg_last_assigned = td; 214 td->td_kse = ke; 215 ke->ke_thread = td; 216 CTR2(KTR_RUNQ, "kse_reassign: ke%p -> td%p", ke, td); |
217 sched_add(td); | 217 sched_add(td, SRQ_BORING); |
218 return; 219 } 220 221 ke->ke_state = KES_IDLE; 222 ke->ke_thread = NULL; 223 TAILQ_INSERT_TAIL(&kg->kg_iq, ke, ke_kgrlist); 224 kg->kg_idle_kses++; 225 CTR1(KTR_RUNQ, "kse_reassign: ke%p on idle queue", ke); --- 67 unchanged lines hidden (view full) --- 293 /* 294 * If it is not a threaded process, take the shortcut. 295 */ 296 if ((td->td_proc->p_flag & P_SA) == 0) { 297 /* We only care about the kse in the run queue. */ 298 td->td_priority = newpri; 299 if (ke->ke_rqindex != (newpri / RQ_PPQ)) { 300 sched_rem(td); | 218 return; 219 } 220 221 ke->ke_state = KES_IDLE; 222 ke->ke_thread = NULL; 223 TAILQ_INSERT_TAIL(&kg->kg_iq, ke, ke_kgrlist); 224 kg->kg_idle_kses++; 225 CTR1(KTR_RUNQ, "kse_reassign: ke%p on idle queue", ke); --- 67 unchanged lines hidden (view full) --- 293 /* 294 * If it is not a threaded process, take the shortcut. 295 */ 296 if ((td->td_proc->p_flag & P_SA) == 0) { 297 /* We only care about the kse in the run queue. */ 298 td->td_priority = newpri; 299 if (ke->ke_rqindex != (newpri / RQ_PPQ)) { 300 sched_rem(td); |
301 sched_add(td); | 301 sched_add(td, SRQ_BORING); |
302 } 303 return; 304 } 305 306 /* It is a threaded process */ 307 kg = td->td_ksegrp; 308 TD_SET_CAN_RUN(td); 309 if (ke) { 310 if (kg->kg_last_assigned == td) { 311 kg->kg_last_assigned = 312 TAILQ_PREV(td, threadqueue, td_runq); 313 } 314 sched_rem(td); 315 } 316 TAILQ_REMOVE(&kg->kg_runq, td, td_runq); 317 kg->kg_runnable--; 318 td->td_priority = newpri; | 302 } 303 return; 304 } 305 306 /* It is a threaded process */ 307 kg = td->td_ksegrp; 308 TD_SET_CAN_RUN(td); 309 if (ke) { 310 if (kg->kg_last_assigned == td) { 311 kg->kg_last_assigned = 312 TAILQ_PREV(td, threadqueue, td_runq); 313 } 314 sched_rem(td); 315 } 316 TAILQ_REMOVE(&kg->kg_runq, td, td_runq); 317 kg->kg_runnable--; 318 td->td_priority = newpri; |
319 setrunqueue(td); | 319 setrunqueue(td, SRQ_BORING); |
320} 321 322void | 320} 321 322void |
323setrunqueue(struct thread *td) | 323setrunqueue(struct thread *td, int flags) |
324{ 325 struct kse *ke; 326 struct ksegrp *kg; 327 struct thread *td2; 328 struct thread *tda; 329 int count; 330 331 CTR4(KTR_RUNQ, "setrunqueue: td:%p ke:%p kg:%p pid:%d", --- 4 unchanged lines hidden (view full) --- 336 TD_SET_RUNQ(td); 337 kg = td->td_ksegrp; 338 if ((td->td_proc->p_flag & P_SA) == 0) { 339 /* 340 * Common path optimisation: Only one of everything 341 * and the KSE is always already attached. 342 * Totally ignore the ksegrp run queue. 343 */ | 324{ 325 struct kse *ke; 326 struct ksegrp *kg; 327 struct thread *td2; 328 struct thread *tda; 329 int count; 330 331 CTR4(KTR_RUNQ, "setrunqueue: td:%p ke:%p kg:%p pid:%d", --- 4 unchanged lines hidden (view full) --- 336 TD_SET_RUNQ(td); 337 kg = td->td_ksegrp; 338 if ((td->td_proc->p_flag & P_SA) == 0) { 339 /* 340 * Common path optimisation: Only one of everything 341 * and the KSE is always already attached. 342 * Totally ignore the ksegrp run queue. 343 */ |
344 sched_add(td); | 344 sched_add(td, flags); |
345 return; 346 } 347 348 tda = kg->kg_last_assigned; 349 if ((ke = td->td_kse) == NULL) { 350 if (kg->kg_idle_kses) { 351 /* 352 * There is a free one so it's ours for the asking.. --- 78 unchanged lines hidden (view full) --- 431 * put the new kse on whatever is next, 432 * which may or may not be us. 433 */ 434 td2 = TAILQ_NEXT(tda, td_runq); 435 kg->kg_last_assigned = td2; 436 td2->td_kse = ke; 437 ke->ke_thread = td2; 438 } | 345 return; 346 } 347 348 tda = kg->kg_last_assigned; 349 if ((ke = td->td_kse) == NULL) { 350 if (kg->kg_idle_kses) { 351 /* 352 * There is a free one so it's ours for the asking.. --- 78 unchanged lines hidden (view full) --- 431 * put the new kse on whatever is next, 432 * which may or may not be us. 433 */ 434 td2 = TAILQ_NEXT(tda, td_runq); 435 kg->kg_last_assigned = td2; 436 td2->td_kse = ke; 437 ke->ke_thread = td2; 438 } |
439 sched_add(ke->ke_thread); | 439 sched_add(ke->ke_thread, flags); |
440 } else { 441 CTR3(KTR_RUNQ, "setrunqueue: held: td%p kg%p pid%d", 442 td, td->td_ksegrp, td->td_proc->p_pid); 443 } 444} 445 446/* 447 * Kernel thread preemption implementation. Critical sections mark --- 394 unchanged lines hidden --- | 440 } else { 441 CTR3(KTR_RUNQ, "setrunqueue: held: td%p kg%p pid%d", 442 td, td->td_ksegrp, td->td_proc->p_pid); 443 } 444} 445 446/* 447 * Kernel thread preemption implementation. Critical sections mark --- 394 unchanged lines hidden --- |