Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] timing for geeks II.



Hello :)

* Jim (jep200404@example.com) [051218 17:34]:
> What problem are you actually trying to solve (or understand)? 

Exceptionally good question actually :)
I apologise, I should have cleared this one right from the beginning of
the thread....

The story is somewhat more complex, but I will try to put it as simple
as possible, since what I am doing is merely an exercise and learning
"how this particular stuff works" more than anything else.

I am trying to figure how precisely can I measure time with pc running
linux. 

So I would like to know, if I just install debian 3.1 on i386 with
latest distro kernel and no special hw, run my application measuring
some physical quantity (eg. sample voltage, temperature... etc.), what
is the uncertainty which I get _exclusively_ from time measurement.

Closely following is the question, whether I can improve it with some
quite easy "tuning". 

In my code I was originally using ftime(), which was quickly replaced by
gettimeofday(). Ok, let me see if there is something even better...
hmmm, I see some clock_gettime()... does it perform any better?  Well,
experiments show that not really, although it perhaps could be a better
option on some circumstances (though I do not know yet exactly what
these are). 

What other options do I have? Ok, I might patch kernel and try some more
real-time oriented stuff. Or maybe I can buy a cheap crystal (say 10$)
and use it as a better clock somehow, or ... ? :) 
This link seems to be quite attractive for me:
http://source.mvista.com/~ganzinger/hrt/home_page.html

The links for embedded RT-linux (Montavista) suggested by Steve seems to me
on the first glimpse to be more work. But I did not explore it well yet. 
The solaris (mentioned by Josh) might be an option as well. But I do not
have any experience with solaris on i386. So this basically seems to be
more work than, say, installing new patched kernel. 

Or maybe I can synchronise clock using ntpdate before every single data
acquisition? Now the topics get more complex, since I shall figure
precise timing of my experiment - how long does it take to switch relay,
how long does it take to nanovoltmeter to measure voltage, how long does
it take to determine temperature, how long does it take to transfer
results, how long does it take ... and is it possible to measure these
delays with pc (gettimeofday) ? Or how should I measure it anyway? :) 

Another idea is to give higher priority to my measurement program. Since
you say that the biggest delay is from OS (only once in a relatively
long time, but still...), this could be one example of cheap tuning :)

Well, right now I have a program which marks absolute time of the
measurement with gettimeofday() and it serves quite well to the purpose.
And the plan is to make these measurements (means voltage, temp..) time
to time for next few decades, so I have some time to think about
improvements in the meantime :)) Oh, I shall perhaps mention that single
measurement run takes about two days. 

Hmm, if I read my post from the top to the bottom, I am not sure if I
answered the original question. But I hope I have offered clearer view
on my line of reasoning. 

After all, "having work done" and "having no questions" are two completely
different things, aren't they? :)) 

Best regards
Michal


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links