1
我按照給出的例子here。雖然我能夠成功創建線程,但這些線程對所有進程都具有默認關聯。如何在Windows中的私人管理池中設置線程優先級?
如何設置親和力?有人可以提供一個例子,我如何使用SetThreadAffinityMask和上面的鏈接給出的例子?
我按照給出的例子here。雖然我能夠成功創建線程,但這些線程對所有進程都具有默認關聯。如何在Windows中的私人管理池中設置線程優先級?
如何設置親和力?有人可以提供一個例子,我如何使用SetThreadAffinityMask和上面的鏈接給出的例子?
好吧,我要假設你想要親和力。 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);
那麼你想要親和力還是優先權? – Tudor 2011-12-17 10:43:59