Hi,
I want to transfert some data between applications through a memory buffer. The buffer transfert between applications is under control.
My problem is with the buffer content.
I though I'll use a Stream writing/reading in/from the memory buffer.
How can I achieve this ? I've found no example doing this.
Note : I use Ada 2012.
I want to transfert some data between applications through a memory buffer. The buffer transfert between applications is under control.
My problem is with the buffer content.
I though I'll use a Stream writing/reading in/from the memory buffer.
How can I achieve this ? I've found no example doing this.
Note : I use Ada 2012.
Hi,
I want to transfert some data between applications through a memory buffer. The buffer transfert between applications is under control.
My problem is with the buffer content.
I though I'll use a Stream writing/reading in/from the memory
buffer. How can I achieve this ? I've found no example doing this.
Note : I use Ada 2012.
Nicolas
I though I'll use a Stream writing/reading in/from the memory buffer.
On Fri, 16 Feb 2024 10:41:12 +0100, DrPi wrote:
I though I'll use a Stream writing/reading in/from the memory buffer.
Wouldn’t be simplest to let the OS manage the buffering for you?
<https://manpages.debian.org/7/pipe.en.html>
I want to transfert some data between applications through a memory buffer. The buffer transfert between applications is under control.
My problem is with the buffer content.
I though I'll use a Stream writing/reading in/from the memory buffer.
How can I achieve this ? I've found no example doing this.
Note : I use Ada 2012.
The library Jean-Pierre pointed me to perfectly matches this usage.Light and easy to use. Thanks.
One enhancement I see is to manage the buffer size to avoid bufferoverflow (or did I missed something ?).
On the memory side, we are
reading/writing bytes from memory, there is no notion of overflow.
Le 17/02/2024 à 14:36, DrPi a écrit :
The library Jean-Pierre pointed me to perfectly matches this usage.Light and easy to use. Thanks.
:-)
One enhancement I see is to manage the buffer size to avoid bufferoverflow (or did I missed something ?).
I don't see what you mean here... On the memory side, we are
reading/writing bytes from memory, there is no notion of overflow. And
the number of bytes processed by Read/Write is given by the size of
Item, so no overflow either...
Concerning the OS and the buffer transfert mechanism, as I said, this is under control. I use Windows and the WM_COPYDATA message.
My usage is a bit special. The writing process writes a bunch of data in
a memory buffer then requests this buffer to be transferred to another process by way of WM_COPYDATA. The receiving process reads the data from
the "new" memory buffer. I say "new" since the address is different from
the one used in the writing process (of course it can not be the same).
On 2024-02-17 14:36, DrPi wrote:
Concerning the OS and the buffer transfert mechanism, as I said, this
is under control. I use Windows and the WM_COPYDATA message.
My usage is a bit special. The writing process writes a bunch of data
in a memory buffer then requests this buffer to be transferred to
another process by way of WM_COPYDATA. The receiving process reads the
data from the "new" memory buffer. I say "new" since the address is
different from the one used in the writing process (of course it can
not be the same).
You ask Windows to copy a chunk of memory from one process space into another, so yes it is physically different memory. Different or same
address tells nothing because under Windows System.Address is virtual
and can point anywhere.
As you may guess it is a quite heavy overhead, not only because of
copying data between process spaces, but also because of sending and dispatching Windows messages.
Note, that if you implement stream Read/Write as individual Windows
messages it will become extremely slow. GNAT optimizes streaming of some built-in objects, e.g. String. But as a general case you should expect
that streaming of any non-scalar object would cause multiple calls to Read/Write and thus multiple individual Windows messages.
An efficient way to exchange data under Windows is a file mapping. See CreateFileMapping and MapViewOfFile.
https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-createfilemappinga
https://learn.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-mapviewoffile
Then use CreateEvent with a name to signal states of the stream buffer system-wide. Named Windows events are shared between processes.
https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-createeventa
[ This is how interprocess stream is implemented for Windows in Simple Components ]
Note, that if you implement stream Read/Write as individual Windows
messages it will become extremely slow. GNAT optimizes streaming of
some built-in objects, e.g. String. But as a general case you should
expect that streaming of any non-scalar object would cause multiple
calls to Read/Write and thus multiple individual Windows messages.
Le 17/02/2024 à 15:26, J-P. Rosen a écrit :usage. Light and easy to use. Thanks.
Le 17/02/2024 à 14:36, DrPi a écrit :
The library Jean-Pierre pointed me to perfectly matches this
buffer overflow (or did I missed something ?).🙂
One enhancement I see is to manage the buffer size to avoid
the number of bytes processed by Read/Write is given by the size of
I don't see what you mean here... On the memory side, we are reading/writing bytes from memory, there is no notion of overflow. And
or a memory buffer you create yourself (my case). In either case, itsA memory buffer IS limited in size. It is either a peripheral buffer
On 2024-02-16 22:54, Lawrence D'Oliveiro wrote:
On Fri, 16 Feb 2024 10:41:12 +0100, DrPi wrote:
I though I'll use a Stream writing/reading in/from the memory buffer.
Wouldn’t be simplest to let the OS manage the buffering for you?
<https://manpages.debian.org/7/pipe.en.html>
That would make applications OS-dependent.
I can't remember at this distance in time, but I think I would have
liked to construct a memory stream on the received UDP packet rather
than copying the content; the compiler wouldn't let me. Perhaps worth
another try.
A memory buffer IS limited in size. It is either a peripheral buffer or
a memory buffer you create yourself (my case). In either case, its size
is limited. When writing in the stream, you have to care to not overflow
the buffer.
My usage is a bit special. The writing process writes a bunch of data in
a memory buffer then requests this buffer to be transferred to another process by way of WM_COPYDATA.
UDP is a kind of thing... Basically, there is no use of UDP except for broadcasting, e.g. in LAN discovery.
As for taking apart a UDP packet, it is straightforward. You simply
declare a stream element array of the packet size and map it on the
packet using:
pragma Import (Ada, A);
for A'Address use UDP_Packet'Address;
And somewhere
pragma Assert (Stream_Element'Size = 8);
just in case...
On Sat, 17 Feb 2024 14:36:46 +0100, DrPi wrote:
My usage is a bit special. The writing process writes a bunch of data in
a memory buffer then requests this buffer to be transferred to another
process by way of WM_COPYDATA.
I thought Windows had pipes.
On Sat, 17 Feb 2024 14:36:46 +0100, DrPi wrote:
My usage is a bit special. The writing process writes a bunch of data in
a memory buffer then requests this buffer to be transferred to another
process by way of WM_COPYDATA.
I thought Windows had pipes.
OK if the participants all have the same endianness. We used XDR (and
the translation cost is nil if the host is big-endian, as PowerPCs are;
all the critical machines were PowerPC).
On 2024-02-18 01:00, Lawrence D'Oliveiro wrote:
On Sat, 17 Feb 2024 14:36:46 +0100, DrPi wrote:
My usage is a bit special. The writing process writes a bunch of data in >>> a memory buffer then requests this buffer to be transferred to another
process by way of WM_COPYDATA.
I thought Windows had pipes.
It does,
We use it for out IPC in both Linux and Windows.
Works very well.
On 2024-02-18 01:00, Lawrence D'Oliveiro wrote:
On Sat, 17 Feb 2024 14:36:46 +0100, DrPi wrote:
My usage is a bit special. The writing process writes a bunch of data in >>> a memory buffer then requests this buffer to be transferred to another
process by way of WM_COPYDATA.
I thought Windows had pipes.
Yes it has, but very rarely used though much better designed than UNIX
pipes.
In general Windows has much richer and better API regarding interprocess communication than Linux.
There is no need in XDR, JSON, ASN.1
or other data representation mess. They are just worthless overhead.
On Sun, 18 Feb 2024 14:02:32 +0100, Dmitry A. Kazakov wrote:
There is no need in XDR, JSON, ASN.1
or other data representation mess. They are just worthless overhead.
Most languages nowadays have JSON libraries readily available. That is a
very easy format to use for passing structured data between processes.
On 2024-02-18 21:58, Lawrence D'Oliveiro wrote:
On Sun, 18 Feb 2024 14:02:32 +0100, Dmitry A. Kazakov wrote:
There is no need in XDR, JSON, ASN.1 or other data representation
mess. They are just worthless overhead.
Most languages nowadays have JSON libraries readily available. That is
a very easy format to use for passing structured data between
processes.
It is easy to jump down the stairwell too. Though I would not recommend
such course of action...
On 2024-02-18 21:56, Lawrence D'Oliveiro wrote:
On Sun, 18 Feb 2024 11:06:16 +0100, Dmitry A. Kazakov wrote:
On 2024-02-18 01:00, Lawrence D'Oliveiro wrote:
I thought Windows had pipes.
Yes it has, but very rarely used though much better designed than UNIX
pipes.
So why don’t programmers use it?
There is no need in that.
In general Windows has much richer and better API regarding
interprocess communication than Linux.
So why is it that Windows programs tend to avoid running multiple
processes?
Because there is no need in multiple processes most of the time. Windows
has a different philosophy and services which preclude the process orgy
so characteristic to UNIX. For example, Windows has and collects many resources when a process dies. So you do not need a process monitoring
file locks, because there is no any.
On Sun, 18 Feb 2024 23:10:10 +0100, Dmitry A. Kazakov wrote:
In general Windows has much richer and better API regarding
interprocess communication than Linux.
So why is it that Windows programs tend to avoid running multiple
processes?
Because there is no need in multiple processes most of the time. Windows
has a different philosophy and services which preclude the process orgy
so characteristic to UNIX. For example, Windows has and collects many
resources when a process dies. So you do not need a process monitoring
file locks, because there is no any.
Windows is the one that keeps files locked, *nix systems typically do not.
On Sun, 18 Feb 2024 23:10:07 +0100, Dmitry A. Kazakov wrote:
On 2024-02-18 21:58, Lawrence D'Oliveiro wrote:
On Sun, 18 Feb 2024 14:02:32 +0100, Dmitry A. Kazakov wrote:
There is no need in XDR, JSON, ASN.1 or other data representation
mess. They are just worthless overhead.
Most languages nowadays have JSON libraries readily available. That is
a very easy format to use for passing structured data between
processes.
It is easy to jump down the stairwell too. Though I would not recommend
such course of action...
Fun fact: you can prove any argument just by coming up with a suitably spurious analogy. For example, your argument is wrong, just by virtue of
the fact that cats land on their feet.
On 2024-02-18 21:56, Lawrence D'Oliveiro wrote:
So why is it that Windows programs tend to avoid running multiple
processes?
Perhaps on win create_process is much heavier than threading compared to unix. My suspicion only though.
MS SQL-server use it for IPC.
So why is it that Windows programs tend to avoid running multiple processes?
On Sun, 18 Feb 2024 12:36:54 +0100, Björn Lundin wrote:
On 2024-02-18 01:00, Lawrence D'Oliveiro wrote:
On Sat, 17 Feb 2024 14:36:46 +0100, DrPi wrote:
My usage is a bit special. The writing process writes a bunch of data in >>>> a memory buffer then requests this buffer to be transferred to another >>>> process by way of WM_COPYDATA.
I thought Windows had pipes.
It does,
We use it for out IPC in both Linux and Windows.
Works very well.
Why doesn’t the OP use them, then?
On 2024-02-18 21:57, Lawrence D'Oliveiro wrote:
On Sun, 18 Feb 2024 12:36:54 +0100, Björn Lundin wrote:
On 2024-02-18 01:00, Lawrence D'Oliveiro wrote:
On Sat, 17 Feb 2024 14:36:46 +0100, DrPi wrote:
My usage is a bit special. The writing process writes a bunch of
data in
a memory buffer then requests this buffer to be transferred to another >>>>> process by way of WM_COPYDATA.
I thought Windows had pipes.
It does,
We use it for out IPC in both Linux and Windows.
Works very well.
Why doesn’t the OP use them, then?
I have no idea,
You can see them with
powershell -command [System.IO.Directory]::GetFiles(\"\\.\pipe\")
Not Windows, It is the applications that have GUI died and files still
open.
You did not say why JSON is needed.
Firefox starts a process for each tab!
On Mon, 19 Feb 2024 09:32:42 +0100, Dmitry A. Kazakov wrote:
You did not say why JSON is needed.
Because it’s such a convenient meta-format,
and its text basis helps with
debugging.
Its popularity aids interoperability with code bases in other
languages,
support by existing tools, and so on and so on.
If you didn’t know all that, you’ve been living under a coconut shell, as we say in the old country ...
On 2024-02-20 01:41, Lawrence D'Oliveiro wrote:
On Mon, 19 Feb 2024 09:32:42 +0100, Dmitry A. Kazakov wrote:
You did not say why JSON is needed.
Because it’s such a convenient meta-format,
Meta of what?
On Tue, 20 Feb 2024 09:55:30 +0100, Dmitry A. Kazakov wrote:
On 2024-02-20 01:41, Lawrence D'Oliveiro wrote:
On Mon, 19 Feb 2024 09:32:42 +0100, Dmitry A. Kazakov wrote:
You did not say why JSON is needed.
Because it’s such a convenient meta-format,
Meta of what?
You don’t understand the concept of “meta-formats”?
Maybe you prefer
“format family” or “format superclass”. Does that help make things clearer?
It is something easily specialized to become an application-
specific format, with less effort than creating the specific format from scratch.
An earlier example is XML. Also IFF on the Commodore-Amiga, from the
1980s.
The burden of checks is moved to the application, the format is same.
On Tue, 20 Feb 2024 21:45:46 +0100, Dmitry A. Kazakov wrote:
The burden of checks is moved to the application, the format is same.
Isn’t that how all formats are implemented?
On 2024-02-20 23:32, Lawrence D'Oliveiro wrote:
On Tue, 20 Feb 2024 21:45:46 +0100, Dmitry A. Kazakov wrote:
The burden of checks is moved to the application, the format is same.
Isn’t that how all formats are implemented?
There is a difference in semantics of checks.
On Wed, 21 Feb 2024 08:43:13 +0100, Dmitry A. Kazakov wrote:
On 2024-02-20 23:32, Lawrence D'Oliveiro wrote:
On Tue, 20 Feb 2024 21:45:46 +0100, Dmitry A. Kazakov wrote:
The burden of checks is moved to the application, the format is same.
Isn’t that how all formats are implemented?
There is a difference in semantics of checks.
Think of a stream of bytes as the ultimate meta-format.
All extra layout
on top of that is “moved to the application”, as you say. But it just takes more work starting from such a low level; starting from a higher
point, like JSON, reduces that work.
On 2024-02-21 20:44, Lawrence D'Oliveiro wrote:
Think of a stream of bytes as the ultimate meta-format.
Of course not. It is not a format it is a transport layer.
[ BTW, it is not bytes, it is octets actually ]
Implementation of serialization/deserialization on top of
JSON is exponentially harder than on top of an octet stream.
Alone specification of handling missing, superfluous, wrongly typed
fields is a huge work before a single line of code is written.
5. JSON cannot specify constraints, like value ranges, precision,
variable record fields, array bounds.
6. JSON has no means of reflection.
fields is a huge work before a single line of code is written.
BNF is better than all common languages.
Firefox starts a process for each tab!
All the web browsers do nowadays. That’s the only way to maximize
isolation of potentially hostile websites.
Dmitry A. Kazakov wrote:
That sand boxing is because they're written in C. If they were written
Firefox starts a process for each tab!
All the web browsers do nowadays. That’s the only way to maximize >>isolation of potentially hostile websites.
in Ada then the original design would be preferrable that uses far less memory.
That sand boxing is because they're written in C. If they were written
in Ada then the original design would be preferrable that uses far less
memory.
I wouldn’t use one characteristic as an excuse for not doing the other >thing as well.
Dear all,
He is not a troll.
With kind regards.
Pól Niocláſ Caileán Gloſtéir
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 399 |
Nodes: | 16 (2 / 14) |
Uptime: | 110:36:04 |
Calls: | 8,369 |
Calls today: | 8 |
Files: | 13,165 |
Messages: | 5,899,005 |