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
pthread mutex restrictions
-
- Member
- Posts: 199
- Joined: Fri Jul 13, 2007 6:37 am
- Location: Stuttgart/Germany
- Contact:
Re: pthread mutex restrictions
Hi,
Whether or not you run into performance problems depends on how the mutexes are used (and lots of other things).
Cheers,
Brendan
AFAIK there are no restrictions on how many mutexes an application can use.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?
Whether or not you run into performance problems depends on how the mutexes are used (and lots of other things).
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Re: pthread mutex restrictions
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.