程序 執行緒優先順序

2021-05-27 01:06:01 字數 2267 閱讀 3880

process priority class

thread priority level

base priority

idle_priority_class

thread_priority_idle

thread_priority_lowest

thread_priority_below_normal

thread_priority_normal

thread_priority_above_normal

thread_priority_highest

thread_priority_time_critical

below_normal_priority_class

thread_priority_idle

thread_priority_lowest

thread_priority_below_normal

thread_priority_normal

thread_priority_above_normal

thread_priority_highest

thread_priority_time_critical

normal_priority_class

thread_priority_idle

thread_priority_lowest

thread_priority_below_normal

thread_priority_normal

thread_priority_above_normal

thread_priority_highest

thread_priority_time_critical

above_normal_priority_class

thread_priority_idle

thread_priority_lowest

thread_priority_below_normal

thread_priority_normal

thread_priority_above_normal

thread_priority_highest

thread_priority_time_critical

high_priority_class

thread_priority_idle

thread_priority_lowest

thread_priority_below_normal

thread_priority_normal

thread_priority_above_normal

thread_priority_highest

thread_priority_time_critical

realtime_priority_class

thread_priority_idle

thread_priority_lowest

thread_priority_below_normal

thread_priority_normal

thread_priority_above_normal

thread_priority_highest

thread_priority_time_critical

//得到當前程序id

dword   dwprocessid   =   getcurrentprocessid();

//得到當前程序控制代碼

handle   hprocess   =   getcurrentprocess();

//提公升程序優先順序

setpriorityclass(hprocess,high_priority_class);

關於優先順序的操作

在程式中,可以獲取和更改程序和執行緒的優先順序。對於程序的優先順序類有如下

函式:

dword   getpriorityclass(handle   hprocess);                 //   hprocess為程序控制代碼

bool   setpriorityclass(hanel   hprocess,   dword   dwpriority);

對執行緒的優先順序有這兩個函式:

int   getthreadpriority(handle   hthread);                     //hthread為執行緒控制代碼

bool   setthreadpriority(handle   hthread,   int   npriority);

多執行緒多程序優先順序理解 優先順序反轉

1.優先順序反轉 priority inversion 由於多程序共享資源,具有最高優先權的程序被低優先順序程序阻塞,反而使具有中優先順序的程序先於高優先順序的程序執行,導致系統的崩潰。這就是所謂的優先順序反轉 priority inversion 2.產生原因 其實,優先順序反轉是在高優級 假設為...

程序優先順序

程序的優先順序可以通過setpriority nice修改優先順序。程序分為普通程序和實時程序。實時程序的優先順序比普通程序的優先順序高。nice的值 20 19值越小優先順序越高。預設為0 不同程序的執行緒優先順序?執行緒會繼承程序的優先順序,核心的排程是執行緒。所以先看程序是普通程序還是實時程序...

程序優先順序

用top或者ps命令會輸出pri pr ni ni nice這三種指標值,這些到底是什麼東西?先給出大概的解釋如下 pri 程序優先權,代表這個程序可被執行的優先順序,其值越小,優先順序就越高,越早被執行 ni 程序nice值,代表這個程序的優先值 nice 改變過優先順序的程序的占用cpu的百分比...