[comp.os.os2.programmer] Shared memory usage

eli@elisun.metaphor.com (Eli Lauris) (09/27/90)

I have questions about shared memory usage under OS/2. My application
consists of various application programs using a common buffer pool that
is accessed via a DLL interface (e.g. GetBuf, PutBuf).  I would like to 
used a common shared memory segment, so that any of those applications
can access the buffers in their virtual address space.  I think this is
pretty easily doable in OS/2 using DosAllocShrSeg and DosGetShrSeg 
functions (correct me, if I am wrong).

In addition to that, I also want to be able to call GetBuf and PutBuf
as well as access the buffers from a device driver - both from the 
Strategy and an Interrupt Routine.  My device driver will get an empty
buffer, fill it up with data coming from a device and return the buffer to an
application.  I want to use the same buffers in the shared memory segment
in order to avoid buffer copying. I also _do_not_ want the applications
to get the buffer and provide a pointer to it for the strategy routine,
because the data can come in asynchrounously and I need to be able to 
queue it up in my device driver, until the application requests it.

Here are the questions:

1). Is what I am trying to do at all doable under OS/2 ?
If the answer to the above is Yes, then I'd like to know the
details:

2). Can the driver call routines from DLL, or do I need to have
a separate version of these routines statically linked with the driver ?

3). How can I access the buffers that are in that shared memory segment
from within an interrupt context ?

4). What is the best synchronization mechanism to prevent the interrupt
routine of the driver from manipulating the buffers at the same time that
the strategy routine or one of the applications does it ?  Is it CLI/STI
bracketing of the code, or is there some OS/2 function that is better ?

I appreciate any insight you give me on those issues.

Eli Lauris
Metaphor Computer Systems.