harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Leo Li" <liyilei1...@gmail.com>
Subject Re: [classlib] Shared Memory
Date Sat, 15 Sep 2007 03:35:00 GMT
On 9/15/07, Rodney Dowdall <rdowdall@qnx.com> wrote:

> Hello
>
> Please forgive my ignorance, but I am not certain on how the Unix
> shmget, shmat, shmdt functions work.  I am trying to port the classlib
> to QNX Neutrino, which uses shm_open, shm_ctl and shm_unlink.  In the
> shared memory code a control file is created, and then a key is
> generated using ftok with the control file name.  Control file data is
> then written to the control file.  When you do a shmat is the shared

  Hi, Rodney:

  Excuse me, are you trying to use a shared memory file as the control file?

> memory attaching to the file?  Or is it a clean area in memory?  I'm

    If you transfer a NULL parameter as the target address for shmat,
System will choose a proper block( and not allocated ) of virtual
memory space into which the shared memory will be mapped.

> wondering if I have to generate a new name for my shm_open call, or if I
> can just use the control file name.

    If you want shm_open to get different shared memory objects, it is
necessary to use distinct names. Although shm_open will return
different fid by the same name, the fid will reference the same shared
memory objects. Furthermore, the shared object is system wide and will
last till next boot or explicitly call shm_unlink if I have not missed
something.

>
> Thanks,
> Rodney
>


-- 
Leo Li
China Software Development Lab, IBM

Mime
View raw message