I set up a separate thread that can be sent messages,and puts them into a FIFO to ensure its printed in the correct order, but is there a better way? I want to just drop in print statements ;_;
Name:
Anonymous2010-02-02 19:41
you must _feel_ the code
Name:
Anonymous2010-02-02 19:52
I don't play around with multithreaded programs often but an obvious suggestion is to have each thread be debugged individually outwards (as in, any threads initialized from within or depending on other threads. Also, set any required variable that thread needs to "working" limits (even testing those working limits to make sure).
It's not really difficult. You think about the execution of threads and where they may possibly overlap. Ask yourself what happens if the threads execute in a certain order - and if you have no answer or your answer is "I don't know," you probably have a threading bug.
Name:
Anonymous2010-02-02 20:48
>>4
This. If you're having difficulty, you're doing something horribly wrong. Remember, threads are evil.
That being said, printf is thread-safe in glibc, and on BSD afaik.
>>12
Why would that matter? Threading is a problem in lots of languages. >>4
Yes, I know. I had various synchronisation points, and I was mostly using this information to ensure that execution was correct up to the bug.