All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-help] Problem getting the time with a kernel patched with xenomai
@ 2010-05-06  7:52 Divi Oillo
  2010-05-06  8:15 ` Gilles Chanteperdrix
  0 siblings, 1 reply; 4+ messages in thread
From: Divi Oillo @ 2010-05-06  7:52 UTC (permalink / raw)
  To: xenomai

[-- Attachment #1: Type: text/plain, Size: 2751 bytes --]

Hi, I post this message because I need a little help.

I've recently patched with success my 2.6.32.12 kernel with xenomai
adeos-ipipe-2.6.32.7-x86-2.6-01.patch and I've installed xenomai-2.5.2.
When I run this code on my linux-2.6.32.12 patched with xenomai, I'm getting
some trouble. The following code give the current time each second using
nanosleep and gettimeofday. The program wait 1 second and print the time in
the terminal.

************************************************************
#include <iostream>
#include <string>
#include <time.h>
#include <sys/time.h>
#include <unistd.h>

using namespace std;

int main (void)
{
        timeval timestamp;
        timeval timestamp_sav;
        struct timespec req;
        req.tv_sec=1; //1 second
        req.tv_nsec=0;
        double diff;

        while(1)
        {
                gettimeofday(&timestamp_sav,NULL);
                nanosleep(&req,&req);
                gettimeofday(&timestamp,NULL);

                diff = timestamp.tv_usec - timestamp_sav.tv_usec;
                cout << "timestamp_sav=" << timestamp_sav.tv_sec << "
timestamp=" << timestamp.tv_sec <<  "   Diff : " << diff << endl;
        }

        return 0;
}
************************************************************

uname -r
2.6.32-12-xenomai
../bin/timer
timestamp_sav=1273069305 timestamp=1273069306   Diff : 10010
timestamp_sav=1273069306 timestamp=1273069307   Diff : 10011
timestamp_sav=1273069307 timestamp=1273069308   Diff : 10011
timestamp_sav=1273069308 timestamp=1273069309   Diff : 10011
timestamp_sav=1273069309 timestamp=1273069310   Diff : 10011
timestamp_sav=1273069310 timestamp=1273069311   Diff : 10011
timestamp_sav=1273069311 timestamp=1273069312   Diff : 10010
timestamp_sav=1273069312 timestamp=1273069313   Diff : 10011
timestamp_sav=1273069313 timestamp=1273069314   Diff : 10011
timestamp_sav=1273069314 timestamp=1273069315   Diff : 10011

uname -r
2.6.32-12
../bin/timer
timestamp_sav=1273069885 timestamp=1273069886   Diff : 305
timestamp_sav=1273069886 timestamp=1273069887   Diff : 306
timestamp_sav=1273069887 timestamp=1273069888   Diff : 379
timestamp_sav=1273069888 timestamp=1273069889   Diff : 311
timestamp_sav=1273069889 timestamp=1273069890   Diff : 302
timestamp_sav=1273069890 timestamp=1273069891   Diff : 292
timestamp_sav=1273069891 timestamp=1273069892   Diff : 309
timestamp_sav=1273069892 timestamp=1273069893   Diff : 313
timestamp_sav=1273069893 timestamp=1273069894   Diff : 309
timestamp_sav=1273069894 timestamp=1273069895   Diff : 311


Why do I have +10010 µs or +10011 µs between each dating with my xenomai
kernel and approximately +300 µs with my non-patched kernel?
Thanks.

[-- Attachment #2: Type: text/html, Size: 3157 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Xenomai-help] Problem getting the time with a kernel patched with xenomai
  2010-05-06  7:52 [Xenomai-help] Problem getting the time with a kernel patched with xenomai Divi Oillo
@ 2010-05-06  8:15 ` Gilles Chanteperdrix
       [not found]   ` <i2kcfed72901005060830q1d29f948x4b558e2cf8cb617a@domain.hid>
  0 siblings, 1 reply; 4+ messages in thread
From: Gilles Chanteperdrix @ 2010-05-06  8:15 UTC (permalink / raw)
  To: Divi Oillo; +Cc: xenomai

Divi Oillo wrote:
> Hi, I post this message because I need a little help.

Hi,

> (...)
>                 gettimeofday(&timestamp_sav,NULL);
>                 nanosleep(&req,&req);
>                 gettimeofday(&timestamp,NULL);
> (...)

Note that your application does not benefit from any improvements made
by Xenomai, it is using Linux services.


> Why do I have +10010 µs or +10011 µs between each dating with my xenomai
> kernel and approximately +300 µs with my non-patched kernel?
> Thanks.

To obtain such results, you are probably running your test on an idle
system. But anyway, the problem is probably that the vanilla
configuration probably has high resolutions timers running, whereas the
Xenomai patched kernel has not.

Whether high resolution timers are enabled is both a question of
kernel-configuration (CONFIG_HIGHRES_TIMERS, CONFIG_X86_LOCAL_APIC,
CONFIG_HPET have an influence), and a question of run-time decisions.
You should find some hints in the kernel messages.

Regards.

-- 
					    Gilles.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Xenomai-help] Problem getting the time with a kernel patched with xenomai
       [not found]   ` <i2kcfed72901005060830q1d29f948x4b558e2cf8cb617a@domain.hid>
@ 2010-05-06 19:17     ` Gilles Chanteperdrix
  2010-05-06 19:42       ` Gilles Chanteperdrix
  0 siblings, 1 reply; 4+ messages in thread
From: Gilles Chanteperdrix @ 2010-05-06 19:17 UTC (permalink / raw)
  To: Divi Oillo; +Cc: Xenomai help

Divi Oillo wrote:
> I don't have CONFIG_HPET=y and CONFIG_HPET_MMAP=y in the .config of my
> patched kernel. How can I configure my patched kernel to fix my problem?
> Can I add these two options in my patched kernel .config?

Yes you can, but more important than the kernel options are the run time
decisions, of which you are informed in the kernel logs, as my last mail
already told you. Anyway, all this is not really specific about Xenomai,
so you would probably be better of finding some web site explaining
high-res timers in details.

And please do not forget to CC the mailing list.

-- 
					    Gilles.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Xenomai-help] Problem getting the time with a kernel patched with xenomai
  2010-05-06 19:17     ` Gilles Chanteperdrix
@ 2010-05-06 19:42       ` Gilles Chanteperdrix
  0 siblings, 0 replies; 4+ messages in thread
From: Gilles Chanteperdrix @ 2010-05-06 19:42 UTC (permalink / raw)
  To: Divi Oillo; +Cc: Xenomai help

Gilles Chanteperdrix wrote:
> Divi Oillo wrote:
>> I don't have CONFIG_HPET=y and CONFIG_HPET_MMAP=y in the .config of my
>> patched kernel. How can I configure my patched kernel to fix my problem?
>> Can I add these two options in my patched kernel .config?
> 
> Yes you can, but more important than the kernel options are the run time
> decisions, of which you are informed in the kernel logs, as my last mail
> already told you. Anyway, all this is not really specific about Xenomai,
> so you would probably be better of finding some web site explaining
> high-res timers in details.

for instance:
http://elinux.org/High_Resolution_Timers#How_to_detect_if_your_timer_system_supports_high_resolution



-- 
					    Gilles.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-05-06 19:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-06  7:52 [Xenomai-help] Problem getting the time with a kernel patched with xenomai Divi Oillo
2010-05-06  8:15 ` Gilles Chanteperdrix
     [not found]   ` <i2kcfed72901005060830q1d29f948x4b558e2cf8cb617a@domain.hid>
2010-05-06 19:17     ` Gilles Chanteperdrix
2010-05-06 19:42       ` Gilles Chanteperdrix

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.