MCPcopy Create free account
hub / github.com/F-Stack/f-stack / runq_choose_fuzz

Function runq_choose_fuzz

freebsd/kern/kern_switch.c:430–467  ·  view source on GitHub ↗

* Find the highest priority process on the run queue. */

Source from the content-addressed store, hash-verified

428 * Find the highest priority process on the run queue.
429 */
430struct thread *
431runq_choose_fuzz(struct runq *rq, int fuzz)
432{
433 struct rqhead *rqh;
434 struct thread *td;
435 int pri;
436
437 while ((pri = runq_findbit(rq)) != -1) {
438 rqh = &rq->rq_queues[pri];
439 /* fuzz == 1 is normal.. 0 or less are ignored */
440 if (fuzz > 1) {
441 /*
442 * In the first couple of entries, check if
443 * there is one for our CPU as a preference.
444 */
445 int count = fuzz;
446 int cpu = PCPU_GET(cpuid);
447 struct thread *td2;
448 td2 = td = TAILQ_FIRST(rqh);
449
450 while (count-- && td2) {
451 if (td2->td_lastcpu == cpu) {
452 td = td2;
453 break;
454 }
455 td2 = TAILQ_NEXT(td2, td_runq);
456 }
457 } else
458 td = TAILQ_FIRST(rqh);
459 KASSERT(td != NULL, ("runq_choose_fuzz: no proc on busy queue"));
460 CTR3(KTR_RUNQ,
461 "runq_choose_fuzz: pri=%d thread=%p rqh=%p", pri, td, rqh);
462 return (td);
463 }
464 CTR1(KTR_RUNQ, "runq_choose_fuzz: idleproc pri=%d", pri);
465
466 return (NULL);
467}
468
469/*
470 * Find the highest priority process on the run queue.

Callers 1

sched_chooseFunction · 0.85

Calls 1

runq_findbitFunction · 0.85

Tested by

no test coverage detected