From: yo sang <stlfatboy@hotmail.com>
To: Philippe Gerum <rpm@xenomai.org>
Cc: "xenomai@lists.linux.dev" <xenomai@lists.linux.dev>
Subject: RE: data modified by second NRT write with same memory location
Date: Thu, 3 Aug 2023 01:03:12 +0000 [thread overview]
Message-ID: <DM6PR14MB38713771375803FD8C2FBF0FA308A@DM6PR14MB3871.namprd14.prod.outlook.com> (raw)
In-Reply-To: <87bkfpes2u.fsf@xenomai.org>
Thank you again for the detailed explanation, it really help.
It's my mistake for using private pointer for XDDP. ^-^
-----Original Message-----
From: Philippe Gerum <rpm@xenomai.org>
Sent: Wednesday, August 2, 2023 4:57 PM
To: yo sang <stlfatboy@hotmail.com>
Cc: xenomai@lists.linux.dev
Subject: Re: data modified by second NRT write with same memory location
yo sang <stlfatboy@hotmail.com> writes:
> Thanks for the reply.
>
> I still have several doubts:
> 1. it's very common to delete data right after calling write(). Data should be completely copied to ensure a successful write() call.
>
Except that your code is simply not doing that. Please read it again. Hint: this implementation introduces sharing by mean of a pointer.
> 2. The fd opened for nrt is blocking by default. If I'm using un-blocking way of write(), it's reasonable to maintain several distinct RTMem instances at write end.
>
This is not the point in discussion. The issue is with the broken indirection the pointer adds.
> 3. If I modify the RTMem class as below, the result is correct then:
>
> class RTMem
> {
> public:
> RTMem() {}
>
> RTMem(const char* data, int size, RTMemType type) {
> //Data = Buf;
> memcpy(Data, data, size);
> Size = size;
> Type = type;
> }
>
> int Size{};
> RTMemType Type{};
> //char* Data{};
> char Data[256]{};
>
> };
Obviously it is, indeed.
--
Philippe.
prev parent reply other threads:[~2023-08-03 1:03 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <DM6PR14MB3871876E6E078D3BE974ADCBA30AA@DM6PR14MB3871.namprd14.prod.outlook.com>
2023-08-01 9:18 ` data modified by second NRT write with same memory location yo sang
2023-08-01 17:29 ` Philippe Gerum
2023-08-02 1:19 ` yo sang
2023-08-02 6:04 ` yo sang
2023-08-02 7:30 ` Philippe Gerum
2023-08-02 8:14 ` dietmar.schindler
2023-08-02 9:01 ` Philippe Gerum
2023-08-02 8:32 ` yo sang
2023-08-02 8:56 ` Philippe Gerum
2023-08-03 1:03 ` yo sang [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=DM6PR14MB38713771375803FD8C2FBF0FA308A@DM6PR14MB3871.namprd14.prod.outlook.com \
--to=stlfatboy@hotmail.com \
--cc=rpm@xenomai.org \
--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).