Windows OS provides JobObject to limit the cpu usage of a process, but I’m wondering if the cpu portion takes account of kernel-space cpu usage or it is just user-space cpu usage? The documents doesn’t provides any clue.
>Solution :
Windows Job Objects can limit both user-mode and kernel-mode CPU usage of a process. When a process calls a system function that transitions into kernel mode, the kernel-mode CPU time used by that process is also counted towards its overall CPU usage.
According to Microsoft’s documentation, when you set a CPU rate limit using a Job Object, it applies to "both user-mode CPU time and kernel-mode CPU time that is associated with the process." Therefore, the limit applies to both user-mode and kernel-mode CPU usage.
It is important to note that setting a CPU rate limit using a Job Object is not a precise way to limit CPU usage, since it relies on statistical sampling and the accuracy of the CPU time measurements. In some cases, the actual CPU usage of a process may exceed the limit set by the Job Object due to factors such as system load and context switching.