----- Mail original -----
> De: "Gilles Chanteperdrix" <[email protected]>
> À: "Huy Cong Vu" <[email protected]>
> Cc: [email protected]
> Envoyé: Mardi 23 Décembre 2014 17:46:59
> Objet: Re: [Xenomai] Differents switch mode from differents Xenomai skin

> On Tue, Dec 23, 2014 at 05:43:41PM +0100, Huy Cong Vu wrote:
>> 
>> 
>> ----- Mail original -----
>> > De: "Gilles Chanteperdrix" <[email protected]>
>> > À: "Huy Cong Vu" <[email protected]>
>> > Cc: [email protected]
>> > Envoyé: Mardi 23 Décembre 2014 17:35:35
>> > Objet: Re: [Xenomai] Differents switch mode from differents Xenomai skin
>> 
>> > On Tue, Dec 23, 2014 at 05:23:07PM +0100, Huy Cong Vu wrote:
>> >> void mini( void *ptr )
>> >> {
>> >> 
>> >> 
>> >>   uint8_t b;
>> >>   int ret1;
>> >>   int idx;
>> >> 
>> >>   pthread_set_mode_np(0, PTHREAD_WARNSW);
>> >>    printf("Starting posix test\n");
>> >> 
>> >>   ec_port = malloc(sizeof(ecx_portt*));
>> >> 
>> >>   if (setup_nic(ec_port,"rteth0") > 0) {
>> >>              idx = getindex (ec_port);
>> >>                   /* setup datagram */
>> >>                   b = 0x0000;
>> >>                   setupdatagram (ec_port, &(ec_port->txbuf[idx]),0x0009, 
>> >> idx, 0x0000, 0x0103,
>> >>                   sizeof(b), &b );
>> >>                   /* send data and wait for answer */
>> >>                   wkc = srconfirm (ec_port, idx, EC_TIMEOUTRET3);
>> >>   }
>> >>   
>> >> }
>> > 
>> > Typically, as I already explained, what you do here is wrong: you
>> > should not arm the PTHREAD_WARNSW bit before call such as malloc or
>> > the calls in setup_nic, which switch to secondary mode.
>> 
>> Ok, should I call it laterly? It is just for detect mode switch
>> reason in fact
> 
> How to use PTHREAD_WARNSW is thoroughly documented, see:
> https://xenomai.org/2014/06/finding-spurious-relaxes/
> 

So perhaps I was misunderstanding this statement?
Then, you need to enable the warn_upon_switch capability on a per-thread basis. 
For instance, a POSIX-based application would run this code from the thread to 
monitor for spurious relaxes:

    /* Ask Xenomai to warn us upon switches to secondary mode. */
    pthread_set_mode_np(0, PTHREAD_WARNSW);

Does that means that I must put the line into the thread with function calls 
that cause mode switch?
I thought it means that I have to put the line in the threads of my program (in 
my case mini() ).

> --
>                                           Gilles.

-- 
Huy Cong
Wandercraft SAS

_______________________________________________
Xenomai mailing list
[email protected]
http://www.xenomai.org/mailman/listinfo/xenomai

Reply via email to