Skip to main content

Hi,


I need to access shared memory from COBOL. The COBOL will be native.

As the code will be developed on Windows and deployed to Linux I need the API to be the same on both platforms.

I think that I will have to do this:

    working-storage section.

    01  w-data-pointer usage pointer.

    linkage section.

    01  l-data pic x(...).

    procedure division.

        call "MAP_MEMORY" using w-pointer.

        set address of l-data to w-pointer.

The MAP_MEMORY routine is something I have to develop.

My question is this. Does anyone have something like MAP_MEMORY that they would be prepared to share? Does Micro Focus have any samples or demos of this sort of thing?

Thanks,

Leigh.


#COBOL

Hi,


I need to access shared memory from COBOL. The COBOL will be native.

As the code will be developed on Windows and deployed to Linux I need the API to be the same on both platforms.

I think that I will have to do this:

    working-storage section.

    01  w-data-pointer usage pointer.

    linkage section.

    01  l-data pic x(...).

    procedure division.

        call "MAP_MEMORY" using w-pointer.

        set address of l-data to w-pointer.

The MAP_MEMORY routine is something I have to develop.

My question is this. Does anyone have something like MAP_MEMORY that they would be prepared to share? Does Micro Focus have any samples or demos of this sort of thing?

Thanks,

Leigh.


#COBOL

For platform compatibility I would recommend that you use the COBOL library routines, CBL_ALLOC_MEM or CBL_ALLOC_SHMEM that are documented under Library routines.

Thanks.


Hi,


I need to access shared memory from COBOL. The COBOL will be native.

As the code will be developed on Windows and deployed to Linux I need the API to be the same on both platforms.

I think that I will have to do this:

    working-storage section.

    01  w-data-pointer usage pointer.

    linkage section.

    01  l-data pic x(...).

    procedure division.

        call "MAP_MEMORY" using w-pointer.

        set address of l-data to w-pointer.

The MAP_MEMORY routine is something I have to develop.

My question is this. Does anyone have something like MAP_MEMORY that they would be prepared to share? Does Micro Focus have any samples or demos of this sort of thing?

Thanks,

Leigh.


#COBOL

Chris,

What I do not understand about CBL_ALLOC_MEM and CBL_ALLOC_SHMEM is how two separate processes can map the same shared memory using these routines.

In a SYS V IPC environment The shared memory segments are identified by a 'key'. All processes attach to the shared memory using the same 'key' and hence access the same memory. Similarly, using mmap all processes map the same file into memory.

The CBL_ALLOC_MEM and CBL_ALLOC_SHMEM do not have any arguments that allow any sort of 'key' to be specified. Are these routines only of use inside one process? If that is the case, I fail to see what the difference between CBL_ALLOC_MEM and CBL_ALLOC_SHMEM is.

Leigh.


Hi,


I need to access shared memory from COBOL. The COBOL will be native.

As the code will be developed on Windows and deployed to Linux I need the API to be the same on both platforms.

I think that I will have to do this:

    working-storage section.

    01  w-data-pointer usage pointer.

    linkage section.

    01  l-data pic x(...).

    procedure division.

        call "MAP_MEMORY" using w-pointer.

        set address of l-data to w-pointer.

The MAP_MEMORY routine is something I have to develop.

My question is this. Does anyone have something like MAP_MEMORY that they would be prepared to share? Does Micro Focus have any samples or demos of this sort of thing?

Thanks,

Leigh.


#COBOL

Take a look at CBL_PUT_SHMEM_PTR and CBL_GET_SHMEM_PTR.

There is a demo on how to use these to share memory between processes here although it is for NX the shared memory and rununit calls still apply.


Hi,


I need to access shared memory from COBOL. The COBOL will be native.

As the code will be developed on Windows and deployed to Linux I need the API to be the same on both platforms.

I think that I will have to do this:

    working-storage section.

    01  w-data-pointer usage pointer.

    linkage section.

    01  l-data pic x(...).

    procedure division.

        call "MAP_MEMORY" using w-pointer.

        set address of l-data to w-pointer.

The MAP_MEMORY routine is something I have to develop.

My question is this. Does anyone have something like MAP_MEMORY that they would be prepared to share? Does Micro Focus have any samples or demos of this sort of thing?

Thanks,

Leigh.


#COBOL

Chris,

Thanks. I was aware of those calls. I assumed that they allow the memory to be shared between members of the coru only. Is that correct?

Some other information I did not mention before:

  • The COBOL programs in question will be running under a transaction monitor and will not be members of the same coru (or so I assume).
  • There's a need to set the memory areas up prior to transaction monitor is started. Hence, the memory mapped file or SYS V IPC syle approaches.

Thanks for your help.

Leigh.