22. Operating system tasks and clock beats

Source: Internet
Author: User

1, the task, usually refers to the work of the delivery, responsibility. In modern computers, "task" is also a professional term for its basic work unit.

When designing a more complex application, it is also common to break down a large task into smaller tasks, and then, by running small tasks on the computer, accomplish the big task. Because this method can make the system run multiple tasks concurrently, it improves the utilization of the processor and speeds up the execution of the program.

2. Multi-tasking system

(1) Simple is to use a processor, concurrent (not at the same time) running multiple programs of Computer Management system

(2) Concurrency: Multiple programs are run by the same processor in rotation. Or a resource that is used by multiple programs to occupy the processor in shifts. It is not always possible to run the program during the time it takes up this resource.

3. Task management in Μc/Os

(1) Task control block

The primary role of a task control block is to save the virtual processor's stack pointer register SP for that task. In fact, as the complexity of task management increases, it should also save some additional information.

A. The most straightforward way to identify a person's task is to have a name for each task, because the tasks in Uc/os-ii have a unique priority, so uc/os-ii is the task's priority as the task's identity. So the task control block also wants to save the task's priority level.

B. Additionally, a task is in a different state at different times, and it is clear that the data that records the status of the task should also be saved in the task control block.

C. Therefore, the system must create a data structure for each task that holds the relevant information about the task, which is called the Task Control block (TCB) of the task.

(2) The structure of the task in memory

(3) General structure of user task code

(4) Idle tasks provided by the system

A. In a multitasking system, the system often runs in the so-called idle state at some time without a user task class, and UC/OS-II provides a system task called the Idle Task Ostaskldle () in order for the CPU to do something when no user task can be performed.

B.μc/os-ii stipulates that a user application must use this idle task, and that the task cannot be deleted by software

(5) Statistical tasks

Another system task provided by Μc/OS is the statistical task Ostaskstat (). This statistic task calculates the time per second that the CPU is used in a unit time and stores the result as a percentage in the variable oscpusage so that the application accesses it to understand the CPU utilization, so this system task Ostaskstat () is called a statistical task.

(6) Priority level of the task

A. Uc/os_ii the priority of the mission into 64 priority levels, each of which is represented by a number. The number 0 indicates that the task has the highest priority, and the higher the number, the lower the priority level of the task.

B. The user can os_cfg the file according to the needs of the application. H describes the number of task priority levels in the application by assigning values to Changshu Os_lowest_prio, which represents the lowest priority. Once defined, this constant means that the priority level available in the system is 0,1,2 ...., Os_lowest_prio, Total os_lowest_prio+1.

C. Fixed, the system always assigns the lowest priority level Os_lowest_prio to the idle task automatically.                             If statistical tasks are also used in the application, the system assigns the priority os_lowest_prio-1 to the statistics task automatically, so the priority level that the user task can use is: 0,1,2 ... Os_lowest_prio-2 of Os_lowest_prio-1, a total of

(7) Task stack

A.

B.

C.

D.

(8) Initialization of the task stack

A.

B.

C.

D.

E.

(9) Task Readiness table and task scheduling

A.

B.

C.

D

(ten) Ucos system clock

A.

B.

C.

D.

22. Operating system tasks and clock beats

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.