C++11的线程类,创建的线程,如何设置优先级?

更新时间:2023-05-15 12:01:14 阅读: 评论:0

C++11的线程类,创建的线程,如何设置优先级?
SetThreadPriority
The SetThreadPriority function ts the priority value for the specified thread. This value, together with the priority class of the thread's process, determines the thread's ba priority level.
BOOL SetThreadPriority(
HANDLE hThread, // handle to the thread学生会竞选部长演讲稿
int nPriority  // thread priority level
);
青春寄语Parameters
hThread
燕麦牛奶粥
Handle to the thread who priority value is to be t.
Windows NT: The handle must have the THREAD_SET_INFORMATION access right associated with it.
nPriority平塔岛象龟
Specifies the priority value for the thread. This parameter can be one of the following values: Priority Meaning
THREAD_PRIORITY_ABOVE_NORMAL Indicates 1 point above normal priority for the priority class.
THREAD_PRIORITY_BELOW_NORMAL Indicates 1 point below normal priority for the priority class.
THREAD_PRIORITY_HIGHEST Indicates 2 points above normal priority for the priority class.
THREAD_PRIORITY_IDLE Indicates a ba priority level of 1 for IDLE_PRIORITY_CLASS, NORMAL_PRIORITY_CLASS, or HIGH_PRIORITY_CLASS process, and a ba priority level of 16 for REALTIME_PRIORITY_CLA THREAD_PRIORITY_LOWEST Indicates 2 points below normal priority for the priority class.
THREAD_PRIORITY_NORMAL Indicates normal priority for the priority class.
THREAD_PRIORITY_TIME_CRITICAL Indicates a ba priority level of 15 for IDLE_PRIORITY_CLASS, NORMAL_PRIORITY_CLASS, or HIGH_PRIORITY_CLASS process, and a ba priority level of 31 for REALTIME_PR
武汉旅行攻略Return Values
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
Remarks
香蕉奶昔怎么做Every thread has a ba priority level determined by the thread's priority value and the priority class of its process. The system us the ba priority level of all executable threads to determine which thread gets the next slice robin fashion at each priority level, and only when there are no executable threads at a higher level does scheduling of threads at a lower level take place.
浮光掠影什么意思The SetThreadPriority function enables tting the ba priority level of a thread relative to the priorit
y class of its process. For example, specifying THREAD_PRIORITY_HIGHEST in a call to SetThreadPriority for a thread of a For IDLE_PRIORITY_CLASS, NORMAL_PRIORITY_CLASS, and HIGH_PRIORITY_CLASS process, the system dynamically boosts a thread's ba priority level when events occur that are important to the thread. REALTIM All threads initially start at THREAD_PRIORITY_NORMAL. U the GetPriorityClass and SetPriorityClass functions to get and t the priority class of a process. U the GetThreadPriority function to get the priority value of a th U the priority class of a process to differentiate between applications that are time critical and tho that have normal or below normal scheduling requirements. U thread priority values to differentiate the relative priorities
When manipulating priorities, be very careful to ensure that a high-
priority thread does not consume all of the available CPU time. A thread with a ba priority level above 11 interferes with the normal operation of the operating system. Using REALTIME_PRIORITY_CLASS may cau disk ca
Windows CE: The thread's priority level is one of the following values:
THREAD_PRIORITY_TIME_CRITICAL
Indicates 3 points above normal priority.曲靖旅游景点
THREAD_PRIORITY_HIGHEST
Indicates 2 points above normal priority.
THREAD_PRIORITY_ABOVE_NORMAL
Indicates 1 point above normal priority.
THREAD_PRIORITY_NORMAL
Indicates normal priority.
THREAD_PRIORITY_BELOW_NORMAL
Indicates 1 point below normal priority.
THREAD_PRIORITY_LOWEST
Indicates 2 points below normal priority.
THREAD_PRIORITY_ABOVE_IDLE
Indicates 3 points below normal priority.
THREAD_PRIORITY_IDLE
Indicates 4 points below normal priority.
Windows CE does not support priority class. The order in which threads are scheduled is determined only by their thread priorities.
When manipulating priorities, ensure that a high-
priority thread does not consume all of the available CPU time. A thread with a priority level of THREAD_PRIORITY_TIME_CRITICAL will execute until it explicitly yields processing to other threads. Processing of the threads
QuickInfo
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Requires version 1.0 or later.
Header: Declared in winba.h.
Import Library: U kernel32.lib.
See Also
Process and Threads Overview, Process and Thread Functions, GetPriorityClass, GetThreadPriority, SetPriorityClass

本文发布于:2023-05-15 12:01:14,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/82/640370.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:线程   部长   武汉   青春
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图