WINDOWS应用程序中进程优先级的设置

WINDOWS核心编程第7章讲的是线程的调度、优先级和亲缘性,

 

一个优先级设置的核心代码如下:

 

void CSchedLabDlg::setPriorityFun(void)
{

 dwpc = GetPriorityClass(GetCurrentProcess());

 //SetPriorityClass(GetCurrentProcess(),BELOW_NORMAL_PRIORITY_CLASS);
 //SetPriorityClass(GetCurrentProcess(),ABOVE_NORMAL_PRIORITY_CLASS);
 //SetPriorityClass(GetCurrentProcess(),IDLE_PRIORITY_CLASS);
 SetPriorityClass(GetCurrentProcess(),HIGH_PRIORITY_CLASS);

}

 

其中dwpc定义为DWORD类型,指向对应进程的优先级值,
 DWORD dwpc; 

GetPriorityClass定义为全局函数,返回进程的优先级;

The GetPriorityClass function retrieves the priority class for the specified process.

This value, together with the priority value of each thread of the process,

determines each thread's base priority level.

DWORD GetPriorityClass(
  HANDLE hProcess
);
GetCurrentProcess()函数返回当前进程。
SetPriorityClass()函数设置当前进程的优先级。

你可能感兴趣的:(windows,class,thread,each,function,编程)