Multithreading and compatibility library (libconfig)
I have a question regarding a library for reading configuration files,
libconfig. I think I'm going slightly off-topic here, but I have not
found a better place for this question.
While this library does not support multithreading, I do need to access
the containing information from two threads. I do the following: I load
the configuration file once before I multithread. I never change the
configuration data. I do retrieve information from it and this can
happen by two threads at the same time.
It's website states the following ->
Libconfig is fully reentrant; the functions in the library do not make
use of global variables and do not maintain state between successive
calls. Therefore two independent configurations may be safely
manipulated concurrently by two distinct threads.
If it doesn't use global variables, or maintain state between successive
calls, shouldn't it be safe to request data with one of its functions,
as long as it doesn't reload or write/modify/save data? I could imagine
that some pointers could get mixed up with two concurrent calls
searching for some data. But since it doesn't use global variables or
maintain state between successive calls, I don't see how this can happen.
I hope someone can give me some clarity on this. Below I have some more
notes on libconfig and multithreading.
Kind regards, Maarten
ps. some additional info supplied by the developer:
Libconfig is not thread-safe. The library is not aware of the presence
of threads and knows nothing about the host system's threading model.
Therefore, if an instance of a configuration is to be accessed from
multiple threads, it must be suitably protected by synchronization
mechanisms like read-write locks or mutexes; the standard rules for safe
multithreaded access to shared data must be observed.
Libconfig is not async-safe. Calls should not be made into the library
from signal handlers, because some of the C library routines that it
uses may not be async-safe.
Libconfig is not guaranteed to be cancel-safe. Since it is not aware of
the host system's threading model, the library does not contain any
thread cancellation points. In most cases this will not be an issue for
multithreaded programs. However, be aware that some of the routines in
the library (namely those that read/write configurations from/to files
or streams) perform I/O using C library routines which may potentially
block; whether or not these C library routines are cancel-safe depends
on the host system.
Re: Multithreading and compatibility library (libconfig)
On 01/23/2013 07:16 AM, Muffinman wrote:
> Hello all,
> I have a question regarding a library for reading configuration files,
> libconfig. I think I'm going slightly off-topic here, but I have not
> found a better place for this question.
I'd recommend sending questions to
|All times are GMT. The time now is 02:45 PM.|
Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.