[PD] firm delay scheduling

IOhannes m zmoelnig zmoelnig at iem.at
Wed Oct 31 09:07:25 CET 2012


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 2012-10-30 18:13, Jean-Marie Adrien wrote:
> Hello I'm trying to launch security procedures in case of trouble, 
> that will respond in less than 250 msec. The fundamental question 
> is :
> 
> Is there an object to schedule an event in the future with firm 
> absolute delay ?
> 

if you want "hard realtime", then you would need a system that is
capable of doing realtime. no "standard" (as in "desktop") operating
system on the market will fullfill your needs.

so let's assume "soft realtime" (where a given piece of code has
'hopefully' been executed by a certain time) is good enough.

you are facing to different problems:

- - if your CPU is busy doing other things, there is no way for it to
also do your specific tasks. adding more CPUs might help if there are
*other* programs involved that eat your processing power.
it's not so easy if Pd itself is consming too much CPU: unfortunately
Pd is inherently single threaded, so there is no way to start your
"security procedures" if the main thread is busy having "troubles",
short of running 2 Pd's in parallel (and let them communicate e.g. via
network)

- - you can experience the "elastic" nature (compared to your wall
clock) of [delay] even if your CPU does not run at 100%. Pd's logical
time is floating a bit (compared to real time) in order to be able to
prevent dropouts due to short  CPU load spikes. however (unless you
really max out your CPU for longer periods) the elasticity is limited,
and is basically a function of your "audiobuffer" settings in the
media settings dialog.
so try reducing the audiobuffer, or even run Pd without audio
(depending on your needs) and tune the "-sleepgrain" parameter, to get
a reasonably low jitter.

once you have done that, simply schedule your "security procedures" at
"250-maxjitter" in the future, which should make your system react at
most 250ms in the future, which seems to be what you have been asking for.


fgmasdr
IOhannes
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAlCQ3DoACgkQkX2Xpv6ydvQDCQCeLvlL4P4+zFNYJJ4zq8Tf3ivP
fQgAoNY89PqwCmFeaY/fra20itN75fTl
=WlDi
-----END PGP SIGNATURE-----



More information about the Pd-list mailing list