I'm trying to do some stuff with pthreads and sync them:
How could I use mutex just for a group of threads ?
Let's say I have t0,t1, t2, .. t20. pthreads running at the same time, and I want to have a lock for the even numbers threads and other lock for the odd numbers threads... or one lock for the first ten, and other for the rest, or one lock for each one. I mean, grouping pthreads depending on its data (the fourth argument in this funcion:
int pthread_create(pthread_t *thread, pthread_attr_t *attr, void *(*start_routine)(void *), void *arg);
and sharing the mutex for a group of pthreads.
I'm working on a kind of bank project and I want to lock all the phreads trying to access to a same account number. (as critical section CRUD operations)
Does it make sense ? or there is a better approach to do this ?
Thanks in advance for your help and time ;)
J.