Changeset 3355 for trunk/src/kWorker
- Timestamp:
- Jun 5, 2020, 4:06:42 AM (5 years ago)
- Location:
- trunk/src/kWorker
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kWorker/Makefile.kmk
r3192 r3355 78 78 nt/ntunlink.c \ 79 79 nt/kFsCache.c \ 80 win_get_processor_group_active_mask.c \ 80 81 quote_argv.c \ 81 82 is_console.c \ -
trunk/src/kWorker/kWorker.c
r3347 r3355 55 55 #include "nt/kFsCache.h" 56 56 #include "nt_fullpath.h" 57 #include "win_get_processor_group_active_mask.h" 57 58 #include "quote_argv.h" 58 59 #include "md5.h" … … 12284 12285 12285 12286 12287 /** 12288 * Helper for main() argument handling that sets the processor group if 12289 * possible. 12290 */ 12291 static void kwSetProcessorGroup(unsigned long uGroup) 12292 { 12293 typedef BOOL (WINAPI *PFNSETTHREADGROUPAFFINITY)(HANDLE, const GROUP_AFFINITY*, GROUP_AFFINITY *); 12294 HMODULE const hmodKernel32 = GetModuleHandleW(L"KERNEL32.DLL"); 12295 PFNSETTHREADGROUPAFFINITY pfnSetThreadGroupAffinity; 12296 12297 pfnSetThreadGroupAffinity = (PFNSETTHREADGROUPAFFINITY)GetProcAddress(hmodKernel32, "SetThreadGroupAffinity"); 12298 if (pfnSetThreadGroupAffinity) 12299 { 12300 GROUP_AFFINITY OldAff = { 0, 0, 0, 0, 0 }; 12301 GROUP_AFFINITY NewAff = { 0, (WORD)uGroup, 0, 0, 0 }; 12302 NewAff.Mask = win_get_processor_group_active_mask((WORD)uGroup); 12303 if (NewAff.Mask && (WORD)uGroup == uGroup) 12304 { 12305 if (!pfnSetThreadGroupAffinity(GetCurrentThread(), &NewAff, &OldAff)) 12306 kwErrPrintf("Failed to set processor group to %lu (%p): %u\n", uGroup, NewAff.Mask, GetLastError()); 12307 } 12308 else if (GetLastError() == NO_ERROR) 12309 kwErrPrintf("Cannot set processor group to %lu: No active processors in group!\n", uGroup); 12310 else 12311 kwErrPrintf("Cannot set processor group to %lu: GetLogicalProcessorInformationEx failed: %u\n", 12312 uGroup, GetLastError()); 12313 } 12314 else 12315 { 12316 OSVERSIONINFOA VerInfo = {0}; 12317 if (VerInfo.dwMajorVersion > 6 || (VerInfo.dwMajorVersion == 6 && VerInfo.dwMinorVersion >= 1)) 12318 kwErrPrintf("Cannot set processor group to %lu: SetThreadGroupAffinity no found! (Windows version %lu.%lu)\n", 12319 uGroup, VerInfo.dwMajorVersion, VerInfo.dwMinorVersion); 12320 } 12321 } 12322 12323 12286 12324 int main(int argc, char **argv) 12287 12325 { … … 12511 12549 && *pszEnd == '\0' 12512 12550 && uValue == (WORD)uValue) 12513 { 12514 typedef BOOL (WINAPI *PFNSETTHREADGROUPAFFINITY)(HANDLE, const GROUP_AFFINITY*, GROUP_AFFINITY *); 12515 PFNSETTHREADGROUPAFFINITY pfnSetThreadGroupAffinity; 12516 pfnSetThreadGroupAffinity = (PFNSETTHREADGROUPAFFINITY)GetProcAddress(GetModuleHandleW(L"KERNEL32.DLL"), 12517 "SetThreadGroupAffinity"); 12518 if (pfnSetThreadGroupAffinity) 12519 { 12520 GROUP_AFFINITY NewAff = { ~(uintptr_t)0, (WORD)uValue, 0, 0, 0 }; 12521 GROUP_AFFINITY OldAff = { 0, 0, 0, 0, 0 }; 12522 if (!pfnSetThreadGroupAffinity(GetCurrentThread(), &NewAff, &OldAff)) 12523 kwErrPrintf("Failed to set processor group to %lu: %u\n", uValue, GetLastError()); 12524 } 12525 else 12526 kwErrPrintf("Cannot set processor group to %lu because SetThreadGroupAffinity was not found\n", uValue); 12527 } 12551 kwSetProcessorGroup(uValue); 12528 12552 else 12529 12553 return kwErrPrintfRc(2, "Invalid --priority argument: %s\n", argv[i]);
Note:
See TracChangeset
for help on using the changeset viewer.