views:

150

answers:

4

Hi, imagine that you have a 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?

A: 

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.

Chris Smith
A: 

In Windows process priority is not inherited.

Assaf Lavie
A: 

In Windows the priority class is inherited, in contrast to the other response. Don't believe me? Try yourself. I used to assume it surely wasn't inherited, but it is. I just tested again, to verify what I already knew.

Jeremy Collake
A: 

Please note the accepted answer is wrong, as priorities ARE INHERITED unless they are specified during CreateProcess. The MSDN docs quote says this at the end too. It just bothers me a wrong answer is picked ;)

Jeremy Collake