原创 WINDOWS应用程序中进程优先级的设置收藏

新一篇: 枚举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()函数设置当前进程的优先级。

发表于 @ 2006年12月24日 20:22:00|评论(loading...)|编辑

新一篇: 枚举WINDOWS进程和线程的创建、挂起、唤醒操作 | 旧一篇: 金堂的味道

评论:没有评论。

发表评论  


当前用户设置只有注册用户才能发表评论。如果你没有登录,请点击登录
Csdn Blog version 3.1a
Copyright © buxiangshui_cd