//-------------------------------------------------------------------------- // Rob Wyatt for Game Developer/Gamasutra April 1999 //-------------------------------------------------------------------------- #include "Windows.h" #include "stdio.h" #include "conio.h" #include "Detect.h" //------------------------------------------------------------------------------ // Display the processor serial number in intel format void DisplaySerialNumber ( DWORD* num ) //------------------------------------- { static char hex_chars[16] = {'0','1','2','3','4','5','6','7', '8','9','A','B','C','D','E','F'}; // go through the for (int dw_count = 2; dw_count>=0; dw_count--) { for (int bp=28; bp>=0; bp-=4) { DWORD nibble = (num[dw_count] >> bp) & 0x0f; printf("%c", hex_chars[nibble]); if ((bp == 16) || ((bp == 0) && (dw_count!=0)) ) printf("-"); } } printf("\n"); } //------------------------------------------------------------------------------ // This function shall be called as a thread DWORD _stdcall DetectProcessor ( void* user ) //------------------------------------- { CDetect detect_simd; //-------------------------------------------------------------------------- if (detect_simd.GetStatus()) { printf("SIMD detection good\n"); } else { printf("SIMD detection bad\n"); } //-------------------------------------------------------------------------- if (detect_simd.GetSIMDSupport()) { printf("SIMD instructions present\n"); } else { printf("SIMD instructions not present\n"); } //-------------------------------------------------------------------------- if (detect_simd.GetOSSupport()) { printf("OS supports SIMD and new state instructions\n"); } else { printf("OS does not support SIMD and new state instructions\n"); } //-------------------------------------------------------------------------- if (detect_simd.GetOSExceptions()) { printf("OS supports SIMD exceptions\n"); } else { printf("OS does not support SIMD exceptions\n"); } //-------------------------------------------------------------------------- if (detect_simd.SerialNumberPresent()) { printf("Processor has serial number\n"); printf("Serial Number : "); DisplaySerialNumber(detect_simd.GetSerialNumber()); } else { printf("Processor does not have serial number\n"); } return 0; } //------------------------------------------------------------------------------ void main ( ) //------------------------------------- { SYSTEM_INFO sys_info; DWORD processor; HANDLE thread; DWORD thread_id; // Get the system info to derive the number of processors // within the system. It will always be 1 on 95 or 98. GetSystemInfo(&sys_info); processor = sys_info.dwNumberOfProcessors; printf("Number of processors in system: %d\n\n", processor); while (processor>0) { printf("PROCESSOR: %d\n",processor); printf("-------------\n"); // create a thread that is suspended thread = CreateThread(NULL,0,DetectProcessor,NULL, CREATE_SUSPENDED,&thread_id); // Set the affinity of the thread so to force it to run // on the required processor SetThreadAffinityMask(thread, 1<<(processor-1)); // Now we have set the processor resume the thread and it // will run only on the specified processor. ResumeThread(thread); // Wait for the current detection thread to finish WaitForSingleObject(thread,INFINITE); // Close the handle to the now finished thread CloseHandle(thread); // goto the next processor processor--; // leave a gap.. printf("\n"); } printf("Press any key\n"); while(!kbhit()); }