UnQLite Users Forum

Multithreading for Linux

append delete shiva

Is Multithreading for linux also enabled by default when we compile it with the compile time directive? Currently I am linking the library using -lpthreads and creating the unqlite.so file. Will this provide Threadsafety or do I have to still install my own Mutex Subsystem?

Thank You.


Reply RSS


append delete #1. chm

Make sure the library is compiled with the UNQLITE_ENABLE_THREADS directive defined.


append delete #2. shiva

Yes. I have complied it with the mentioned directive. The question is for Linux is it enough if we link using -lpthread or need to implement our own threadsaftey?
(Platforms others than Windows and UNIX systems must install their own mutex subsystem via unqlite_lib_config() with a configuration verb set to UNQLITE_LIB_CONFIG_USER_MUTEX.)

append delete #3. chm

Linux is a part of the UNIX family, so you're safe with that. We're talking for exotic OS here that should implement their own mutex subsystem.

append delete #4. shiva

Sorry!!I am a novice in Linux. Thank you for your reply.

append delete #5. shiva

Hallo Chm,

I am reopening the thread to discuss about the Concurrent Write and Read operations on the database.

I have enabled the Multithreading.
1. In one thread I am trying to Store different data in the Database using an array of keys. I am doing a Database commit as soon as I store any data and also closing the database between 2 stores and reopening again for any fresh operations.

2. While the Store is ongoing after some time I start my 2nd thread which Tries to Retrieve the data from this database using the same keys. I am opening the database in another handle using UNQLITE_OPEN_READONLY attribute. Now the read should happen as the Retrieves are concurrently possible. But, still I get UNQLITE_BUSY which means the database reads are not concurrent even though I have enabled the multithreading. Am I going somewhere wrong??

I am using the unqlite_lib_is_threadsafe to check if multithreading is enabled and also making sure not to configure it as Single thread using Liunqlite_lib_config.

Sorry!! I did not provide any code sample. But, its just a serial Write and a Serial Read from 2 different threads.


(Leave this as-is, it’s a trap!)

There is no need to “register”, just enter the same name + password of your choice every time.

Pro tip: Use markup to add links, quotes and more.

Your friendly neighbourhood moderators: chm_at_symisc, devel_at_symisc