C# 设置使用单个cpu

时间:2024-10-12 04:26:57

1、首先,实现方法进程与指定cpu绑定 :SetProcessAffinityMask(GetCurrentProcess(),dwMask);

C# 设置使用单个cpu

2、线程与指定cpu绑定: SetThreadAffinityMask(GetCurrentThread(),dwMask);dwMask为CPU序号的或运算值:1(0001)

C# 设置使用单个cpu

3、代表只运行在CPU1,2(0010)代表只运行在CPU2,3(0011)代表可以运行在CPU1和CPU2 ,以此类推。

C# 设置使用单个cpu

4、设置之溱碳叛鹤前最好判断一下系统有几个CPU: SYSTEM_INFOSystemInfo; GetSystemInfo(&SystemInfo);CPU个数:SystemInfo.dwNumberOfProcessors

C# 设置使用单个cpu

5、当前启用的CPU序号: SystemInfo.dwActiveProcessorMask ,Mask representing the set of processors configured into the system. Bit 0 is processor 0;bit 31 is processor 31.

C# 设置使用单个cpu
© 手抄报圈