The only way an user space application can explicitly initiate a switch to kernel mode during normal operation is by making an system call such as open, read, write etc.
Whenever a user application calls these system call APIs with appropriate parameters, a software interrupt/exception(SWI) is triggered.
As a result of this SWI, the control of the code execution jumps from the user application to a predefined location in the Interrupt Vector Table [IVT] provided by the OS.
This IVT contains an adress for the SWI exception handler routine, which performs all the necessary steps required to switch the user application to kernel mode and start executing kernel instructions on behalf of user process.
Useful link: https://stackoverflow.com/questions/11905934/how-to-switch-from-user-mode-to-kernel-mode
It uses Red black tree.
Priority is based on nice, number of processes running in the machine
Nice -> A factor to decide the priority
vruntime is used to select the one which process should get next CPX. Once a process qualifies for running, it will get fixed timeslice defined by RR_TIMESLICE. --> https://stackoverflow.com/questions/16401294/how-to-know-linux-scheduler-time-slice
Change Nice -> https://www.nixtutor.com/linux/changing-priority-on-linux-processes/
struct sched_entity - https://elixir.bootlin.com/linux/v4.4.57/source/include/linux/sched.h#L1246
Update_curr -> https://elixir.bootlin.com/linux/v4.4.57/source/kernel/sched/fair.c#L699
Reference:
https://elixir.bootlin.com/linux/v4.4.57/source/include/linux/sched.h#L1246
https://elixir.bootlin.com/linux/v4.4.57/source/kernel/sched/fair.c#L699
https://stackoverflow.com/questions/39725102/how-linux-process-scheduler-prevents-starvation-of-a-process