BOOL osTerminateTask( HANDLE Handle );
A handle to the task to be terminated.
Returns TRUE on success or FALSE on failure. Use the osGetLastError function to obtain extended error information.
This function terminates the specified task.
To terminate the current task, use osExitTask, which also allows specifying a custom exit code. When the osTerminateTask function is used to terminate a task, the exit code is automatically set to ERR_TASK_TERMINATED_BY_OTHER.
Upon termination, all critical sections owned by the task are released and marked as abandoned. If OS_ALLOW_OBJECT_DELETION is set to 1, all objects opened by the task are closed. If an object is no longer opened by any other task, it is deleted from the system.
The osTerminateTask function stops the execution of the task but does not delete the task object instance itself. To remove the task object, osCloseHandle must be called. The task object is deleted only after it has reached the terminated state and all tasks that previously opened the object have closed their respective handles. If all handles are closed prior to task termination, the object cannot be deleted.
This function is available only when the OS_TERMINATE_TASK_FUNC constant is set to 1. If this functionality is not required, it can be disabled to reduce the memory footprint of the output code.
| Version: | 1.0 |
|---|---|
| Header file: | OS_Task.h (include OS_API.h) |
| See also: | BOOL, creating a task, FALSE, HANDLE, OS_ALLOW_OBJECT_DELETION, OS_TERMINATE_TASK_FUNC, osCloseHandle, osCreateTask, osExitTask, osGetLastError, tasks, TRUE |