I updated from rtlV2.2 to V3.0p10 and found a different behaviour of pthread_make_periodic_np(...,...,0). In V2.2 it works as suspected: The thread is called once and is sentenced to wait with a pthread_wait_np() afterwards. In V3.0p10 the call of pthread_wait_np() blocks the thread forever.
Code example:
void *thread_code(void *param)
{
// blabla
--------------- snip -----------------------------------------------
do
{
min_diff = 2000000000;
max_diff = -2000000000;
for (i = 0; i < ntests; i++)
{
now = clock_gethrtime(rtl_getschedclock());
if (advance && !mode)
{
if (now < expected)
{
rtl_delay (expected - now);
}
now = clock_gethrtime(CLOCK_UST);
}
/* start of next time element */
do_rayonic_start();
do_rayonic(loops);
do_rayonic_fini();
/* finished user part of measurement */
fini = clock_gethrtime(rtl_getschedclock());
samp.fini = fini;
/* calculate time for next activation */
/* 1) difference from expectation */
diff = now - expected;
samp.diff = diff;
if (diff < min_diff)
{
min_diff = diff;
}
if (diff > max_diff)
{
max_diff = diff;
}
/* 2) theoretical sleeping duration */
sleepfor = CYCLETIME-(fini-now);
samp.sleepfor = sleepfor;
/* 3) adaptive control towards expected time */
sleepfor -= diff;
/* 4) avoid processor overload */
expected += CYCLETIME;
while (sleepfor < MAXLOAD)
{
sleepfor += CYCLETIME;
expected += CYCLETIME;
samp.skipped ++;
}
/* 5) absolute time for reactivation */
sleepto = (now+sleepfor);
samp.sleepto = sleepto;
pthread_make_periodic_np (pthread_self(),sleepto,0);
//++++++++++++++++++++++++++++++++++++++++++++++++
// In V3.0p10 the next call blocks the thread forever,
// in V2.2 it works properly....
//++++++++++++++++++++++++++++++++++++++++++++++++
pthread_wait_np();
}
samp.min = min_diff;
samp.max = max_diff;
write (fifo_monitor, &samp, sizeof(samp));
} while (1); // endless...
----------------- snap -----------------------------------------------------------
} // thread end
Any hints will be welcome!
Peter
Peter Helbig Rayonic Sensor Systems GmbH Entwicklung Software Bayreuther Strasse 108 D-91301 Forchheim Tel: ++49 (0) 9191 72 818-0 Fax: ++49 (0) 9191 640 333 Email: [EMAIL PROTECTED] http://www.rayonic.de -- [rtl] --- To unsubscribe: echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR echo "unsubscribe rtl" | mail [EMAIL PROTECTED] --- For more information on Real-Time Linux see: http://www.rtlinux.org/rtlinux/
