Task
During OS-based application development, an application is usually seperated into a number of tasks. In CooCox CoOS, a task is a C function whose inside is a infinite loop, it also has the return values and parameters. However, since a task will never return, the returned type must be defined as void. Code 1 shows a typical task structure.
Code 1 An infinite loop task
Which is different from the C function, the quit of a task is achieved by calling system API function. Once you quit the task only through the ending of the code execution, the system would breakdown.
You can delete a task by calling CoExitTask ( ) or CoDelTask (taskID) in CooCox CoOS. CoExitTask ( ) is called to delete the current running task while CoDelTask (taskID) to delete others. If the incoming parameter is the current task ID, CoDelTask (taskID) can also delete the current task. The concrete use is shown in Code 2.
Code 2 Deleting a task
|