Home |
RTKernel-32 Programming Manual Miscellaneous RTKernel-32 Operations Function RTKSetTaskStartStopHook Function RTKInstallExitTask |
Function RTKInstallExitTaskRTKInstallExitTask installs an Exit Task if none has been created already: void RTKInstallExitTask(unsigned StackSize, unsigned long Flags, const char * Name); The three parameters are used as follows by RTKInstallExitTask: if (Name == NULL) Name = "Exit Task"; RTKCreateThread(ExitTask, RTK_MAX_PRIO, StackSize, Flags, NULL, Name); The Exit Task created with this function can be used later to terminate the program with RTKExit in a defined context. RTKExit sends a message to the Exit Task which will then call C/C++ run-time system function exit(). Function exit() will then execute all exit handlers installed by the application through atexit() (including RTKernel-32's exit handler installed by RTKernelInit). Terminating a program through the Exit Task can become necessary when the program context is undefined. For example, a program cannot be terminated directly from an interrupt handler or from an Idle Task. However, termination via the Exit Task is still possible in these cases. The Exit Task is particularly useful for application debugging. Frequently, program execution is suspended by interrupting the program in an arbitrary context, and then restarted. Safe program termination is only possible through the Exit Task in this situation. For this reason, RTKernelInit calls RTKInstallExitTask(0, 0, NULL); RTCallDebugger(RT_DBG_CALLRESET, (DWORD)RTKExit, 0); RTSetExitHandler(RTKExit); at program startup if the program is running under the RTTarget-32 Debug Monitor and kernel flag RF_NO_EXIT_TASK has not been set by the application. Thus, applications usually do not need to call RTKInstallExitTask explicitly. The recommended setup to ensure safe program termination or restart is:
|