0

I'm using libmysql in a simple multithreaded app which will run on a uni-core embedded system processor. I read here that the client library is almost thread-safe.

Do I need to serialise my app (say, with a mutex)?

1
  • 2
    you should really read the page you linked. it has all the info. Commented Nov 14, 2014 at 18:36

1 Answer 1

3

Depends on what you're doing. In a simple scenario you'd just link against libmysqlclient_r and make sure you don't share a connection with multiple threads nor execute multiple queries "simultaneously" on a single connection.

Other requirements:

  1. Before creating any threads, call mysql_library_init() to initialise the MySQL library;
  2. On each thread call mysql_thread_init() to initialise thread-specific variables before using any MySQL related functions;
  3. Before destroying a thread, call mysql_thread_end().

If your program is respecting these limitations, MySQL is your friend.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.