xenomai.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Julien Blanc <julien.blanc@sprinte.eu>
To: "ruiqurm@gmail.com" <ruiqurm@gmail.com>,
	"xenomai@lists.linux.dev" <xenomai@lists.linux.dev>
Subject: Re: Issue with std::mutex when porting POSIX program to Xenomai 3
Date: Tue, 26 Mar 2024 09:46:25 +0000	[thread overview]
Message-ID: <2783a56721258c8b0661fceb4589c8119c00fb96.camel@sprinte.eu> (raw)
In-Reply-To: <TYZPR04MB642556FC09A8013E8B51B9FDAA352@TYZPR04MB6425.apcprd04.prod.outlook.com>

Le mardi 26 mars 2024 à 09:13 +0000, Sam Chiu a écrit :
> Dear Xenomai Community,
> 
> 
> So maybe I should consider replacing std::mutex with pthread_mutex.  However, before proceeding, I would like to inquire if
> there are better
>  approaches or solutions for porting POSIX C++ programs that utilize std::mutex.

std::mutex is not posix, it's C++. Whether or not it will make posix calls, and which calls it will make, is completely up to your
libc++ implementation.

If you plan on using std::xx calls from xenomai threads, it will usually not work: you would need a xenomai-compatible libc++, and
i'm not aware of any. Some calls might happen to work, some won't, and there is just no guarantee that a lib update will not break
things. If you plan on using std::xx calls from regular linux threads, inside a xenomai application, you will need to disable
cobalt wrappers.

The way we solved this is by implementing our own xenomai::mutex, which resembles std's one, and uses wrapped pthread_mutex_xx
calls. This also allows us to compile to regular posix, for test purposes.

Regards,

Julien

  reply	other threads:[~2024-03-26  9:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-26  9:13 Issue with std::mutex when porting POSIX program to Xenomai 3 Sam Chiu
2024-03-26  9:46 ` Julien Blanc [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-03-28  2:31 Sam Chiu
2024-03-28  8:24 ` Julien Blanc
2024-03-28  8:42 Sam Chiu

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=2783a56721258c8b0661fceb4589c8119c00fb96.camel@sprinte.eu \
    --to=julien.blanc@sprinte.eu \
    --cc=ruiqurm@gmail.com \
    --cc=xenomai@lists.linux.dev \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).