I am trying to hack the Linux kernel and I am wondering. How can I change the default Linux Process scheduler with another one? And can I just set every processes as a real time process?
This post is a little bit dated, but anyway I hope this can help... I had similar problem and I implemented a hack to Linux Kernel to make RR the default CPU scheduler. In the end the hack basically changes the shed_fork function, as pointed out in previous comments. Here is the code I made to implement that: https://aelseb.wordpress.com/2016/01/06/change-linux-cpu-default-scheduler/
Here's the relevant diff for the __sched_setscheduler
function in kernel/sched/core.c
in Linux v3.18:
- p->prio = current->normal_prio;
+ /* Lorenzo Nava: force policy to RR */
+ if (p->policy == SCHED_NORMAL) {
+ p->prio = current->normal_prio - NICE_WIDTH -
+ PRIO_TO_NICE(current->static_prio);
+ p->normal_prio = p->prio;
+ p->rt_priority = p->prio;
+ p->policy = SCHED_RR;
+ p->static_prio = NICE_TO_PRIO(0);
+ }
+ /* Lorenzo Nava: force policy of process to RR */
+ if (attr.sched_policy == SCHED_NORMAL) {
+ attr.sched_priority = param->sched_priority -
+ NICE_WIDTH - attr.sched_nice;
+ attr.sched_policy = SCHED_RR;
+ }
+