what is task execution? -凯发k8网页登录

main content

what is task execution?

a task is a unit of execution or unit of work in a software application. typically, task execution in an embedded processor is managed by the operating system (os). when deployed to the embedded processor, a task corresponds to an os thread. the soc blockset™ defines the execution life cycle and relation to os threads as follows.

task execution life cycle

the life cycle of a task can be divided into five states:

  • created – the system creates all the tasks when the application starts and immediately moves them to the waiting state.

  • waiting – the task waits for the associated trigger signal, such as an os timer or i/o device. after receiving the trigger signal, the task starts to run. if the task has the highest priority, it enters the running state. otherwise, the task continues to wait until it becomes the highest priority, triggered task.

  • running – the task executes its code. when the code completes execution, the task immediately moves to the waiting state. if a trigger for a higher-priority task occurs, the running task moves to the preempted state.

  • preempted – the task is preempted and waiting to run. a task runs based on a combination of the task priority and the order the task entered the preempted state. assuming equal task priorities of all other tasks in ready to resume state, tasks run based on first-in-first-out (fifo) ordering.

  • terminated – tasks terminate when the application ends.

this figure shows the state diagram of a task execution life cycle for an application using an os. for simplicity, the terminated state is not shown, but a task can reach the terminated state from any of the other states.

task and thread

a task is a conceptual unit of work in an algorithm. in an application executing on a device, a task is a section of code that executes in a thread within an operating system (os). the os thread determines the state of execution of the task. within the soc blockset, a task specifically refers to the portion of the simulink® model contained within a rate or function-call subsystem. the trigger signal for that subsystem comes from a block. when deployed to hardware, an os thread uses the task properties. the thread executes the code generated from the subsystem. conceptually, a task in simulation is equivalent to a thread in generated code.

see also

related topics

    external websites

      网站地图