All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tobias Luksch <Tobias.Luksch@itk-engineering.de>
To: Philippe Gerum <rpm@xenomai.org>,
	"xenomai@xenomai.org" <xenomai@xenomai.org>
Subject: Re: [Xenomai] Multiple processes within same session
Date: Tue, 13 Sep 2016 08:48:48 +0000	[thread overview]
Message-ID: <96de570c4780415e98b93f5b7a96f83c@itk-engineering.de> (raw)
In-Reply-To: <dcec62b2-a521-1696-3184-0975b389198e@xenomai.org>

> On 09/06/2016 05:38 PM, Tobias Luksch wrote:
> > Hello,
> >
> > [Arch:x86, Processor:Corei7, Kernel: 4.1.18, Xenomai:3.0.2]
> >
> > we are using several Xenomai processes communicating using shared
> memory (rt_heap) and a few named mutexes. The processes also create
> additional unnamed task, mutexes, semaphores, etc.
> > After porting to Xenomai 3, I see the following problem: To access the
> shared heap, I start two processes within the same session (--session from
> command line). Shared access to the heap works, but when creating
> unnamed objects, e.g. a mutex, in the second process, rt_mutex_create
> returns -17.
> >
> > Here is a small example program to reproduce this:
> >
> > #include <alchemy/task.h>
> > #include <alchemy/mutex.h>
> > #include <stdio.h>
> >
> > int main(int argc, char* argv[])
> > {
> > 	rt_printf("hello  world\n");
> > 	RT_MUTEX mutex;
> > 	int ret_val = rt_mutex_create( &mutex, NULL );
> > 	rt_printf( "rt_mutex_create: %d\n", ret_val );
> >
> > 	while (true)
> > 	{
> > 		rt_task_sleep(1000000000);
> > 		rt_printf("ping\n");
> > 	}
> > 	return 0;
> > }
> >
> > Starting this program (called xeno-test here) once gives:
> > $ ./xeno-test --session=test
> > hello  world
> > rt_mutex_create: 0
> > ping
> > ping
> > [..]
> >
> > Starting it a second time with the same session:
> > $ ./xeno-test --session=test
> > hello  world
> > rt_mutex_create: -17
> > ping
> > ping
> > [..]
> >
> > Starting the program another time with a different session works without
> error. Also using differently named mutexes for both instances works.
> >
> > I am not sure about the naming mechanism (if any) when creating
> unnamed objects like mutexes, nor about what is actually shared between
> processes when using the same session. It would be great if anyone could
> give some details on this.
> >
> > Any help would be appreciated.
> 
> This patch should address the issue:
> 
> commit e539ab0b1db5ca56f8d3db39d2ca0bdf009c9b25
> Author: Philippe Gerum <rpm@xenomai.org>
> Date:   Tue Sep 13 09:36:11 2016 +0200
> 
>     boilerplate/ancillaries: fix unique name generation in pshared mode
> 
> diff --git a/lib/boilerplate/ancillaries.c b/lib/boilerplate/ancillaries.c
> index a811a40..0f469a4 100644
> --- a/lib/boilerplate/ancillaries.c
> +++ b/lib/boilerplate/ancillaries.c
> @@ -231,7 +231,11 @@ char *generate_name(char *buf, const char *radix,
>  		buf[len] = '\0';
>  	} else {
>  		tag = atomic_add_fetch(&ngen->serial, 1);
> +#ifdef CONFIG_XENO_PSHARED
> +		snprintf(buf, len, "%s@%d[%d]", ngen->radix, tag,
> __node_id);
> +#else
>  		snprintf(buf, len, "%s@%d", ngen->radix, tag);
> +#endif
>  	}
> 
>  	return buf;
> 

Thank you for the patch, we will test it soon and give feedback on the result.

Tobias



      reply	other threads:[~2016-09-13  8:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-06 15:38 [Xenomai] Multiple processes within same session Tobias Luksch
2016-09-11 13:29 ` Philippe Gerum
2016-09-13  7:37 ` Philippe Gerum
2016-09-13  8:48   ` Tobias Luksch [this message]

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=96de570c4780415e98b93f5b7a96f83c@itk-engineering.de \
    --to=tobias.luksch@itk-engineering.de \
    --cc=rpm@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.