pthreads: mutex initializer
Hi there!
i'm using the pthreads (posix threads) but i have a doubt germane to mutex declaration.
when i initialize a mutex (as below), i want to lock/unlock any of the 4 variables: G_a, G_b, G_c or G_d. if i use the code below, i'm not sure if "my_mutex" can be used to lock/unlock the 4 variables or only the first one (G_a). i would like to avoid creating a mutex for every single variable.
pthread_mutex_t my_mutex = PTHREAD_MUTEX_INITIALIZER;
struct data G_a;
struct data G_b;
int G_c;
int long G_d;
i haven't found anything about it. i would appreciate any suggestions.
thanks,
cardias.
|