Page 1 of 1

pthread mutex restrictions

Posted: Sat Feb 21, 2009 8:13 am
by sancho1980
hi

i am trying to make the json-c library thread-safe and i need to use pthread_mutex_t's for that
the approach is to introduce a field of type pthread_mutex_t in struct json_object
this way i can lock a json object before making a put/get etc., and unlock it afterwards
we need this at our company for a project where in the end many thousands of such json objects will reside in memory, and we were wondering whether there are any restrictions as to how many mutexes an application may have in use and/or whether we are going to run into performance problems?
does any one have an idea?
thanks
martin

Re: pthread mutex restrictions

Posted: Sat Feb 21, 2009 8:41 am
by Brendan
Hi,
sancho1980 wrote:we need this at our company for a project where in the end many thousands of such json objects will reside in memory, and we were wondering whether there are any restrictions as to how many mutexes an application may have in use and/or whether we are going to run into performance problems?
AFAIK there are no restrictions on how many mutexes an application can use.

Whether or not you run into performance problems depends on how the mutexes are used (and lots of other things).


Cheers,

Brendan

Re: pthread mutex restrictions

Posted: Sun Feb 22, 2009 4:20 pm
by iammisc
No I don't think there would be a limit to the number of mutexes. Mutexes can be implemented purely in userspace if the need arise, so if this application is kernel-specific, you can develop your own mutex implementation. But I'm pretty sure regular pthreads can do the job.