Solved

Checking for RDTSC support

Posted on 1998-01-02
2
276 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Windows Standards for file storage. 3 39
Enable Clear Text in Win 8.1 7 49
Is AWS.RDS considered a part of "Big Data"? 4 160
WPF issue with Trigger 2 149
This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

752 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