I recently started reading Robert Love's book "Linux Kernel Development 3rd edition" and dived into the scheduler part, which left me with lots of questions.
So first off, I understood there are 2 cases where the scheduler changes the task that currently runs (Correct me if I'm not precise), either by a task that willingly requested to re-schedule since it blocks on some I/O or sleeps, or a timer interrupt that caused the cpu to jump to scheduler code and preempt the current task if it's interruptible.
Does each core in a multicore processor get the interrupt that is related to re-scheduling? Do they each have a different timer, or say there is one interrupt that in some type of algorithm picks a specific core to handle it each time?
Assuming not only one core re-schedules each interrupt (since then I would imagine it might take a while to swap processes on all of the cores), what happens if two cores re-schedule at the same time? Because, I assume that when you run the schedule function the task-list must be locked, and then I'd imagine a few cores re-scheduling their current task simultaneously resulting in only one core actually doing scheduling work and all of the other cores waiting on the task-list lock.
Not only that the task-list lock is required to touch the actual task-list and say change tasks state or run-queue order, what if one core that schedules currently calculates which task should be run next and meanwhile another core finishes scheduling successfully which causes the first core calculation to be totally mistaken since the successful re-scheduling just heavily changed the system state?
I understood that in linux priority is divided to "nice value" which is -20 to 19 (higher means less priority and more "nice") and real-time priority (0-99). real-time priority values matter only for a couple of scheduling policies, and each process can register to a different scheduling policy. Does the real-time policies always beat processes that are not registered to real-time policies? Meaning if I run a real-time process I will never get to execute normal processes? How are the "nice" values of normal processes and real-time priority values of real-time processes work together in the scheduler algorithm?