HALTing a task is like a sudden power outage for the task. The HALTed task doesn't know it's coming, and can't get its affairs in order before it goes down. A safer and more robust approach for stopping tasks is to request the task to end itself.
For example, suppose VARB35 must be set to enable Task 4, and the controlling task may stop Task 4 by clearing VARB35. The program in Task 4 would qualify each atomic (atomic means not to be interrupted or aborted) block of code with VARB35 and look like:
WHILE (VARB35 = B1) ;some fast code IF (VARB35 = B1) ;some atomic code NIF TIMST0 WHILE (TIM < 100 AND VARB35=B1) ;dwell while still enabled NWHILE ;end of qualified dwell IF (VARB35 = B1) ;more atomic code NIF NWHILE ;end of main task loop ;end of task cleanup code, graceful exit END
0 Comments