regarding scheduling

I was interested in knowing if the scheduling for CPU time between multiple processes was the same as the scheduling for CPU time between multiple threads of the same process.

To be more precise, if there are p processes running, each running t number of threads, when the scheduler decides which thread gets the CPU next does it take into consideration that another thread from the same process just had the CPU? i.e, does the scheduler try to give preferences to threads from processes that didn’t recently get the CPU.

Round-robin , FIFO etc all scheduling algo s are for threads or process
as there are no priority option for processes

if this is a silly qn… please forgive me :frowning:
Thanks in advance

The scheduler doesn’t know about processes, only about threads.

process is container for threads.
there is no process without threads(process is at least have one thread), so no priority for process.
so scheduling for processes is same as scheduling threads for all processes in system.


if we read this line from wiki ( or from anywhere)

Round-robin (RR) is one of the simplest scheduling algorithms for processes in an operating system,

so i thought that schedular deals with process.

so it means that there is no role of process for schedular? is it not strange?

if schedular knows about process also then might be less context switching is required…

As far as I know there is no preferences given to the next thread being in the same process as the current thread or not. There is no mention of that in the documentation. However when switching from threads in the same processes the kernel used a different code path (faster) then when switching from threads that are not in the same process.

There are some operating systems for which there is a hierarchy for scheduling. The scheduler would first check for the highest priority process, and then schedule based on the thread priority within that process. I don’t think that makes much sense for a real time system like QNX. What if I process had two threads, one which needs to run at a higher priority than any other application thread, and one which should run lower than any other application thread? You could not do it without splitting the two threads into two processes. But this type of division of labor is not uncommon for QNX.

Consider this Koan for a second. If a (QNX) system is using round-robin scheduling, and it is working the way round-robin is defined, then it is probably not working.

thanks to all :slight_smile: