Solved

Checking for RDTSC support

Posted on 1998-01-02
2
277 Views
Last Modified: 2013-12-03
Is there a quick check you can do to find out if the RDTSC (time stamp)
instruction
is supported on the particular CPU that you're running on?

I know you can back this out by doing a bunch of tests to see what brand
and model
CPU you have, and then figuring out from that info if the RDTSC
instruction is supported,
but I'm hoping to have a simpler runtime check that doesn't require us
to keep track
of every CPU brand and model.

Currently if you execute the RDTSC on cpu's that don't support it, Win95
pops up a
box about an illegal instruction. Is there some way you can attempt to
execute the
RDTSC and then catch the fact that its not supported before Win95 gets
upset
about it? If so, will this work on NT also?

Thanks for any help you can give me-
Paul Titchener

0
Comment
Question by:titchener
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
Arkadiy earned 100 total points
ID: 1409811
You probably should use structured exceptions. Something like this:
BOOL bCommandAccessible = TRUE;
__try
{
   asm{RDTSC ...}
}
__except(1)
{
  //the command is not accessible
  bCommandAccessible = FALSE;
  ASSERT(_exception_code() == 6); //6 means invalid instruction
}

That code applies to Visual C++. If you use something els, see help on _structured_ (not C++) exception handling.
P.S. I never tried this code to catch a bad command exception. I use it mostly for code 5 (GPF)
0
 

Author Comment

by:titchener
ID: 1409812
I didn't try the suggested approach in the answer yet, but
it makes sense and looks like it will probably work well.

Thanks,

Paul Titchener
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question