I am using many pthread mutex’s. My program uses them and then, at a certain point I want to do a soft restart of my program, I am repeating “Soft-restart”, not hard restart. By soft restart I mean, I will not exit the program by, I start the program once more using “goto” statement, which starts at the start of the program, to once again run the program.
My doubt is, if I am using the mutex’s in my program and in the mid way, I get a soft-restart, where I am initializing this mutex’s. Will they be initialized irrespective of where they were in the program.
I checked with normal datatypes like “int”, they get initialized to what ever we specified at the restart. But, I want some confidence from you all about mutex’s.
If you call ‘pthread_mutex_init’ on them, they will be initialized as if they were new mutexes. Just make sure no thread is or might be accessing them as you attempt to re-initialize them.
However, your notion of soft restarting sounds a bit off to me. If I had to implement such a thing (and I’d resist it to the ends of the Earth) I’d do it by getting rid of all previous objects and creating new ones, not by trying to reuse the leftover cruft from the previous run.