[linux-audio-dev] shared memory tools?

Kjetil S. Matheussen k.s.matheussen at notam02.no
Thu Mar 6 14:43:00 UTC 2003


On Thu, 6 Mar 2003, Juhana Sadeharju wrote:

> Hello. I need two functions:
>
> make_shm(int size, char *key)
>  -run by root
>  -creates a locked shared memory segment
>  -returns a key (preferably a string) which is used to
>   access the shared memory
>
> char *request_shm(char *key)
>  -run by users
>  -returns the address of the requested shared memory segment
>
> Could somebody please write these routines to me? Or give good
> hints? I have Jack and other codes, but it all is confusing
> when the shared memory should be accessed from separate process
> which is not fork() of the other.
>

The sharedmem handlers in the aipc package, (which I'm sort of
working on), is extremely easy to use.

Just define a common filename_prefix for all your processes,
and let them call the function:

struct aipc_sharedmem *aipc_sharedmem_new(
					  char *filenames_prefix,
					  int size,
					  int timeout
					  )

The first process to call this function with the same
filenames_prefix argument, and a size larger than 0,
will allocate the memory. If size is 0, the function
will wait for 'timeout' usecs and either give up and
return NULL, or return shared memory.

This might not be exactly what you're looking for, but at
least it'll give you a start.

You can find aipc at http://www.notam02.no/arkiv/src/k_jack.tar.gz/aipc/



-- 




More information about the Linux-audio-dev mailing list