IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 21294


Ignore:
Timestamp:
Feb 4, 2009, 1:36:56 PM (17 years ago)
Author:
eugene
Message:

adding mutex locks to psImage structure manipulation

Location:
branches/eam_branch_20090203/psLib/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branch_20090203/psLib/src/imageops/psImageStructManip.c

    r15492 r21294  
    88 *  @author Robert DeSonia, MHPCC
    99 *
    10  *  @version $Revision: 1.20 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2007-11-08 01:09:48 $
     10 *  @version $Revision: 1.20.42.1 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2009-02-04 23:36:56 $
    1212 *
    1313 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2121#include <string.h>
    2222#include <assert.h>
     23#include <errno.h>
    2324
    2425#include "psMemory.h"
    2526#include "psError.h"
    2627#include "psAbort.h"
     28#include "psTrace.h"
    2729
    2830#include "psImageStructManip.h"
     
    100102    psPtr rawData = psMemIncrRefCounter(image->p_rawDataBuffer);
    101103
     104    // XXX worry about this later...
    102105    if (out != NULL) {
    103106        // if a child, need to orphan (disassociate from parent) first
     
    108111
    109112            // drop my entry on my parent's array of children
     113            psMutexLock (out);
    110114            psArrayRemoveDataNoFree (out->parent->children, out);
     115            psMutexUnlock (out);
    111116
    112117            // drop my reference to my old parent
     
    119124        out = p_psAlloc(file, lineno, func, sizeof(psImage));
    120125        out->data.V = NULL;
     126        psMutexInit (out);
    121127    }
    122128
     
    129135    P_PSIMAGE_SET_ROW0(out, row0);
    130136
     137    // As long as I have a valid image reference, no one else can free it to zero (I have at
     138    // least the last reference)
    131139    out->parent = psMemIncrRefCounter(image); // track references to parents
    132140    out->children = NULL;
     
    144152    }
    145153
    146     // add output image as a child of the input image.
     154    // Add output image as a child of the input image.  Lock image before performing this
     155    // operation (psArrayAdd is NOT thread-safe)
     156    psMutexLock (image);
    147157    image->children = p_psArrayAdd(file, lineno, func, image->children, 16, out);
     158    psMutexUnlock (image);
     159
    148160    psFree (out); // the image->children array is an array of views only
    149 
    150161    return (out);
    151162}
  • branches/eam_branch_20090203/psLib/src/mathtypes/psImage.c

    r20547 r21294  
    99 *  @author Ross Harman, MHPCC
    1010 *
    11  *  @version $Revision: 1.132 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2008-11-05 11:12:39 $
     11 *  @version $Revision: 1.132.10.1 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2009-02-04 23:36:56 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2424#include <math.h>
    2525#include <unistd.h>
     26#include <errno.h>
    2627
    2728#include "psMemory.h"
     
    2930#include "psAssert.h"
    3031#include "psAbort.h"
     32#include "psTrace.h"
    3133
    3234#include "psImage.h"
     
    5355
    5456        // drop my entry on my parent's array of children
     57        // lock parent before freeing child : psArrayRemoveDataNoFree is NOT thread safe
     58        psMutexLock (parent);
    5559        psArrayRemoveDataNoFree (parent->children, image);
     60        psMutexUnlock (parent);
    5661
    5762        // drop my reference to my parent
     
    6671    }
    6772
     73    psMutexDestroy(image);
    6874    psFree(image->children);
    6975    psFree(image->p_rawDataBuffer);
     
    122128    image->parent = NULL;
    123129    image->children = NULL;
     130
     131    // XXX for a test : we will add a mutex to all images:
     132    psMutexInit (image);
    124133
    125134    return image;
Note: See TracChangeset for help on using the changeset viewer.