Multithreading and compatibility library (libconfig)

M

Muffinman

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.

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 ->
http://www.hyperrealm.com/libconfig/libconfig_manual.html#Multithreading-Issues:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top