• High memory usage with queue (DosAllocSharedMem, DosGiveSharedMem) - OB

    From Andi B.@21:1/5 to All on Sun Jun 18 13:00:20 2023
    Hi,
    I wanted to implement high memory usage in pmprintf package cause it eats up all my lower
    shared memory in one use case. As far as I see this does not work.

    Is it possible to give high mem to another process via DosGiveSharedMem and queue? As I
    understand the pmprintf caller (pmprintf.dll) allocates the high memory and put a string
    into it. The pointer to the string is transfered to the monitor program (pmprintf.exe -
    the server) via a queue (DosOpenQueue). But the server always get a null pointer instead
    the pointer to the string.

    Any ideas?

    Andreas

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dave Yeo@21:1/5 to Andi B. on Sun Jun 18 13:22:12 2023
    Andi B. wrote:
    Hi,
    I wanted to implement high memory usage in pmprintf package cause it
    eats up all my lower shared memory in one use case. As far as I see this
    does not work.

    Is it possible to give high mem to another process via DosGiveSharedMem
    and queue? As I understand the pmprintf caller (pmprintf.dll) allocates
    the high memory and put a string into it. The pointer to the string is transfered to the monitor program (pmprintf.exe - the server) via a
    queue (DosOpenQueue). But the server always get a null pointer instead
    the pointer to the string.

    Any ideas?


    Isn't the problem that some 16bit API is involved? Looking at os2safe.h (GCC/libc), I see this,
    ```
    /*
    * Note! The DOS queue API does not work with data, but with addresses, request
    * numbers, priorities and process IDs. I.e. the data address you give
    * DosWriteQueue is NOT used to memcpy() what it points to into some
    internal
    * buffer that is then queued. Instead that address is converted to
    16-bit and
    * placed on the queue.
    *
    * This means that the data pointer passed to DosWriteQueue CANNOT be a
    high
    * address! (The wrappers below makes sure all the other pointer
    parameters
    * can be pointing to high memory, though.)
    */
    #define DosCreateQueue SafeDosCreateQueue
    #define DosOpenQueue SafeDosOpenQueue
    #define DosPeekQueue SafeDosPeekQueue
    #define DosQueryQueue SafeDosQueryQueue
    #define DosReadQueue SafeDosReadQueue
    ```
    Dave

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Andi B.@21:1/5 to Dave Yeo on Mon Jun 19 10:01:06 2023
    Dave Yeo schrieb:
    Andi B. wrote:
    Hi,
    I wanted to implement high memory usage in pmprintf package cause it
    eats up all my lower shared memory in one use case. As far as I see this
    does not work.

    Is it possible to give high mem to another process via DosGiveSharedMem
    and queue? As I understand the pmprintf caller (pmprintf.dll) allocates
    the high memory and put a string into it. The pointer to the string is
    transfered to the monitor program (pmprintf.exe - the server) via a
    queue (DosOpenQueue). But the server always get a null pointer instead
    the pointer to the string.

    Any ideas?


    Isn't the problem that some 16bit API is involved? Looking at os2safe.h (GCC/libc), I see this,
    ```
    /*
    * Note! The DOS queue API does not work with data, but with addresses, request
    * numbers, priorities and process IDs. I.e. the data address you give
    * DosWriteQueue is NOT used to memcpy() what it points to into some internal
    * buffer that is then queued. Instead that address is converted to
    16-bit and
    * placed on the queue.
    *
    * This means that the data pointer passed to DosWriteQueue CANNOT be a
    high
    * address! (The wrappers below makes sure all the other pointer
    parameters
    * can be pointing to high memory, though.)
    */
    #define DosCreateQueue SafeDosCreateQueue
    #define DosOpenQueue SafeDosOpenQueue
    #define DosPeekQueue SafeDosPeekQueue
    #define DosQueryQueue SafeDosQueryQueue
    #define DosReadQueue SafeDosReadQueue
    ```
    Dave



    Thanks Dave. I didn't think about searching in libc/bww sources for
    programing guidelines before.

    Beside that header file is there some official IBM documentation about?

    I've searched all my files for OBJ_ANY and only found it in a few
    toolkit headers. I mean just in case I've overlooked something.
    Otherwise it seems someone (Knut, Dmitriy, ?) did a very good job in
    writing down their findings.

    Andreas

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dave Yeo@21:1/5 to Andi B. on Mon Jun 19 11:27:17 2023
    Andi B. wrote:
    Thanks Dave. I didn't think about searching in libc/bww sources for programing guidelines before.

    Beside that header file is there some official IBM documentation about?

    Not that I know of, as you said, IBM's documentation on using high
    memory was very slim.
    Hmm, the Programmers Guide and Reference Addendum does have a section on
    "API's Supporting High memory Objects" which looks incomplete.


    I've searched all my files for OBJ_ANY and only found it in a few
    toolkit headers. I mean just in case I've overlooked something.
    Otherwise it seems someone (Knut, Dmitriy, ?) did a very good job in
    writing down their findings.

    A lot of it was trial and error after we moved to using high memory in
    Mozilla. Something would crash or otherwise fail and os2safe.h would get
    an update along with libos2.
    The code is here, https://github.com/bitwiseworks/libc/blob/master/src/emx/src/libos2/safe/SafeDosCreateQueue.c
    if interested in how libc handles these API's. I always assumed they
    just force using low memory.
    If nothing else, os2safe.h does give a list of API's that are not high
    memory safe.
    Dave

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)