Re: mutex
Ron Eggler wrote:
Hi,
I wanna use a mutex to make a class thread safe. I initialize it in
its constructor like:
GPIOcontrol::GPIOcontrol()
{//constructor
pthread_mutex_init(GPIO_mtx, NULL);//initializing the mutex
}
But my application just terminates after issueing thiss line. I'm
using gcc
4.1.3
I have no clue what it's doing, GPIO-mtx is declared like this as a
private member of this class:
pthread_mutex_t *GPIO_mtx; // mutex declaration
It's not a mutex declaration. It's a _pointer_to_mutex_ declaration.
Where is the actual mutex? What memory does this pointer point to?
The weird thing is now, it works just fine by declaring the member
like: pthread_mutex_t GPIO_mtx; // mutex declaration
and calling the mutex_init like:
pthread_mutex_init(&GPIO_mtx, NULL);//initializing the mutex
Why is this????
That's weirdin me out. Anyone an idea?
Learn to use pointers.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask