Ⅰ, write in front
Before studying this article, you can refer to my previous article :
Ucos2_stm32f1 Migration Detailed process (summary article)
UCOS2 system kernel tells ( a ) _ General Description
or in accordance with the thinking of the previous article ( from the outside to the inside ), this article (combined with the source code) further in-depth ucos system kernel, I will be described in the source code comments to change to Chinese, for your reference.
The previous article generally describes the entire project "peripheral" code, this article will be further "shortlisted" to further describe the function called by Osinit.
This article is also a combination of the previously ported, can be run source code to tell about the latest version of the UCOS2 system kernel part of the code (around the source to tell).
The content of this article does not need to be understood in depth, you can know first.
For more information about this article, go to look down.
Ⅱ,osinit The function that is called
The previous article probably covered the contents of the function, and this article will further describe Osinit System initialization.
I will the functions called by the Osinit are divided into two categories: mandatory and non-mandatory .
Required Classes : Initialization that is closely related to the system and the task. In fact, these initializations are given initial values for variables, structs, and so on. (such as: System run flag bit initialization paused, highest priority pointing to NULL, etc.) their initialization is inside the system kernel os_core.c .
non-mandatory class : This class is a class that can be used to initialize without being tuned. From the code can see that they have a pre-processing flag in front of "such as:#if (Os_flag_en > 0u) && (Os_max_flags > 0u)", these flags are located in os_cfg.h (previously said the cropping of the system), when we do not use these features, that is, the system cut off these features, they will not be initialized.
event flag groups, memory management, Message Queuing, and so on are non-mandatory classes that are initialized in their own . C Files (not located in os_core.c). "such as:os_flaginit located in the os_flag.c file"
Here's a look at the mandatory class (non-mandatory classes are described later in conjunction with related resources):
1. Os_initmisc(mandatory Class)
This function will be The Osinit () is used to initialize the variables. Initialize the values in the red box parameters, which are the necessary variables for the system, like we define a global variable and assign it initially .
2 . os_initrdylist(mandatory Class)
This function is The Osinit () is used to initialize the Ready table. The readiness table here actually refers to the idea of arranging a task into a table to initialize the table. To perform a response task, you need to know the priority of the task, the task control block, the task currently pointed to, and a series of information.
3 . os_inittcblist(mandatory Class)
This function will be The Osinit () is used to initialize the idle TCB (Task control block). This initialization function contains information that is more difficult and is important to the system (the TCB is described later).
The so-called task control block, is to control the task related variables data information types of structure of the classification, its structure contains a lot of information.
Understanding the TCB requires a certain familiarity with the data structure.
4 . os_initeventlist(mandatory Class)
This function will be The Osinit () is used to initialize the idle ECB (event control block ). This function although I classify it into the system must class this piece, actually not exactly correct. The event described here is actually one or set of system-related resources (Message Queuing, mailbox, semaphore, mutex, etc.). You can see the following macro definitions in ucos_ii.h:
#define Os_event_en (((Os_q_en > 0u) && (Os_max_qs > 0u)) | | (Os_mbox_en > 0u) | | (Os_sem_en > 0u) | | (Os_mutex_en > 0u))
These resources, such as Message Queuing, mailboxes, semaphores, mutexes, and so on, need to be initialized when they are called by the system. The system defines them as events, and the use is to call the relevant data, which is defined by the system as the ECB (the event control block ), somewhat similar to the TCB ( task control block ).
5 . Os_inittaskidle(mandatory Class)
This function will be Osinit () is used to create idle tasks. This function is not intercepted at the beginning of this section (the screen height is limited), but this function is also a function that the system must initialize. Idle function is actually the system to create the task is finished, those are suspended , or deleted , the system idle nothing to do, it will be to perform this idle task .
Idle tasks play a role in statistics , so-called statistics, is that we all know the CPU occupancy rate , the more idle statistics,the more CPU idle, the lower the CPU utilization. "From CPU usage should be easy to understand why to create idle tasks"
Ⅲ, Case Engineering download
The author for beginners to provide routines are removed a lot of unnecessary features, streamlining the official code, for beginners to understand, a simple and clear engineering for everyone to learn.
I provide examples of projects are on the board after many tests and no problem before uploading to The cloud disk, welcome to download testing, reference learning.
I will be the latest UCOS2.92 operating system ported to F0, F1, F3, F4 on each hardware platform, you can choose to download according to your chip series.
Ucos based on STM32F0 series instances:
HTTPS://YUNPAN.CN/CBYHFXCFPAIBH Access Password 4437
Ucos based on STM32F1 series instances:
Https://yunpan.cn/cByHum5BStkEK Access Password 00a6
Ucos based on STM32F3 series instances:
Https://yunpan.cn/cByHrMmkekIar Access Password da90
Ucos based on STM32F4 series instances:
Https://yunpan.cn/cByHx47jehTgX Access Password 5a04
Some of the comments in this article have been modified to Chinese:
Https://yunpan.cn/cMGZKfnVVb2Li Access Password 49c2
Ⅳ, description
Ucos related articles I will be the first time in the public to share with you, you can also visit my blog.
When you master Ucos on one platform, other platforms are similar, please do not restrict a platform.
The above summary is for reference only, if has the wrong place, please understanding.
Ⅴ, last
More wonderful articles I will share the first time in the public number, if you do not want to miss, you can follow my public number.
based on the principle of free sharing, it is convenient for us to learn knowledge and share technical knowledge on the platform regularly. If you feel that the content you share is useful to you, and you want to learn more about the relevant articles, please use the search "Embedddeveloper" or scan the QR code below, attention, there will be more exciting content waiting for you.
UCOS2 system kernel tells (ii) _ Initialize Call function