Handling Timer Queuing Conflicts
At busy times, in multiple-execution scenarios, the timer may need to add the timer
callback function (TimerFcn) to the MATLAB execution queue before the previously
queued execution of the callback function has completed. You can determine how the
timer object handles this scenario by setting the BusyMode property to use one of these
modes:
In this section...
“Drop Mode (Default)” on page 27-10
“Error Mode” on page 27-11
“Queue Mode” on page 27-13
Drop Mode (Default)
If you specify 'drop' as the value of the BusyMode property, the timer object adds the
timer callback function to the execution queue only when the queue is empty. If the
execution queue is not empty, the timer object skips the execution of the callback.
For example, suppose you create a timer with a period of 1 second, but a callback that
requires at least 1.6 seconds, as shown here for mytimer.m.
function mytimer()
t = timer;
t.Period = 1;
t.ExecutionMode = 'fixedRate';
t.TimerFcn = @mytimer_cb;
t.BusyMode = 'drop';
t.TasksToExecute = 5;
t.UserData = tic;
start(t)
end
function mytimer_cb(h,~)
timeStart = toc(h.UserData)
pause(1.6);
timeEnd = toc(h.UserData)
end
27 Program Scheduling