All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [Xenomai-help] periodical task in posix skin
@ 2010-08-24 13:16 Ramon
  0 siblings, 0 replies; 7+ messages in thread
From: Ramon @ 2010-08-24 13:16 UTC (permalink / raw)
  To: Xenomai help

Hi,

I'm sorry in my previous email I made an error.

If I use

clock_gettime      ( TIMER_ABSTIME, &now);
now.tv_nsec=now.tv_nsec+PERIOD;
out=pthread_make_periodic_np (pthread_self(), &now,&period);
......

it always says that "the start time has already passed\n". Differently 
if I use

clock_gettime      ( CLOCK_REALTIME, &now);
        now.tv_nsec=now.tv_nsec+PERIOD;
        out=pthread_make_periodic_np (pthread_self(), &now,&period);

  everything works fine.


Ramon


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Xenomai-help] periodical task in posix skin
  2010-08-24 13:09       ` Ramon
@ 2010-08-24 13:11         ` Gilles Chanteperdrix
  0 siblings, 0 replies; 7+ messages in thread
From: Gilles Chanteperdrix @ 2010-08-24 13:11 UTC (permalink / raw)
  To: ramoncostacastello; +Cc: Xenomai help

Ramon wrote:
> On 24/08/2010 14:13, Gilles Chanteperdrix wrote:
>> ramon costa wrote:
>>    
>>> Any suggestion to substitute pthread_make_periodic_np and  pthread_wait_np
>>> in a POSIX skin ?
>>>      
>> clock_nanosleep with TIMER_ABSTIME.
>>
>>
>>    
> 
> Unfortunatelly,  clock_nanosleep is a relative delay while 
> pthread_make_periodic_n is an absolute one, as a consequence the 
> behaviour is different.

TIMER_ABSTIME means absolute delay.

-- 
					    Gilles.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Xenomai-help] periodical task in posix skin
  2010-08-24 12:13     ` Gilles Chanteperdrix
@ 2010-08-24 13:09       ` Ramon
  2010-08-24 13:11         ` Gilles Chanteperdrix
  0 siblings, 1 reply; 7+ messages in thread
From: Ramon @ 2010-08-24 13:09 UTC (permalink / raw)
  To: Gilles Chanteperdrix; +Cc: Xenomai help

On 24/08/2010 14:13, Gilles Chanteperdrix wrote:
> ramon costa wrote:
>    
>> Any suggestion to substitute pthread_make_periodic_np and  pthread_wait_np
>> in a POSIX skin ?
>>      
> clock_nanosleep with TIMER_ABSTIME.
>
>
>    

Unfortunatelly,  clock_nanosleep is a relative delay while 
pthread_make_periodic_n is an absolute one, as a consequence the 
behaviour is different.

Ramon



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Xenomai-help] periodical task in posix skin
  2010-08-24 10:25   ` ramon costa
@ 2010-08-24 12:13     ` Gilles Chanteperdrix
  2010-08-24 13:09       ` Ramon
  0 siblings, 1 reply; 7+ messages in thread
From: Gilles Chanteperdrix @ 2010-08-24 12:13 UTC (permalink / raw)
  To: ramon costa; +Cc: Xenomai help

ramon costa wrote:
> Any suggestion to substitute pthread_make_periodic_np and  pthread_wait_np
> in a POSIX skin ?

clock_nanosleep with TIMER_ABSTIME.


-- 
					    Gilles.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Xenomai-help] periodical task in posix skin
  2010-08-23 20:23 ` Gilles Chanteperdrix
@ 2010-08-24 10:25   ` ramon costa
  2010-08-24 12:13     ` Gilles Chanteperdrix
  0 siblings, 1 reply; 7+ messages in thread
From: ramon costa @ 2010-08-24 10:25 UTC (permalink / raw)
  To: Gilles Chanteperdrix; +Cc: Xenomai help

[-- Attachment #1: Type: text/plain, Size: 1732 bytes --]

Hi,


>
> > I also have tried
> >
> >        struct timespec period;
> >        period.tv_sec=0;
> >        period.tv_nsec=PERIOD;
> >
> >         clock_gettime      ( CLOCK_REALTIME, &now);
> >         pthread_make_periodic_np (pthread_self(), &now,&period);
> >
> > Although both compile and execute, non of them works fine to me. Any clue
> ?
>
> Here I have no clue, more exactly, I would need to see the whole code to
> see what is going wrong. But again, checking pthread_make_periodic_np
> return value, and looking at the documentation would help. My guess
> would be that at the time of pthread_make_periodic_np, "now" is a date
> in the past.
>

Yes !!! You are completelly right !!

I was following RTLinux scheme and that made me to fail.
Current code is :

clock_gettime      ( TIMER_ABSTIME, &now);
now.tv_nsec=now.tv_nsec+PERIOD;
out=pthread_make_periodic_np (pthread_self(), &now,&period);
       switch(out){
         case 0 :
          break;
         case ESRCH:
        printf("thread is invalid \n");
        pthread_exit ((void *)-1);
          break;
         case ETIMEDOUT :
        printf("the start time has already passed\n");
        pthread_exit ((void *)-1);
          break;
         default :
        printf(" output value not defined \n");
            pthread_exit ((void *)-1);
    }




>
> And pthread_make_periodic_np/pthread_wait_np are supposed to help
> porting code from RTLinux, they should not be used in new programs. You
> should be using clock_gettime with the TIMER_ABSTIME flag.
>

This is very useful for porting from RTLinux which is exactly what I'm
doing.

Any suggestion to substitute pthread_make_periodic_np and  pthread_wait_np
in a POSIX skin ?



Thank you very much
Ramon

[-- Attachment #2: Type: text/html, Size: 2382 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Xenomai-help] periodical task in posix skin
  2010-08-23 18:59 ramon costa
@ 2010-08-23 20:23 ` Gilles Chanteperdrix
  2010-08-24 10:25   ` ramon costa
  0 siblings, 1 reply; 7+ messages in thread
From: Gilles Chanteperdrix @ 2010-08-23 20:23 UTC (permalink / raw)
  To: ramon costa; +Cc: Xenomai help

ramon costa wrote:
> Hi,
> 
> I have developed a very simple task in native code and it works fine
> (included in native.tar.gz). This
> simple task generates a square waveform through the parallel port ( and also
> the speaker).
> 
> Currently I'm trying to transform this code into the POSIX skin (Makefile
> and .c included in posix,tar.gz).
> Unfortunatelly It does not work, although the parallel port shows a square
> waveform its period is not the desired
> one (0.1ms), its period is very small. This makes the system to freeze.
> 
> It seems that pthread_wait_np is not working properly, or may be I'm not
> using pthread_make_periodic_np
> properly. I used it in the following way :
> 
>         #define PERIOD 100000
> 
>         clock_gettime      ( CLOCK_REALTIME, &now);
>         pthread_make_periodic_np (pthread_self(), &now, (struct timespec
> *)PERIOD);

Well, the reason why this does not work is obvious, I am even amazed
that it does not cause a segmentation fault, but you could check
pthread_make_periodic_np return value to have a clue.

> I also have tried
> 
>        struct timespec period;
>        period.tv_sec=0;
>        period.tv_nsec=PERIOD;
> 
>         clock_gettime      ( CLOCK_REALTIME, &now);
>         pthread_make_periodic_np (pthread_self(), &now,&period);
> 
> Although both compile and execute, non of them works fine to me. Any clue ?

Here I have no clue, more exactly, I would need to see the whole code to
see what is going wrong. But again, checking pthread_make_periodic_np
return value, and looking at the documentation would help. My guess
would be that at the time of pthread_make_periodic_np, "now" is a date
in the past.

And pthread_make_periodic_np/pthread_wait_np are supposed to help
porting code from RTLinux, they should not be used in new programs. You
should be using clock_gettime with the TIMER_ABSTIME flag.

-- 
					    Gilles.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Xenomai-help] periodical task in posix skin
@ 2010-08-23 18:59 ramon costa
  2010-08-23 20:23 ` Gilles Chanteperdrix
  0 siblings, 1 reply; 7+ messages in thread
From: ramon costa @ 2010-08-23 18:59 UTC (permalink / raw)
  To: Xenomai help


[-- Attachment #1.1: Type: text/plain, Size: 1131 bytes --]

Hi,

I have developed a very simple task in native code and it works fine
(included in native.tar.gz). This
simple task generates a square waveform through the parallel port ( and also
the speaker).

Currently I'm trying to transform this code into the POSIX skin (Makefile
and .c included in posix,tar.gz).
Unfortunatelly It does not work, although the parallel port shows a square
waveform its period is not the desired
one (0.1ms), its period is very small. This makes the system to freeze.

It seems that pthread_wait_np is not working properly, or may be I'm not
using pthread_make_periodic_np
properly. I used it in the following way :

        #define PERIOD 100000

        clock_gettime      ( CLOCK_REALTIME, &now);
        pthread_make_periodic_np (pthread_self(), &now, (struct timespec
*)PERIOD);

I also have tried

       struct timespec period;
       period.tv_sec=0;
       period.tv_nsec=PERIOD;

        clock_gettime      ( CLOCK_REALTIME, &now);
        pthread_make_periodic_np (pthread_self(), &now,&period);

Although both compile and execute, non of them works fine to me. Any clue ?


Best wishes,
Ramon

[-- Attachment #1.2: Type: text/html, Size: 1281 bytes --]

[-- Attachment #2: native.tar.gz --]
[-- Type: application/x-gzip, Size: 1394 bytes --]

[-- Attachment #3: posix.tar.gz --]
[-- Type: application/x-gzip, Size: 1575 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-08-24 13:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-24 13:16 [Xenomai-help] periodical task in posix skin Ramon
  -- strict thread matches above, loose matches on Subject: below --
2010-08-23 18:59 ramon costa
2010-08-23 20:23 ` Gilles Chanteperdrix
2010-08-24 10:25   ` ramon costa
2010-08-24 12:13     ` Gilles Chanteperdrix
2010-08-24 13:09       ` Ramon
2010-08-24 13:11         ` Gilles Chanteperdrix

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.