[SciPy-user] shared memory machines

Sturla Molden sturla@molden...
Mon Feb 9 05:56:56 CST 2009

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
    return errno;


More information about the SciPy-user mailing list