[SciPy-user] shared memory machines

Philip Semanchuk philip@semanchuk....
Mon Feb 9 09:07:16 CST 2009


On Feb 9, 2009, at 6:56 AM, Sturla Molden wrote:

> On 2/9/2009 12:38 PM, Gael Varoquaux wrote:
>
>> This means that we probably need a shared reference counter :(.  
>> Sounds
>> tedious to implement.
>
> On System V, you can get the attachment count using shmctl with
> IPC_STAT. Then after calling shmdt, checking the count and marking for
> removal if it is zero:
>
> int cleanup(int shmid)
> {
>    int ierr;
>    struct shmid_ds buf;
>    ierr = shmctl(shmid, IPC_STAT, &buf);
>    if(ierr < 0) goto error;
>    if (buf.shm_nattch == 0) {
>       ierr = shmctl(shmid, IPC_RMID, NULL);
>       if(ierr < 0) goto error;
>    }
>    return 0
> error:
>    return errno;
> }

Unfortunately POSIX IPC doesn't report that information.

Since I'm not a numpy user I'm a little lost as to how you're using  
the shared memory here, but I gather that it is effectively "magic" to  
a numpy user? i.e., he doesn't have any idea that a shared memory  
segment is being created on his behalf? If that's the case I don't see  
any way around reference counting.






More information about the SciPy-user mailing list