pthread mutex restrictions

Programming, for all ages and all languages.
Post Reply
sancho1980
Member
Member
Posts: 199
Joined: Fri Jul 13, 2007 6:37 am
Location: Stuttgart/Germany
Contact:

pthread mutex restrictions

Post 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
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: pthread mutex restrictions

Post 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
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.
iammisc
Member
Member
Posts: 269
Joined: Thu Nov 09, 2006 6:23 pm

Re: pthread mutex restrictions

Post 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.
Post Reply