l i n u x - u s e r s - g r o u p - o f - d a v i s
L U G O D
 
Next Meeting:
December 2: Social gathering
Next Installfest:
TBD
Latest News:
Nov. 18: Club officer elections
Page last updated:
2003 Sep 15 20:44

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
Re: [vox-tech] Driver Question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vox-tech] Driver Question



On Mon, 15 Sep 2003, John Wojnaroski wrote:

> Would not the select() stop the application, forcing it to wait for the
> data?

Yes.  You can also set a zero timeout, though, to get immediate results.

> The application (real time simulation) cannot block or run timeouts or spend
> any time testing to see if data is available.

Perhaps we have different definitions of "real-time"... wouldn't be the
first time those wires got crossed.  Userspace in Linux is NOT what I
think of as real-time.

> The only time it wants to be bothered is when data is available, otherwise
> "leave-me-alone". Since the I/O is async it seems that a push system is more
> advantagous...

It is not clear to me what the primary inputs and outputs for this
simulation are... since you said the driver was autonomously handling most
of the I/O, I assumed the realtime portion of the code was in the driver
(including generation of output signals). In such a case, the userspace
portion would simply be used to provide logging and/or on-the-fly
visibility into the simulation progress, and blocking on such data would
make perfect sense.

Userspace is fine for taking a snapshot of realtime and munging it onto a
a screen or out a network port, but not so good for supplying data to an
A/D card to create the illusion of a physical process signal (voltage
proportional to spring position, for example).

Some simulations use keyboard and screen for their primary I/O... the most
well-known of these simulations are first-person-shoot'em'up games.  Such
simulations can afford to slip a little now and then... that is, not
hitting the specified frame rate simply results in degraded performance
that may or may not be noticeable in the intended application, so
userspace simulation is perfectly acceptable, and poll or select can be an
effective way to obtain input.

However, at some level, your application will be interested in learning
what the status of those inputs are that you are considering signalling.  
It might seem that the quickest way to do that is to simply check an
internal variable that is updated via a signal.  However, you are living a
bit on borrowed time, because when the signal comes along the application
will be stopped for quite a few clock cycles... I would guess easily three
times the clock cycles as the cost of a poll() call would take.  Thus, you
are setting yourself up for fast execution most of the time, with an
occasional hiccup in your simulation speed.  Simply calling poll() every
time with a zero timeout could yield a more predictable simulation loop
execution time.  However, I don't know enough about your application to
say whether average speed or worst-case speed is most important to you.

> Granted signals are more complicated, but they might be necessary in some
> cases. I fiddled with a very non-elegant approach where the driver set a
> flag in the data file and the application read the file (about 64 chars) on
> each pass and tested the flag, if true it accepted the data and reset the
> flag with a write to the file, if false it ignored the data. It works but
> waste CPU resources big time...

You may simply be polling too often.  Also, if there is no change in
input, then there is no need to actually transmit data... the application
can more easily check lack of data than transfer useless data (though
there is that execution time predictability problem again).

> You spend all the effort to design a Ferrari (the interrupt driver and
> board) and then install a VW engine(the fiddle thingy) to make it run ;-)

I don't understand "fiddle thingy".  If you are suggesting that poll() or
signal() are kludgy, then you may not have an appropriate perspective on
userspace programming. Neither of them is intended to provide a real-time
interface to interrupts... that is kernelspace work, or "realtime
task" work as defined by some realtime extension to Linux.  Userspace is
"processing power as available", rather than "processing power on
demand", and blocking on input is ideal for that kind of resource.

---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil@dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...2k
---------------------------------------------------------------------------

_______________________________________________
vox-tech mailing list
vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech



LinkedIn
LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
facebook
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
Appahost Applications
For a significant contribution towards our projector, and a generous donation to allow us to continue meeting at the Davis Library.