Question

I'm trying to change the scheduling scheme of running threads in freeBSD. The default thread scheduling of freeBSD is based on the thread's priority but I want to change it to another condition. I was wondering which of the following functions are responsible for this scheduling, tdq_runq_add() in sched_ule.c or runq_choose() in kern_switch.c.

Was it helpful?

Solution 2

The answer to this question was changing the function runq_choose(). Because this functions shows exactly how the threads should be chosen to be put in the running queue. The other function just makes sure that the whole queuing process is being done. The 'tdq_runq_add()' is used to handle the cooperation between time sharing and realtime queues. Thus for changing the priority, we'd better to change the runq_choose().

OTHER TIPS

Selecting the tread that will be run next is done in choosethread() in /usr/src/sys/kern/kern_switch.c. This in turn calls sched_choose(). Depending on which scheduler you're using, this is in /usr/src/sys/kern/sched_4bsd.c (for the old scheduler) or /usr/src/sys/kern/sched_ule.c (the ULE scheduler, which is the default now).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top