0

As my understanding, on a Linux system (x86_64 architecture), any process is scheduled by the kernel. But I don't quite understand how it works.

Saying a very simple process, which does nothing but run only an infinite loop, this loop has no business with any I/O action. Would this process be scheduled by the kernel too? Does it mean that the kernel may not give its the CPU time so that it has to be stopped for a very short time and the user hardly feels this kind of stop?

If I'm right, my question is if there is a way to allow a programmer to control the scheduling strategy?

Saying that I have a process, after running it, the kernel may schedule it so that it may not use the CPU for a while (am I right?). Is there a method to force my process to be able to use the CPU continuously?

Yves
  • 11,597
  • 17
  • 83
  • 180
  • 1
    https://stackoverflow.com/questions/8887531/which-real-time-priority-is-the-highest-priority-in-linux https://lwn.net/Articles/296419/ – Ujjwal Mishra Feb 14 '20 at 01:53
  • If there are any idle cores, your process won't ever sleep for any human-perceptible amount of time. It might even migrate if an interrupt handler takes over the core it had been running on for too long. You can use taskset to set CPU affinity to control that, and/or scheduling class and priority / nice level for other controls. – Peter Cordes Feb 14 '20 at 02:04
  • @PeterCordes A custom linux system, such as Ubuntu, has many system-level processes, so I think on a personal PC with 4 cores, there is no idle cores, right? – Yves Feb 14 '20 at 02:44
  • 1
    All the daemons that start at bootup sleep most of the time, normally waiting for activity of a file descriptor. If your load average is below your number of cores, you have idle cores. (Run `uptime` or `top`) – Peter Cordes Feb 14 '20 at 02:46

0 Answers0