| CMP Game Media Group Presents: | ||
![]() |
|
|
|
|
||
|
Processor Detection and a Pentium III Update
The code… The code is implemented as a C++ class called ProcessorDetect. Within the constructor of this class, threads are created to interrogate all the processors in the machine, and the results are stored within the class. Storing the data locally enables information about any of the processors in the machine to be returned without regard to the affinity of the calling thread. All the class member functions return a bool indicating their success, and although errors could be handed by C++ exceptions, I wanted this code to be used by as many people as possible. Details of all the public class members are given below. More specific information is available within the source code comments. The code is available as a Visual C++ project for download (CPUDetect.zip, which will be available 7/12/99). The project should build with version 6.0 of Visual C++ and with version 4.0 of the Intel compiler. I intend to keep this code as up to date as possible with new processor releases and bug fixes so keep checking back on the Gamasutra web site for the latest version. Public Class Member 1: bool get_processor_count ) Description Return the number of processors in the machine, as well as the number of processors available for the current process. The ID of the processor passed to all other members should be between 0 and processor_avail-1. Parameters processor_count is a reference to a 32-bit unsigned int that will be filled with the number of processors in the machine. On Windows 95/98 this will always be 1. processor_avail is a reference to a 32-bit unsigned int that will be filled with the number of processors available to the current process. On Windows 95/98 this will always be 1. Returns False if an error occurred. Under these conditions the contents of any return values are undefined.
Public Class Member 2: bool get_features
uint32_t processor, ) Description Returns the abstract features of the specified processor. The returned feature flag word is a bit set of the following: CPU_CPUID processor
supports CPUID instruction Parameters processor is the ID number of the processor for which the information is required, must always be 0 on Windows 95/98. feature_flags is a reference to a 32-bit unsigned int that contains the features specific to the requested processor. The features reported are listed above. Returns False if an error occurred or an invalid processor was passed in. Under these conditions the contents of any return values are undefined.
Public Class Member 3: bool get_manufacturer (
uint32_t processor, ) Description Get the manufacturer of the specified processor if it is available. Parameters processor is the ID number of the processor for which the information is required. It must always be 0 on Windows 95/98. manufacturer is a reference to a ProcessorManufacturer enum (32 bits in size) which will be filled with one of the following: Intel 0 Processors without the CPUID instruction will return a processor type of Unknown, as will processors that are not made by one of the above manufacturers. Returns False if an error occurred or an invalid processor was passed in. Under these conditions the contents of any return values are undefined.
Public Class Member 4: bool get_family ( ) Description Returns the family of the processor that is determined from the make, architecture family and stepping. If the processor has an unknown manufacturer then just the generic architecture will be returned. The manufacturer’s unknown values will be returned for future models by that manufacturer. If the processor has no CPUID and it is not a 386 or 486, then the result will be Unknown. Parameters processor is the ID number of the processor for which the information is required. It must always be 0 on Windows 95/98. Family is a reference to a ProcessorFamily enum, which will be filled with one of the following: Generic_Architecture4 4
Returns False if an error occurred or an invalid processor was passed in. Under these conditions the contents of any return values are undefined.
Public Class Member 5: bool get_clock_frequency
) Description Returns the clock speed in MHz of the specified processor. This clock speed is the raw speed as measured, so it may not be the exact rated clock speed. For example, a 400MHz machine may return 400.1MHz or 399.9MHz. Parameters processor is the ID number of the processor for which the information is required. It must always be 0 on Windows 95/98. mhz is a reference to a float that will be filled with the clock speed. Returns False if an error occurred or an invalid processor was passed in. Under these conditions the contents of any return values are undefined. |
|
Copyright
© 2000 CMP Media Inc. All rights reserved.
Privacy Policy |