Home |
RTKernel-32 Programming Manual Multitasking, Real-Time, and RTKernel-32 Alternate APIs for RTKernel-32 Program Termination |
Program TerminationThe most critical phases of a program are initialization and termination. Please be aware that all tasks can run until RTKernel-32's exit function has been completed. A program is terminated by a call to function exit. A call to exit is generated automatically by the compiler at the end of the main program. Therefore, the whole program terminates when the Main Task reaches its end. Function exit then calls all exit functions in reverse order as they have been inserted into the exit chain using atexit; meanwhile, task switches can still take place. Consequently, it can happen that a module is used after its exit function has been executed. Termination can be initiated by any task and is carried out in this task's context (i.e., with its priority and stack). Caution must also be exercised when one task terminates another. The terminating task generally does not know where the task to be terminated is suspended. Ideally, tasks should terminate themselves when they are in a defined state, e.g., when they reach the end of their task function. In this case, they are terminated automatically by RTKernel-32. If a program is aborted using function abort, the computer must be rebooted to reinitialize the interrupt vectors. RTKernel-32's Debug Version reports the successful completion of its exit function.
|