* [Xenomai-help] pthread_make_periodic_np and clock_gettime
@ 2007-02-13 12:07 Roderik_Wildenburg
2007-02-13 19:20 ` Jan Kiszka
0 siblings, 1 reply; 4+ messages in thread
From: Roderik_Wildenburg @ 2007-02-13 12:07 UTC (permalink / raw)
To: Xenomai-help
[-- Attachment #1: Type: text/plain, Size: 733 bytes --]
Can anybody tell me, how I have to set the 2. parameter (starttp) of
pthread_make_periodic_np ?
When I use clock_gettime to fill startp I get a giant timeout value in
the /proc/xenomai/sched list and my task never gets periodic.
Is this just a problem of my hardware(PPC)/xenomai(2.3) combination or
does anybody else have the same problem.
See attached code example for easier testing.
Thanks a lot for your help
Roderik
MAN Roland Druckmaschinen AG
Vorsitzender des Aufsichtsrates: Hanno C. Fiedler
Vorstand: Gerd Finkbeiner (Vorsitzender), Dr. Ingo Koch, Dr. Markus Rall, Paul Steidle
Sitz der Gesellschaft: Offenbach am Main, Registergericht: Amtsgericht Offenbach HRB-Nr. 42592
USt-Ident-Nr. DE 250200933
[-- Attachment #2: pperiodic.c --]
[-- Type: application/octet-stream, Size: 2144 bytes --]
#include <time.h>
#include <errno.h>
#include <unistd.h>
#include <signal.h>
#include <sys/mman.h>
#include <posix/pthread.h>
#include <stdio.h>
#define CYCTASK_PRI 1
#define CYCTASK_STACK_SIZE 8192
pthread_t cyktaskid;
void cyc_task(void *t2dummy)
{
int nResult;
struct timespec tstart;
struct timespec tperiod;
int cyc;
unsigned long nOverrun;
if( (nResult=clock_gettime(CLOCK_REALTIME,&tstart))!=0)
printf("!!WARNING!! clock_gettime failed");
else
printf("clock_gettime : %ld %ld\n",tstart.tv_sec,tstart.tv_nsec);
tstart.tv_sec ++;
tstart.tv_nsec = 100000;
tperiod.tv_sec = 1; // sec
tperiod.tv_nsec = 0; // nsec
printf("period : %ld %ld\n",tperiod.tv_sec,tperiod.tv_nsec);
if (( nResult = pthread_make_periodic_np(pthread_self(),&tstart,&tperiod)) == 0)
{
while (1)
{
printf("CykleTask %d\n",cyc++);
if ((nResult = pthread_wait_np(&nOverrun)) != 0)
printf("systick overrun %d",nOverrun);
}
}
else
{
printf("failed to start timer");
}
}
void __xeno_user_exit (void)
{
}
int __xeno_user_init (void)
{
struct sched_param parm;
pthread_attr_t attr;
int rc = 0, fd = -1;
pthread_attr_init(&attr);
pthread_attr_setinheritsched(&attr, 1);
pthread_attr_setschedpolicy(&attr, SCHED_FIFO);
pthread_attr_setstacksize(&attr, CYCTASK_STACK_SIZE);
parm.sched_priority = CYCTASK_PRI;
pthread_attr_setschedparam(&attr, &parm);
rc = pthread_create(&cyktaskid, &attr, &cyc_task, NULL);
if (rc)
{
printf("pthread_create(cyktask): %d\n", rc);
}
return rc;
}
int main (int ac, char *av[])
{
sigset_t mask;
int rc, sig;
sigemptyset(&mask);
sigaddset(&mask,SIGINT);
sigaddset(&mask,SIGTERM);
sigaddset(&mask,SIGHUP);
sigaddset(&mask,SIGALRM);
pthread_sigmask(SIG_BLOCK, &mask, NULL);
mlockall(MCL_CURRENT|MCL_FUTURE);
rc = __xeno_user_init();
if (rc)
{
printf("__xeno_user_init: %d\n", -rc);
return -rc;
}
sigwait(&mask, &sig);
__xeno_user_exit();
return 0;
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Xenomai-help] pthread_make_periodic_np and clock_gettime
2007-02-13 12:07 [Xenomai-help] pthread_make_periodic_np and clock_gettime Roderik_Wildenburg
@ 2007-02-13 19:20 ` Jan Kiszka
2007-02-13 20:01 ` Gilles Chanteperdrix
0 siblings, 1 reply; 4+ messages in thread
From: Jan Kiszka @ 2007-02-13 19:20 UTC (permalink / raw)
To: Roderik_Wildenburg; +Cc: Xenomai-help
[-- Attachment #1: Type: text/plain, Size: 1134 bytes --]
Roderik_Wildenburg@domain.hid wrote:
> Can anybody tell me, how I have to set the 2. parameter (starttp) of
> pthread_make_periodic_np ?
> When I use clock_gettime to fill startp I get a giant timeout value in
> the /proc/xenomai/sched list and my task never gets periodic.
>
> Is this just a problem of my hardware(PPC)/xenomai(2.3) combination or
> does anybody else have the same problem.
>
> See attached code example for easier testing.
>
Confirmed over v2.3.x in periodic mode, aperiodic is fine. Gilles?
> Thanks a lot for your help
> Roderik
>
> MAN Roland Druckmaschinen AG
> Vorsitzender des Aufsichtsrates: Hanno C. Fiedler
> Vorstand: Gerd Finkbeiner (Vorsitzender), Dr. Ingo Koch, Dr. Markus Rall, Paul Steidle
> Sitz der Gesellschaft: Offenbach am Main, Registergericht: Amtsgericht Offenbach HRB-Nr. 42592
> USt-Ident-Nr. DE 250200933
Hah, I waited for the first footer of this kind appearing on mailing
lists! As far as I understood the new German law, this is not required
when you post to public forums. But probably your corporate mail server
injects this automatically.
Jan
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 250 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Xenomai-help] pthread_make_periodic_np and clock_gettime
2007-02-13 19:20 ` Jan Kiszka
@ 2007-02-13 20:01 ` Gilles Chanteperdrix
2007-02-14 17:44 ` Jan Kiszka
0 siblings, 1 reply; 4+ messages in thread
From: Gilles Chanteperdrix @ 2007-02-13 20:01 UTC (permalink / raw)
To: Jan Kiszka; +Cc: Roderik_Wildenburg, Xenomai-help
Jan Kiszka wrote:
> Roderik_Wildenburg@domain.hid wrote:
> > Can anybody tell me, how I have to set the 2. parameter (starttp) of
> > pthread_make_periodic_np ?
> > When I use clock_gettime to fill startp I get a giant timeout value in
> > the /proc/xenomai/sched list and my task never gets periodic.
> >
> > Is this just a problem of my hardware(PPC)/xenomai(2.3) combination or
> > does anybody else have the same problem.
> >
> > See attached code example for easier testing.
> >
>
> Confirmed over v2.3.x in periodic mode, aperiodic is fine. Gilles?
Ok. I will have a look at it.
--
Gilles Chanteperdrix.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Xenomai-help] pthread_make_periodic_np and clock_gettime
2007-02-13 20:01 ` Gilles Chanteperdrix
@ 2007-02-14 17:44 ` Jan Kiszka
0 siblings, 0 replies; 4+ messages in thread
From: Jan Kiszka @ 2007-02-14 17:44 UTC (permalink / raw)
To: Gilles Chanteperdrix; +Cc: Roderik_Wildenburg, Xenomai-help
[-- Attachment #1: Type: text/plain, Size: 961 bytes --]
Gilles Chanteperdrix wrote:
> Jan Kiszka wrote:
> > Roderik_Wildenburg@domain.hid wrote:
> > > Can anybody tell me, how I have to set the 2. parameter (starttp) of
> > > pthread_make_periodic_np ?
> > > When I use clock_gettime to fill startp I get a giant timeout value in
> > > the /proc/xenomai/sched list and my task never gets periodic.
> > >
> > > Is this just a problem of my hardware(PPC)/xenomai(2.3) combination or
> > > does anybody else have the same problem.
> > >
> > > See attached code example for easier testing.
> > >
> >
> > Confirmed over v2.3.x in periodic mode, aperiodic is fine. Gilles?
>
> Ok. I will have a look at it.
>
Hmm, something went wrong here. I think I passed a too fast tick_arg to
the kernel yesterday which smashed the timing. I'm now running the
pperiodic demo at tick_arg=1000000 successfully.
So, Roderik, either you did some similar mistake, or it's a PPC issue.
Jan
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 250 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-02-14 17:44 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-13 12:07 [Xenomai-help] pthread_make_periodic_np and clock_gettime Roderik_Wildenburg
2007-02-13 19:20 ` Jan Kiszka
2007-02-13 20:01 ` Gilles Chanteperdrix
2007-02-14 17:44 ` Jan Kiszka
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.