当前位置:网站首页>LabVIEW中编程更改进程的优先级
LabVIEW中编程更改进程的优先级
2022-07-27 00:03:00 【LabVIEW开发】
LabVIEW中编程更改进程的优先级
在labVIEW中可以调用kernel32动态链接库来更改进程的优先级。需要两个函数:GetCurrentProcess()和SetPriorityClass()。
有6个优先级可供选择,这6个优先级及其标识码列表如下:
空闲(IDLE): IDLE_PRIORITY_CLASS
次低(BELOWNORMAL): BELOW_NORMAL_PRIORITY_CLASS
普通(NORMAL): NORMAL_PRIORITY_CLASS
次高(ABOVENORMAL): ABOVE_NORMAL_PRIORITY_CLASS
高级(HIGHPRIORITY): HIGH_PRIORITY_CLASS
实时(REALTIME): REALTIME_PRIORITY_CLASS
在LabVIEW中,首先建立一个调用库函数节点,并指向kernel32.dll(一般位于c:\windows\system32)。建立调用后函数原型的样子为:
unsigned longGetCurrentProcess(void)
因为这是调用了Windows的API函数,调用方式改为stdcall(WINAPI)。第二个调用库函数VI与第一个相似,除了使用SetPriorityClass函数。建立第二个调用库函数节点后函数原型的样子为:
unsigned longSetPriorityClass(unsigned long handle, unsigned long priority)
同样的,调用方式改为stdcall(WINAPI)。 GetPriorityClass函数的返回值与SetPriorityClass函数的句柄相关,相应的优先级类型是十六进制 (hex)。在winbase.h文件中(包含在Microsoft的WIN32 SDK中),可以找到定义优先级的声明。它们是:
#defineIDLE_PRIORITY_CLASS 0x00000040
#defineBELOW_NORMAL_PRIORITY_CLASS 0x00004000
#define NORMAL_PRIORITY_CLASS0x00000020
#defineABOVE_NORMAL_PRIORITY_CLASS 0x00008000
#defineHIGH_PRIORITY_CLASS 0x00000080
#defineREALTIME_PRIORITY_CLASS 0x00000100
使用这些值,可以指定线程的优先级。举例来说,如果想把进程的优先级设置为空闲(IDLE),只要在调用库函数节点的输入端连上一个十六进制值为40的常数就好了。
打开、运行附件中的例子。运行例子的时候,打开Windows的任务管理器,在更改LabVIEW程序的优先级的时候可以观察LabVIEW优先级的状态。

编辑
添加图片注释,不超过 140 字(可选)
LabVIEW、LabVIEW开发、LabVIEW编程、LabVIEW程序
上文中提到的例子和资料,均在word中的附件里,可点击下载。进一步了解,可联系我们。
LabVIEW中编程更改进程的优先级 - 北京瀚文网星科技有限公司 (bjcyck.com)
边栏推荐
- Okaleido tiger is about to log in to binance NFT in the second round, which has aroused heated discussion in the community
- 万字长文,带你搞懂 Kubernetes 网络模型
- iNFTnews | GGAC联合中国航天ASES 独家出品《中国2065典藏版》
- 软件测试相关试题知识点
- Why do people like to rank things
- c语言:深度学习递归
- Talk about the metrics of automated testing
- FormData的使用
- Time module: acquisition and mutual transformation of timestamp, structured time and formatted time
- 【无标题】
猜你喜欢
随机推荐
If you want to thoroughly optimize the performance, you must first understand the underlying logic~
After ten years of testing, I want to say to my friends who are still confused: one thing is to do a good job in personal planning
Lua函数之非全局函数
cookie增删改查方法
Talk about connection pools and threads
Which securities firm is safer to open an account and buy REITs funds?
FormData的使用
文章主要内容提取软件[基于NLP技术]
Goatgui invites you to attend a machine learning seminar
CuteOne:一款OneDrive多网盘挂载程序/带会员/同步等功能
银河证券基金低佣金开户靠谱吗,可靠安全吗
Leetcode- > binary search clock in
Debezium系列之:记录从库服务器挂掉后binlog文件无法恢复,任务切换到主库并保证数据不丢失的方法
static关键字
关于序列化变量保存的坑,加了索引器的数据不能序列化
Static keyword
Mysql 5.7 取分组第一条
砺夏行动|源启数字化:既有模式,还是开源创新?
Pyqt5 use pyqtgraph to draw dynamic scatter chart
Time module: acquisition and mutual transformation of timestamp, structured time and formatted time








