Question

Imagine that you have a Windows process A running with priority AboveNormal that starts another process B without specify the priority. Is the priority of the process B inherited from the priority of the process A? So, what will be the priority on the process B? AboveNormal, Normal, or another?

Was it helpful?

Solution

If not specified, the priority class is inherited, in some cases.

It occurs when the calling process is in the IDLE_PRIORITY_CLASS or BELOW_NORMAL_PRIORITY class. Otherwise, it gets NORMAL_PRIORITY_CLASS unless specified during the CreateProcess call.

MSDN says on dwCreationFlags of CreateProcess:

This parameter also controls the new process's priority class, which is used to determine the scheduling priorities of the process's threads. For a list of values, see GetPriorityClass. If none of the priority class flags is specified, the priority class defaults to NORMAL_PRIORITY_CLASS unless the priority class of the creating process is IDLE_PRIORITY_CLASS or BELOW_NORMAL_PRIORITY_CLASS. In this case, the child process receives the default priority class of the calling process.

The answer is therefore NORMAL priority class. Basically anything that is above normal doesn't get passed to the child.

OTHER TIPS

From the documentation for CreateProcess:

dwCreationFlags [in]

The flags that control the priority class and the creation of the process. For a list of values, see Process Creation Flags.

This parameter also controls the new process's priority class, which is used to determine the scheduling priorities of the process's threads. For a list of values, see GetPriorityClass. If none of the priority class flags is specified, the priority class defaults to NORMAL_PRIORITY_CLASS unless the priority class of the creating process is IDLE_PRIORITY_CLASS or BELOW_NORMAL_PRIORITY_CLASS. In this case, the child process receives the default priority class of the calling process.

So, in your example, the new process would have normal priority.

In Windows process priority is not inherited.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top