* [Xenomai-help] thread and posix skin
@ 2010-01-18 14:45 Alessio Margan @ IIT
2010-01-18 14:52 ` Gilles Chanteperdrix
0 siblings, 1 reply; 2+ messages in thread
From: Alessio Margan @ IIT @ 2010-01-18 14:45 UTC (permalink / raw)
To: xenomai@xenomai.org
Hi,
I've got problem using pthread_make_periodic_np and pthread_wait_np.
Should I make some particular initializations ?
CONFIG_XENO_OPT_TIMING_PERIOD=y have sense ?
In the examples and testsuite I 've just seen the use of clock_nanosleep
with pthread,
should I use it instead of pthread_make_periodic_np ?
This is the thread routine, I get error on pthread_wait_np() return code
110.
void * rt_thread(void * arg, rt_thread_hook_t * hook)
{
thread_info_t * th_info = (thread_info_t *)arg;
int ret = 0;
struct timespec starttp, periodtp;
//
if ( hook ) { hook->init(0); }
printf("THREAD INIT: name = %s, period %ld us\n",
th_info->name, th_info->period.period.tv_usec);
ret = pthread_set_name_np(pthread_self(), th_info->name);
if ( ret != 0 ) {
printf("%s : pthread_set_name_np() return code %d\n",
th_info->name, ret);
exit(1);
}
periodtp.tv_sec = 0ULL;
periodtp.tv_nsec = th_info->period.period.tv_usec * 1000ULL;
clock_gettime(CLOCK_REALTIME, &starttp);
starttp.tv_sec += 1ULL;
starttp.tv_nsec += periodtp.tv_nsec;
ret = pthread_make_periodic_np(pthread_self(), &starttp, &periodtp);
if ( ret != 0 ) {
printf("%s : pthread_make_periodic_np() return code %d\n",
th_info->name, ret);
exit(1);
}
while (loop) {
if ( hook ) { hook->loop(0); }
// return 0 if the period expires as expected
ret = pthread_wait_np(NULL);
if ( ret != 0 ) {
printf("%s : pthread_wait_np() return code %d\n", th_info->name, ret);
exit(1);
}
}
//
if ( hook ) { hook->shutdown(0); }
printf("THREAD %s ENDS\n", th_info->name);
return 0;
}
TIA
Alessio
--
ISTITUTO ITALIANO
DI TECNOLOGIA
Alessio Margan
/Senior Technician/
mail me <mailto:alessio.margan@domain.hid>
Via Morego, 30 16163 Genova
<http://maps.google.com/maps?f=q&hl=en&geocode=&q=via+morego,+30+genova&sll=37.0625,-95.677068&sspn=85.420533,191.601563&ie=UTF8&ll=44.474913,8.907037&spn=0.004685,0.011652&t=h&z=17&iwloc=addr>
www.iit.it <http://www.iit.it>
*Legal Disclaimer*
This electronic message contains information that is confidential. The
information is intended for the use of the addressee only. If you are
not the addressee we would appreciate your notification in this respect.
Please note that any disclosure, copy, distribution or use of the
contents of this message is prohibited and may be unlawful. We have
taken every reasonable precaution to ensure that any kind of attachment
to this e-mail has been swept for viruses. However, we cannot accept
liability for any damage sustained as a result of software viruses and
would advise you to carry out your own virus checks before opening any
attachment.
*Avvertenza legale*
Questo messaggio Email contiene informazioni confidenziali riservate ai
soli destinatari. Qualora veniate in possesso di tali informazioni senza
essere definito come destinatario vi reghiamo di leggere le seguenti
note. Ogni apertura, copia, distribuzione del contenuto del messaggio e
dei suoi allegati è proibito e potrebbe violare le presenti leggi.
Abbiamo attivato ogni possibile e ragionevole precauzione per assicurare
che gli allegati non contengano virus. Comunque non assumeremo alcuna
responsabilità per ogni eventuale danno causato da virus software e
simili in quanto è onere del destinatario verificarne l’assenza in ogni
allegato attuando propri indipendenti controlli.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Xenomai-help] thread and posix skin
2010-01-18 14:45 [Xenomai-help] thread and posix skin Alessio Margan @ IIT
@ 2010-01-18 14:52 ` Gilles Chanteperdrix
0 siblings, 0 replies; 2+ messages in thread
From: Gilles Chanteperdrix @ 2010-01-18 14:52 UTC (permalink / raw)
To: Alessio Margan @ IIT; +Cc: xenomai@xenomai.org
Alessio Margan @ IIT wrote:
> Hi,
>
> I've got problem using pthread_make_periodic_np and pthread_wait_np.
> Should I make some particular initializations ?
> CONFIG_XENO_OPT_TIMING_PERIOD=y have sense ?
It is unrelated. CONFIG_XENO_OPT_TIMING_PERIODIC means that you request
a periodic timer instead of the default which is one-shot. Which means
all your wake-ups will be aligned on timer ticks.
> In the examples and testsuite I 've just seen the use of clock_nanosleep
> with pthread,
> should I use it instead of pthread_make_periodic_np ?
As you wish.
>
> This is the thread routine, I get error on pthread_wait_np() return code
> 110.
Can't tell, your sample code does not compile here. 110 is ETIMEDOUT, it
is usually returned when the start time has already passed. As
documented here:
http://www.xenomai.org/documentation/xenomai-2.5/html/api/group__posix__thread.html#gafe8deaa3c89e0a07e59f0e58f9ec1473
--
Gilles.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-01-18 14:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-18 14:45 [Xenomai-help] thread and posix skin Alessio Margan @ IIT
2010-01-18 14:52 ` 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.