I have an assignment to implement a module for something called a SIX Lock. It's basically a complex locking mechanism used for concurrent data access. In any case I'm getting a segmentation fault that I've traced to one line of code but cannot figure out why!
So I have this "class" implementing this SIXlock structure as defined below:
Yup...I'm using the pthreads library and that's about it.Code:typedef struct { pthread_mutex_t mutex; /*our mutex*/ pthread_cond_t not_locked; /*cond variable */ SIXlock_mode_t groupMode; /*our overall group mode*/ pthread_t *myThreads; /*pointer to threads*/ SIXlock_mode_t *grantedMode; /*lock mode of each thread */ int numThreads; /*number of threads in array*/ } SIXlock_lock_t;
So I have this create function which starts off like this:
but when it gets to the:Code:/*------------------------------------------------------------------------- /Function: SIXlock_create /Input: Pointer to a SIXlock object /Output: Returns parameter pointer pointing to created lock / Returns SIXlock_result_t notifying the user of the success/failure -------------------------------------------------------------------------*/ SIXlock_result_t SIXlock_create(SIXlock_lock_t **lockPointer) { int i; lockPointer = NULL; /*setup memory allocation*/ lockPointer = (SIXlock_lock_t **)malloc(sizeof( SIXlock_lock_t )); /*if error, return result*/ if(lockPointer == NULL) return SIXLOCK_RESULT_ERROR_MALLOC; /*initialize*/ pthread_mutex_init(&((*lockPointer)->mutex), NULL); .... }
pthread_mutex_init(&((*lockPointer)->mutex), NULL);
line, it throws a segmentation fault. Can someone please help????



LinkBack URL
About LinkBacks


