Skip to contentSkip to conversation

thread and posix skin

Xenomai-help Alessio Margan @ IIT 2 participants 2 messages Jan 18, 2010

lore
Share & tools
lore
#0 lore raw

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

Signature · 15 lines
ISTITUTO ITALIANO
DI TECNOLOGIA

Alessio Margan
/Senior Technician/
mail me <mailto:[email protected]>

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.
#1 lore raw
Quoted 5 lines · 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.

Quoted 3 lines

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.

Quoted 3 lines

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

Signature · 1 line
					    Gilles.