I am test running all my USB routines in a different thread.
Although a Dinosaur, this is my first ever attempt to use threads.
Using the examples I have been able to get a small dedicated program to work, such that
the output on an IO board was stable within 0.2 mSec at 500 msec. (confirmed with my PicoScope)
However, I seem to have problems with the Timer between the threads.
Can someone please tell me what the rules are about calling the Timer in both threads.
What is the best way to secure the time in both threads.?
Do I use the Main thread timer or create another in the second thread ? and if so, what happens when both try to access the Timer
at the same time.?
Do I really have to MutexLock every call to the Timer ?
Generally I do the following:
Code: Select all
Times.CalTime = Timer
Do 'Main Program Loop
Times.mSec = (Timer - Times.CalTime) * 1000
' handle all other routines below here
'and use the Times.mSec as a reference.