1. Cpu Core에 process 할당 : 특정 Process를 특정 CPU에서 실행되도록 설정
BOOL SetProcessAffinityMask(
HANDLE hProcess,
DWORD_PTR dwProcessAffinityMask
);
2. Cpu Core에 Thread 할당 : 특정 Thread를 특정 CPU에서 실행되도록 설정
DWORD_PTR SetThreadAffinityMask(
HANDLE hThread,
DWORD_PTR dwThreadAffinityMask
);
주의 사항
2번째 인자 DWORD_PTR은 2의 제곱근으로 동작 = Bit로 계산되어 동작
CPU 0에 할당 시 : 1 또는 1 << 0
CPU 1에 할당 시 : 2 또는 1 << 1
CPU 2에 할당 시 : 4 또는 1 << 2
참고 자료 1 : docs.microsoft.com/en-us/windows/win32/procthread/multiple-processors
Multiple Processors - Win32 apps
Multiple Processors In this article --> Computers with multiple processors are typically designed for one of two architectures: non-uniform memory access (NUMA) or symmetric multiprocessing (SMP). In a NUMA computer, each processor is closer to some parts
docs.microsoft.com
참고 자료 2 : docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-setprocessaffinitymask
SetProcessAffinityMask function (winbase.h) - Win32 apps
Sets a processor affinity mask for the threads of the specified process.
docs.microsoft.com
참고 자료 3 : docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-setthreadaffinitymask
SetThreadAffinityMask function (winbase.h) - Win32 apps
Sets a processor affinity mask for the specified thread.
docs.microsoft.com
참고 자료 4 : www.jiniya.net/wp/archives/7647
스레드 고급 활용법: 우선순위, 친화도, TLS, APC | 괴짜 프로그래머의 일상사~
스레드 고급 활용법: 우선순위, 친화도, TLS, APC by 신영진(YoungJin Shin), codewiz at gmail.com, @codemaru, http://www.jiniya.net 스레드 우선 순위(Thread Priority) 윈도우 스케줄러는 상대적인 우선순위에 따라서 스
www.jiniya.net
'Programming > Windows' 카테고리의 다른 글
파일명 다루기[2] - PowerShell (0) | 2020.08.07 |
---|---|
파일명 다루기[1] - 명령 프롬프트(cmd) (0) | 2020.08.06 |
Memory Mapped File (MMF) (0) | 2020.07.14 |