μC/OS-ⅱ learning notes (2)-kernel structure

Source: Internet
Author: User

Http://tiandongying.blog.163.com/blog/static/16361282120108155533351/

μC/OS-ⅱ learning notes (2) -- kernel structure

14:25:16 | category:

Operating System | Tag:
| Large font size, medium/small subscription

Take notes on reading 《ucosⅱ 文

1. critical section. Pay attention to the disconnection time. Generally, the microprocessor is related to interrupt/interrupt commands. The C-language compiler used by the user must have a mechanism that can directly perform operations on the Guanzhong/Open interrupt location in C. Some C compilers allow you to insert assembly language statements in your C source code. This makes it easy to insert a microprocessor command to disconnect or interrupt the gateway. Some compilers place interruptions/Open interruptions in the C language in the extended part of the language. OS _enter_critical () and OS _exit_critical (). OS _cpu.h.

2. A task is an infinite loop. Tasks can be deleted by themselves. Void yourtask (void * pdata ). Formal parameter variables are brought in when the user code is executed for the first time, allowing the user application to pass any type of data to the task. μC/OS-ⅱ can manage up to 64 tasks. To enable μC/OS-ⅱ to manage user tasks, you must pass the start address of a task along with other parameters to one of the following two functions: ostastcreat or ostaskcreatext ().

3. Task status

A: ostaskcreate () or ostaskcreateext () Wake up from sleep;

B: osstart () enables the program with the highest priority in the readiness State to start running;

C: The ostimedly () or ostimedlyhmsm () task enters the waiting state, waiting for a certain period of time;

D: ossempend (), osmboxpend (), or osqpend () Tasks enter the waiting state, waiting for the event to occur;

E: All ostaskidle () tasks are executed without running them.

4. The task control block OS _tcbs is used to save the task status and all reside in Ram. In the ucos_ii.h file. The maximum number of tasks that an application can have (OS _max_tasks) is defined in the OS _cfg.h file. The maximum number of tasks is the maximum number of OS _tcbs tasks assigned to the user program by μC/OS-ⅱ. Setting the number of OS _max_tasks to the actual number of tasks required by your application can reduce the demand for Ram. Control Block List array ostcbtbl [].

5. μC/OS-ⅱ allows each task to have its own stack. It is particularly important that the stack capacity of each task can be arbitrary.

6. Ready table. The ready table has two variables: osredygrp and osrdytbl []. When the number of tasks in your application is small, reducing the OS _lowest_pr1o value can reduce the RAM (data space) Demand of μC/OS-ⅱ. Any task with the highest priority is found.

7. Task Scheduling. Task-level scheduling is completed by the function ossched. Interruption-level scheduling is completed by another function osintext. Finally, OS _task_sw () is called to complete the actual task switchover. Ostcbhighrdy. Osctxswctr. Osctxsw ().

8. Lock and unlock the scheduler. When a low-priority task sends a message to the multi-task mailbox, message queue, and semaphore, you do not want high-priority tasks to gain control of the CPU before the mailbox, queue, and semaphore receive messages. In this case, you can use the scheduler function. Use osschedlock () and osschedunlock () Functions with caution because they affect the normal management of tasks by μC/OS-ⅱ.

9. The idle task keeps adding 1 to a 32-bit counter named osidlectr. The statistical task uses this counter to determine the actual CPU time consumed by the current application.

10. interrupt handling. To allow interruption nesting, in most cases, the user should clear the interruption source before the interruption is enabled. Osintenter (). Osintexit (). The user should do as little as possible to interrupt the service and leave most of the work to the task. One of the following functions is called to notify a task of the interruption of service subprograms: osmboxpost (), osqpost (), osqpostfront (), and ossempost ().

11. Differences between interrupted Task Switching and task switching: osintexit () looks very similar to ossched (). But there are three differences. First, osintexit () reduces the number of nested interrupt layers by 1. The scheduling condition of the scheduling function ossched () is: the number of nested interrupt counters and the oslocknesting) both must be zero. The second difference is that the retrieval value y required by osrdytbl [] is saved in the osintexity variable. This is to avoid arranging local variables in the task stack. This variable is related to the osintctxsw () function for task interruption switching. Finally, osintexit () will call osintctxsw () If task switching is required (). Instead of calling OS _task_sw (), just as in the ossched () function.

12. You must enable the timer after the multi-task system is started, that is, after osstart () is called. In other words, the first thing to do after osstart () is to initialize the timer interruption. A large amount of work in ostimtick () is to give each user a task control block OS _tcb the time delay item ostcbdly minus 1.

13. initialization. Osinit ().

14. Start. Multi-task startup is implemented by calling osstart. However, before starting μC/OS-ⅱ, you must create at least one application task.

15. Version: osversion ().

 

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.