I read wikipedia about process scheduler:

The process scheduler is a part of the operating system that decides which process runs at a certain point in time.

I don't really understand what that means. What is a process scheduler in Linux? Is it part of the kernel? What exactly does it do?

up vote 1 down vote accepted

In Linux, the process scheduler is a core part of the kernel. It doesn’t exist as a separate thread, or module, it’s implemented as a function, __schedule().

The job of the process scheduler is to decide which process should run next. Each processor in the system has a runqueue, which is the list of processes which are waiting to run on the CPU. When it’s invoked, the scheduler looks at this list of processes, and decides which one to run next; this can be the process (or rather, thread) which was running previously, or it could be another one. Various other systems in the kernel add and remove tasks from the runqueue, or move them from one CPU’s runqueue to another.

The kernel will reschedule processes in a number of circumstances: whenever a process is blocked (by a semaphore, mutex etc.), and whenever a reschedule has been requested and the system transitions from userspace to the kernel or back. The timer tick doesn’t directly invoke the scheduler, it requests a reschedule.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.