Measuring time differences

R

Randy Howard

Mark McIntyre wrote
(in article said:
what, including Windows NT for RISC? Remember that?

Also, the "SpeedStep" feature of Intel processors can cause
problems with the values read back by RDTSC, which is why Intel
put out an entire paper "Enabling Power Event Interception and
Control Under Microsoft Windows XP" to try and work around this.
 
C

Chuck F.

coder1024 said:
gettimeofday() will work very well if available in the OP's
development environment. the OP didn't provide specifics as to
their environment. I do know the platform. I've developed SW on
Windows using cygwin and gcc and successfully used
gettimeofday() when in a similar situation which is why I
suggested it. I've also developed using Visual C++. I don't
know about other environments (Borland C++, etc.). Anyway, the
OP can take 2 minutes to try and call the function and will
> immediately know if it isn't there. This is more helpful than
your ranting. I mean, really, did you just get out of bed on
the wrong side this morning? Dare I say... relax? :)

Regardless, there's also the APR which will almost certainly be
available on the OP's platform if they want to put in the effort
to add a product to their environment and dependencies list.

To illustrate Flashs point, the following is perfectly valid
implementation of gettimeofday():

unsigned long gettimeofday(void) {
return 1234;
}

If it "isn't there" simply add it to your system library, etc.
Then it will be there. However, it is somewhat doubtful that it
will do what you really want. The reason is that its action,
calling parameters, return values, side effects, etc. are totally
undefined, because IT IS NOT STANDARDIZED. In this newsgroup we
deal ONLY with the standardized C language, as defined by the
various ISO standards (C89, C90, C99) and their predecessor (K&R
C). This means we have a reasonable chance of knowing what we are
talking about. This also means that when someone asks about a
non-standard item, we send him to a newsgroup dealing with his
particular system, where someone may have appropriate knowledge and
where invalid answers are fairly likely to be so flagged.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>
 
C

Chuck F.

coder1024 said:
.... snip OT junk ...

I only posted it as I thought it might be of use to the OP.

By now you have managed to get yourself plonked by several of the
knowledgeable regulars for your persistance in OT posting. That
means their systems have been told to ignore any further posts from
you, thus avoiding annoyance. This also means that, should you
need it, you will never get help from those regulars, because they
no longer know you exist.

Do some reading from the links below.

--
Some useful references about C:
<http://www.ungerhu.com/jxh/clc.welcome.txt>
<http://www.eskimo.com/~scs/C-faq/top.html>
<http://benpfaff.org/writings/clc/off-topic.html>
<http://anubis.dkuug.dk/jtc1/sc22/wg14/www/docs/n869/> (C99)
<http://www.dinkumware.com/refxc.html> (C-library}
<http://gcc.gnu.org/onlinedocs/> (GNU docs)
 
C

coder1024

Martin said:
Please stop it, for God's sake! Are you running for troll-of-the-year?
Off-topic is off-topic. And you are plonked.

I was replying to a post from Keith Thompson. Your ranting is also off
topic btw. Interesting that my reply to Keith about APR would generate
such energy from you, but oh well... 'nuff said.
 
K

Keith Thompson

coder1024 said:
I was replying to a post from Keith Thompson. Your ranting is also off
topic btw. Interesting that my reply to Keith about APR would generate
such energy from you, but oh well... 'nuff said.

I think coder1024 is now *trying* to drop the whole thing. The
asynchronous nature of Usenet makes this difficult to do.
 
C

coder1024

Chuck said:
By now you have managed to get yourself plonked by several of the
knowledgeable regulars for your persistance in OT posting. That
means their systems have been told to ignore any further posts from
you, thus avoiding annoyance. This also means that, should you
need it, you will never get help from those regulars, because they
no longer know you exist.

What value are you trying to add to this discussion with the above
post? Multiple posters have already made it clear that they feel that
forwarding the OP to another forum was the best answer and that they
didn't care for the suggestions I made wrt gettimeofday() and/or
apr_time_now() and furthermore that they didn't care for my
disagreement with their position on this. Some got outright heated
about it.

I provided what I thought to be helpful suggestions to the OP and a
number of others disagreed with my approach and the information I
provided. You're not adding anything new with the above response.

I probably should have just provided the OP whatever help I could and
then left it alone as opposed to letting myself get dragged into a
useless discussion which did nothing to advance the OP's concern or the
concern of those who disagreed with my approach. It was just a bunch
of bickering back and forth.
 
C

coder1024

Chuck said:
If it "isn't there" simply add it to your system library, etc.
Then it will be there. However, it is somewhat doubtful that it
will do what you really want. The reason is that its action,
calling parameters, return values, side effects, etc. are totally
undefined, because IT IS NOT STANDARDIZED. In this newsgroup we
deal ONLY with the standardized C language, as defined by the
various ISO standards (C89, C90, C99) and their predecessor (K&R
C). This means we have a reasonable chance of knowing what we are
talking about. This also means that when someone asks about a
non-standard item, we send him to a newsgroup dealing with his
particular system, where someone may have appropriate knowledge and
where invalid answers are fairly likely to be so flagged.

So it wasn't enough to post about some plonking nonsense earlier, you
thought you'd also come here and do what exactly? Its already been
stated that gettimeofday() and apr_time_now() are non-standard. It was
also made clear by multiple posters that they disagreed with my
providing any suggestions to the OP instead of forwarding them to
another group and that they disagreed with my suggestions anyway. I
fail to see what you're adding to this which hasn't already been said
multiple times. Give it up. Everyone has made their positions here
pretty clear on the topic of discussing non-standard functions. What
more needs to be said?
 
R

Richard Bos

jacob navia said:
One way of doing that (under an x86 and in standard C)
is:

#include <stdio.h>
long long (*rdtsc)(void);

int main(void)
{
unsigned char fn[] = {0xf,0x31,0xc3};
rdtsc = (long long(*)(void)) fn;

No. Not even on an x86 can you rely on an unsigned char array cast to a
function pointer resulting in a callable function. Not in Standard C,
anyway.

Richard
 
J

jacob navia

Richard Bos a écrit :
One way of doing that (under an x86 and in standard C)
is:

#include <stdio.h>
long long (*rdtsc)(void);

int main(void)
{
unsigned char fn[] = {0xf,0x31,0xc3};
rdtsc = (long long(*)(void)) fn;


No. Not even on an x86 can you rely on an unsigned char array cast to a
function pointer resulting in a callable function. Not in Standard C,
anyway.

Richard

Yes, it supposes that the data section can be executed.
This may not be true in all systems.
 
R

Randy Howard

jacob navia wrote
(in article said:
Richard Bos a écrit :
One way of doing that (under an x86 and in standard C)
is:

#include <stdio.h>
long long (*rdtsc)(void);

int main(void)
{
unsigned char fn[] = {0xf,0x31,0xc3};
rdtsc = (long long(*)(void)) fn;


No. Not even on an x86 can you rely on an unsigned char array cast to a
function pointer resulting in a callable function. Not in Standard C,
anyway.

Richard

Yes, it supposes that the data section can be executed.

Then why did you say it was "standard C"?
This may not be true in all systems.

Especially not the newer OS implementations taking advantage of
the processor protection extensions to explicitly prevent it.
 
M

Mark McIntyre

Give it up. Everyone has made their positions here
pretty clear on the topic of discussing non-standard functions. What
more needs to be said?

only this: *plonk*
 
R

Richard Bos

jacob navia said:
Richard Bos a écrit :
jacob navia said:
One way of doing that (under an x86 and in standard C)
is:

#include <stdio.h>
long long (*rdtsc)(void);

int main(void)
{
unsigned char fn[] = {0xf,0x31,0xc3};
rdtsc = (long long(*)(void)) fn;

No. Not even on an x86 can you rely on an unsigned char array cast to a
function pointer resulting in a callable function. Not in Standard C,
anyway.

Yes, it supposes that the data section can be executed.
This may not be true in all systems.

Then isn't it about time that you really do not understand the concept
of "Standard C" very much at all?

Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top