All of lore.kernel.org
 help / color / mirror / Atom feed
From: Huy Cong Vu <huy-cong.vu@wandercraft.eu>
To: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai] Differents switch mode from differents Xenomai skin
Date: Wed, 24 Dec 2014 10:30:18 +0100 (CET)	[thread overview]
Message-ID: <2022750954.117025.1419413418676.JavaMail.zimbra@wandercraft.eu> (raw)
In-Reply-To: <1579728558.117024.1419413400904.JavaMail.zimbra@wandercraft.eu>



----- Mail original -----
> De: "Gilles Chanteperdrix" <gilles.chanteperdrix@xenomai.org>
> À: "Huy Cong Vu" <huy-cong.vu@wandercraft.eu>
> Cc: xenomai@xenomai.org
> Envoyé: Mercredi 24 Décembre 2014 01:29:12
> Objet: Re: [Xenomai] Differents switch mode from differents Xenomai skin

> On Tue, Dec 23, 2014 at 05:58:42PM +0100, Huy Cong Vu wrote:
>> 
>> 
>> ----- Mail original -----
>> > De: "Gilles Chanteperdrix" <gilles.chanteperdrix@xenomai.org>
>> > À: "Huy Cong Vu" <huy-cong.vu@wandercraft.eu>
>> > Cc: xenomai@xenomai.org
>> > 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" <gilles.chanteperdrix@xenomai.org>
>> >> > À: "Huy Cong Vu" <huy-cong.vu@wandercraft.eu>
>> >> > Cc: xenomai@xenomai.org
>> >> > 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() ).
> 
> Enabling this bit, causes every switch to secondary mode of the
> thread where you enabled it to send a signal to that thread. I do
> not understand what is so hard to understand about this.

Ok, so I guess I didn't understand this wrongly at least.  

Suppose that I remove PTHREAD_WARNSW bit, here what I got in output: 
SOEM (Simple Open EtherCAT Master)
Simple test
Starting posix test
Mode switch (reason bad functions call while holding mutex, or other unknown issue), aborting. Backtrace:
./posix_minimal[0x401bf6]
/lib/x86_64-linux-gnu/libpthread.so.0(+0xfcb0)[0x7f94ef972cb0]
/usr/xenomai/lib/libpthread_rt.so.1(__wrap_send+0xd5)[0x7f94efd8f9f5]
./posix_minimal[0x4017dc]
./posix_minimal[0x4016ed]
./posix_minimal[0x4011cd]
/usr/xenomai/lib/libpthread_rt.so.1(+0x5b45)[0x7f94efd8cb45]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x7e9a)[0x7f94ef96ae9a]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x6d)[0x7f94ef28d3fd]
Temps UCT limite expiré (core dumped)

It is the same output as when PTHREAD_WARNSW is active. Could you give me some hints why?

> 
> --
> 					    Gilles.

-- 
Huy Cong
Wandercraft SAS


  parent reply	other threads:[~2014-12-24  9:30 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-18 11:30 [Xenomai] Differents switch mode from differents Xenomai skin Huy Cong Vu
2014-12-18 14:05 ` Gilles Chanteperdrix
     [not found]   ` <530357014.99522.1418920882907.JavaMail.zimbra@wandercraft.eu>
2014-12-18 16:41     ` Huy Cong Vu
2014-12-18 17:43       ` Gilles Chanteperdrix
     [not found]         ` <1886500835.102755.1418982478388.JavaMail.zimbra@wandercraft.eu>
2014-12-19 10:31           ` Gilles Chanteperdrix
     [not found]             ` <873251.115805.1419351709840.JavaMail.zimbra@wandercraft.eu>
2014-12-23 16:23               ` Huy Cong Vu
2014-12-23 16:35                 ` Gilles Chanteperdrix
     [not found]                   ` <1247107386.116030.1419353010523.JavaMail.zimbra@wandercraft.eu>
2014-12-23 16:43                     ` Huy Cong Vu
2014-12-23 16:46                       ` Gilles Chanteperdrix
     [not found]                         ` <473658337.116296.1419353916760.JavaMail.zimbra@wandercraft.eu>
2014-12-23 16:58                           ` Huy Cong Vu
2014-12-24  0:29                             ` Gilles Chanteperdrix
     [not found]                               ` <1579728558.117024.1419413400904.JavaMail.zimbra@wandercraft.eu>
2014-12-24  9:30                                 ` Huy Cong Vu [this message]
2014-12-24 14:49                                   ` Gilles Chanteperdrix
     [not found]                                     ` <122317517.130963.1420453826355.JavaMail.zimbra@wandercraft.eu>
2015-01-05 10:30                                       ` Huy Cong Vu
2015-01-05 16:58                                         ` Gilles Chanteperdrix
     [not found]                                           ` <53399875.136328.1420535338904.JavaMail.zimbra@wandercraft.eu>
2015-01-06  9:09                                             ` Huy Cong Vu
2015-01-06  9:16                                               ` Gilles Chanteperdrix
     [not found]                                                 ` <406329870.136348.1420536332444.JavaMail.zimbra@wandercraft.eu>
2015-01-06  9:34                                                   ` Huy Cong Vu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2022750954.117025.1419413418676.JavaMail.zimbra@wandercraft.eu \
    --to=huy-cong.vu@wandercraft.eu \
    --cc=gilles.chanteperdrix@xenomai.org \
    --cc=xenomai@xenomai.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.