From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: Daniele Nicolodi <daniele@domain.hid>
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai-help] How to avoid a tight real time loop
Date: Tue, 15 Jun 2010 14:46:37 +0200 [thread overview]
Message-ID: <4C17762D.4010906@domain.hid> (raw)
In-Reply-To: <4C177276.7060005@domain.hid>
Daniele Nicolodi wrote:
> Hello. In my application I need to read data from an ADC card in blocks
> of a given number of samples. For efficiency I'm using an mmapped buffer
> to exchange data with the ADC driver. I'm setting up the acquisition,
> and then calling a loop like this:
>
> unsigned int required = <compute required number of bytes>;
> unsigned int read = 0;
> while (1) {
> while (read < required) {
> read = a4l_pool(...);
> }
> process(buffer, ...);
> }
>
> However if I run this loop in a real time thread the tight while loop is
> an obvious cpu hog: the watchdog kicks in and kills the thread.
>
> There is not an analogy API that can be used to require a certain amount
> of data to the ADC driver. How can I code this loop to let other
> processes to run?
You should define a period, and how much data you want to process during
this period. Then make your task periodic, and wait for the next period
at the beginning of the loop.
>
> Thanks. Cheers,
--
Gilles.
next prev parent reply other threads:[~2010-06-15 12:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-15 12:30 [Xenomai-help] How to avoid a tight real time loop Daniele Nicolodi
2010-06-15 12:46 ` Gilles Chanteperdrix [this message]
2010-06-15 22:11 ` Alexis Berlemont
2010-06-16 16:49 ` Daniele Nicolodi
2010-06-16 18:19 ` Gilles Chanteperdrix
2010-06-24 22:50 ` Alexis Berlemont
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=4C17762D.4010906@domain.hid \
--to=gilles.chanteperdrix@xenomai.org \
--cc=daniele@domain.hid \
--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.