All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Petr Červenka" <grugh@centrum.cz>
To: Per Oberg <pero@wolfram.com>, xenomai <xenomai@xenomai.org>
Subject: Re: Posix periodic time first tick
Date: Mon, 10 Aug 2020 09:52:34 +0200	[thread overview]
Message-ID: <4baa56a0-13dc-08d7-79d4-00f63f85c2b0@centrum.cz> (raw)
In-Reply-To: <166391923.711496.1597041953464.JavaMail.zimbra@wolfram.com>

Hello.

The problem is only when I use Xenomai linking flags and only with 
thestart time. Period is OK.

That aprox. 16s time delay can be "compensated" by substracting of any 
number of seconds from the start time.

     // Create timer
     timer_fd = timerfd_create(CLOCK_MONOTONIC, 0);

     // Get current time
     struct timespec start;
     clock_gettime(CLOCK_MONOTONIC, &start);

     // Set periodic
     struct itimerspec timer_conf;
     memset(&timer_conf, 0, sizeof (timer_conf));
     timer_conf.it_value = timespec_add(start, -15 * NANOSEC_PER_SEC); 
// compensation of the delay
     ...
     timerfd_settime(timer_fd, TFD_TIMER_ABSTIME, &timer_conf, NULL);

There is strange unexpected difference/time shift between product of 
clock_gettime and timerfd_settime. Only with Xenomai posix wrappers.

Best regards

Petr Cervenka


Dne 10.08.2020 v 8:45 Per Oberg napsal(a):
> ----- Den 7 aug 2020, på kl 17:12, xenomai xenomai@xenomai.org skrev:
>
>> Hello.
>> I have created small example of periodic task in posix.
>> If I compile it without xenomai it works fine.
>> When I add Xenomai linking flags, the first tick of periodic task take around
>> 16s. After that it continues as it should.
>> Used clock type for timer_fd is CLOCK_MONOTONIC. The example should in
>> attachment.
>> Do you have any suggestions?
> Just had a extremely quick look at it. Are you sure you don't get any rounding errors when doing your period arithmetics ?
>
>> Best regards
>> -------------- next part --------------
>> A non-text attachment was scrubbed...
>> Name: timer_test.cpp
>> Type: text/x-c++src
>> Size: 4351 bytes
>> Desc: timer_test.cpp
>> URL:
>> <http://xenomai.org/pipermail/xenomai/attachments/20200807/d4203f59/attachment.cpp>
> Per Öberg


  reply	other threads:[~2020-08-10  7:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-07 15:12 Posix periodic time first tick Petr Červenka
2020-08-10  6:45 ` Per Oberg
2020-08-10  7:52   ` Petr Červenka [this message]
2020-08-10  8:54     ` Per Oberg
2020-08-10  9:49     ` Philippe Gerum
2020-08-18 15:21       ` Petr Červenka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4baa56a0-13dc-08d7-79d4-00f63f85c2b0@centrum.cz \
    --to=grugh@centrum.cz \
    --cc=pero@wolfram.com \
    --cc=xenomai@xenomai.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.