Writing a scheduler

Hi, I'm trying to write my own custom scheduler.

I'm having trouble knowing where to declare my code and what's the best way to "stick it into the kernel".

1. I have a global: custom_scheduler = 0, which the user can toggle
2. in kern/kern_switch.c:
Code:
runq_choose() {
...
  if(custom_scheduler)
     return my_scheduler(rq);
...
}

What's the best way to include my function my_scheduler(struct runq* rq)? Can I create a kld module? Or must I #include <kern/my_scheduler.c> or something along those lines?

Sorry for such a dumb question, but I'm just starting with freebsd development.

Thanks!
 
Questions concerning the low level implementation of the kernel are better addressed at the hackers mailing list. I'll give you enough to get you started though.

Take a look at /sys/kern/sched_4bsd.c and /sys/kern/sched_ule.c

These are the two schedulers you 'll find in fbsd, ule is used by default. grep the code in /sys/kern with the right keyword and perhaps you 'll find your answer alone before someone just hands it to you.

Good luck!
 
I don't understand

Hi,

can you tell me what's wrong with justint's solution for implementing the new scheduler if we change all runq_choose functions?
 
how to call syscall in kernel

Hello,
I have another question.
I want to change the ule scheduler a little.
for this purpose I decided to call a lkm(syscall) in tdq_choose function in sched_ule.c file and implement my code in that module.
Is that correct to do call a lkm in kernel?
If yes, how can I call the module?
I used syscall(syscall_num,...) it has compile error and the error is:
Code:
usr/src/sys/kern/sched_ule.c:1233: warning: implicit declaration of function 'syscall'

can anyone help me how to fix the problem?
thanks.
 
I think, we can open, exit, fork and other syscalls in kernel, don't we?

I don't know how we should call a syscall(lkm) in kernel codes?
 
Back
Top