What thread do timers operate in
이전 댓글 표시
This question arose from some comments to a previous question: http://www.mathworks.com/matlabcentral/answers/21511-execution-order which refers to another question concerning timers. Instead of hijacking those questions I thought I would ask a new question. The documentation concerning which "thread" a timer operates in and when it can execute its callback seems to be a nightmare.
says: "The specified execution time and the actual execution of a timer can vary because timer objects work in the MATLAB single-threaded execution environment. The length of this time lag is dependent on what other processing MATLAB is performing. To force the execution of the callback functions in the event queue, include a call to the drawnow function in your code. The drawnow function flushes the event queue."
says: "For example, a timer object is in a different thread than the MATLAB main thread. But it cannot interrupt a single MATLAB command i.e. a variable copy command."
I believe (but lack consistent documentation to support) that at least since r2010a timers run asynchronously and can interrupt any function between any two lines of code. I believe this is a change from the original behavior of MATLAB timer objects (introduced back in MATLAB 6.0????), but again cannot find any documentation about this. I also have no idea what a line of code is. For example
x = 1;
y = 2;
is clearly two lines of code, but is
x = 1; y = 2;
one or two lines of code? How do mex, dll and java fit into this? What about compiled built-in functions. What happens when the JIT kicks in?
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!