From: Alexander Stein <alexander.stein@systec-electronic.com>
To: Kurt Van Dijck <kurt.van.dijck@eia.be>
Cc: Pavel Pisa <pisa@cmp.felk.cvut.cz>,
Mohamed HAMZAOUI <requinham@gmail.com>,
Wolfgang Grandegger <wg@grandegger.com>,
Linux-CAN <linux-can@vger.kernel.org>
Subject: Re: [SocketCan] Problem of accuracy
Date: Mon, 09 Jul 2012 16:57:55 +0200 [thread overview]
Message-ID: <23562188.349Ls0e8RT@ws-stein> (raw)
In-Reply-To: <20120709144042.GA2671@vandijck-laurijssen.be>
Am Montag, 9. Juli 2012, 16:40:42 schrieb Kurt Van Dijck:
> I tend to use itimer:
> #include <sys/time.h>
>
> int sigalrm;
>
> void hndalrm(int sig)
> {
> sigalrm = 1;
> signal(SIGALRM, hndalrm);
> }
>
> const struct itimerval itimer = {
> .it_interval = { /* seconds*/, /*useconds*/, },
> .it_value = { 0, 1, }, /* schedule first run quasi immediately */
> };
>
> main ()
> {
> signal(SIGALRM, hndalrm);
>
> setitimer(ITIMER_REAL, &itimer, NULL);
>
> while (1) {
> poll(NULL, 0, -1); /* wait indefinite until signal */
> write(...).
> }
> }
>
> I just realised that this algorithm does not need measuring time spent,
> it will automatically skip cycles, at the cost of having to deal with
> signal's.
> I don't know if it is based on hrtimer in kernel too, I assume yes.
I compared itimer with clock_nanosleep on an ARM board and noticed the signal
overhead of itimer is much bigger, resulting in a higher CPU usage, than
clock_nanosleep upon hrtimer.
So I ended up using clock_nanosleep adding a constant to the last timeout.
itimer should also be based on hrtimer.
Best regards,
Alexander
--
Dipl.-Inf. Alexander Stein
SYS TEC electronic GmbH
August-Bebel-Str. 29
D-07973 Greiz
Tel: +49-3661-6279-0, Fax: +49-3661-6279-99
eMail: Alexander.Stein@systec-electronic.com
Internet: http://www.systec-electronic.com
Managing Director: Dipl.-Phys. Siegmar Schmidt
Commercial registry: Amtsgericht Jena, HRB 205563
next prev parent reply other threads:[~2012-07-09 15:06 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CABMxt4ijuTMYFYXx0n4AYBO6-=SRD0U3F4BTA2=rWE80Z4-yOA@mail.gmail.com>
2012-07-05 8:38 ` Problem of accuracy Oliver Hartkopp
2012-07-07 10:02 ` [SocketCan] " Mohamed HAMZAOUI
2012-07-07 10:32 ` Wolfgang Grandegger
2012-07-08 19:43 ` Mohamed HAMZAOUI
2012-07-08 20:13 ` Wolfgang Grandegger
2012-07-08 20:30 ` Mohamed HAMZAOUI
2012-07-09 7:18 ` Wolfgang Grandegger
2012-07-09 8:14 ` Mohamed HAMZAOUI
2012-07-09 8:20 ` Wolfgang Grandegger
2012-07-09 9:19 ` Mohamed HAMZAOUI
2012-07-09 9:22 ` Wolfgang Grandegger
[not found] ` <CABMxt4jnztXqAmLFcBnqp3001QXds1nX3xA2y_ka=xCNr0cjjA@mail.gmail.com>
[not found] ` <4FFAB09F.6090800@grandegger.com>
[not found] ` <CABMxt4jLRKz8xKNbH3Qa=P0k1aEjMsqmo2vArGDo2O1Wf0=wGQ@mail.gmail.com>
2012-07-09 11:26 ` Fwd: " Mohamed HAMZAOUI
2012-07-09 11:40 ` Wolfgang Grandegger
2012-07-09 11:57 ` Mohamed HAMZAOUI
2012-07-09 12:15 ` Wolfgang Grandegger
2012-07-09 13:19 ` Pavel Pisa
2012-07-09 14:29 ` Mohamed HAMZAOUI
2012-07-09 14:35 ` Mohamed HAMZAOUI
2012-07-09 14:40 ` Kurt Van Dijck
2012-07-09 14:57 ` Alexander Stein [this message]
2012-07-09 15:39 ` Mohamed HAMZAOUI
2012-07-09 17:08 ` Oliver Hartkopp
2012-07-09 20:50 ` Wolfgang Grandegger
2012-07-10 22:11 ` Mohamed HAMZAOUI
2012-07-11 12:35 ` Mohamed HAMZAOUI
2012-07-11 22:22 ` Wolfgang Grandegger
2012-07-11 22:19 ` Wolfgang Grandegger
2012-07-09 6:55 ` Kurt Van Dijck
[not found] ` <1341488146.2416.9.camel@slaptop>
2012-07-05 13:57 ` [Socketcan-users] back to back can frames Kurt Van Dijck
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=23562188.349Ls0e8RT@ws-stein \
--to=alexander.stein@systec-electronic.com \
--cc=kurt.van.dijck@eia.be \
--cc=linux-can@vger.kernel.org \
--cc=pisa@cmp.felk.cvut.cz \
--cc=requinham@gmail.com \
--cc=wg@grandegger.com \
/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.