Multithreading and compatibility library (libconfig)

Discussion in 'C Programming' started by Muffinman, Jan 23, 2013.

  1. Muffinman

    Muffinman Guest

    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.
    Muffinman, Jan 23, 2013
    #1
    1. Advertising

  2. Muffinman

    James Kuyper Guest

    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.

    ....
    > http://www.hyperrealm.com/libconfig/libconfig_manual.html#Multithreading-Issues:


    I'd recommend sending questions to
    <http://www.hyperrealm.com/feedback.html>
    --
    James Kuyper
    James Kuyper, Jan 23, 2013
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sonny
    Replies:
    7
    Views:
    361
    Roger Leigh
    Feb 10, 2004
  2. Brzezi

    Multithreading library

    Brzezi, Oct 19, 2004, in forum: C++
    Replies:
    2
    Views:
    3,401
    Catalin Pitis
    Oct 20, 2004
  3. Grant Edwards
    Replies:
    0
    Views:
    287
    Grant Edwards
    Jul 8, 2010
  4. David Garamond

    multithreading with an external library

    David Garamond, Jan 4, 2004, in forum: Ruby
    Replies:
    1
    Views:
    104
    Paul Brannan
    Jan 5, 2004
  5. Replies:
    11
    Views:
    1,407
    sisyphus
    Apr 20, 2009
Loading...

Share This Page