I have written a C based library and for it to work in multi-thread parallely, I create some global mutexes in the init function.
I expect the init function to be called in the main thread before the library APIs are used in multi-thread.
But, if the init function itself is called in multi-thread directly, then it is a problem. Is there a way to protect the init function itself from my library? One way I can think of is to ask the application to create a mutex and protect parallel calls to my init function, but can I protect it from my library itself?