Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/155.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何在Windows的私有管理池中设置线程优先级?_C++_Windows_Multithreading_Threadpool - Fatal编程技术网

C++ 如何在Windows的私有管理池中设置线程优先级?

C++ 如何在Windows的私有管理池中设置线程优先级?,c++,windows,multithreading,threadpool,C++,Windows,Multithreading,Threadpool,我将遵循所给出的示例。虽然我能够成功地创建线程,但这些线程对所有进程都具有默认的关联性 如何设置关联?有人可以提供一个关于如何使用SetThreadAffinityMask的例子,以及上面链接中给出的例子吗?好的,我假设您需要affinity。SetThreadAffinityMask的第二个参数是一个位掩码,表示允许线程在哪个处理器上运行。在相应的处理器上,位被设置为1。例如: // binary 01, so it allows this thread to run on CPU 0 Set

我将遵循所给出的示例。虽然我能够成功地创建线程,但这些线程对所有进程都具有默认的关联性


如何设置关联?有人可以提供一个关于如何使用SetThreadAffinityMask的例子,以及上面链接中给出的例子吗?

好的,我假设您需要affinity。
SetThreadAffinityMask
的第二个参数是一个位掩码,表示允许线程在哪个处理器上运行。在相应的处理器上,位被设置为1。例如:

// binary 01, so it allows this thread to run on CPU 0
SetThreadAffinityMask(hThread, 0x01); 
// binary 10, so it allows this thread to run on CPU 1
SetThreadAffinityMask(hThread, 0x02); 
// binary 11, so it allows this thread to run on CPU 0 or CPU 1
SetThreadAffinityMask(hThread, 0x03); 

好吧,我假设你想要亲和力。
SetThreadAffinityMask
的第二个参数是一个位掩码,表示允许线程在哪个处理器上运行。在相应的处理器上,位被设置为1。例如:

// binary 01, so it allows this thread to run on CPU 0
SetThreadAffinityMask(hThread, 0x01); 
// binary 10, so it allows this thread to run on CPU 1
SetThreadAffinityMask(hThread, 0x02); 
// binary 11, so it allows this thread to run on CPU 0 or CPU 1
SetThreadAffinityMask(hThread, 0x03); 

那么你想要亲和力还是优先权?那么你想要亲和力还是优先权?