I originally expected to learn Arm7 quickly, but after reading it, I found that it was not of the same order of magnitude as C51. If you really want to learn it well, you still need to study a lot of things. I went around in circles and then turned to learning uC/OS-II. You can't learn something step by step according to the routine in the book. That would be too slow. I read a uC/OS-II textbook and found that it takes some time to learn it well. I don't know if I have enough time to learn it as I am short of time, but as long as I am not interrupted by other more important things, I think I can stick to it. I believe in my perseverance.
Earlier we learned that uC/OS-II (later written as ucos2, easier to type) can realize multitasking. After reading the book, I found that although this multitasking function is much stronger than C51, it really takes a lot of effort to gradually figure it out. Moreover, it is basically impossible for people who are poor in C language, have no assembly experience, have no concept of operating system, and have no foundation in digital circuits to learn well in a short time without a teacher.
ucos2 manages the system tasks through something called TCB. TCB stands for Task Control Block. It is a data structure defined in the form of a structure in C language. Its definition is as follows:
typedef struct os_tcb
{
OS_STK *OSTCBStkPrt; //Pointer to the top of the task stack
struct ostcb *OSTCBNext; //Pointer to the next task control block
INT16U OSTCBDly; //Delay time of tasks, etc. (number of beats)
INT8U OSTCBStat; //The current status flag of the task
INT8U OSTCBPrio; //Task priority
INT8U OSTCBX;
INT8U OSTCBY;
INT8U OSTCBBitX;
INT8U OSTCBBitY;
}OS_TCB;
ucos2 manages tasks through the above-mentioned control block. Every time a user creates a task, the system will assign a task control block TCB to the task. Once a new task is created using the OSTaskCreate() function, the task's OS_TCB is assigned. That is to say, when the user executes the OSInit() function, the system creates a lot of OS_TCB data structures and related linked lists for the user. But at this time, each TCB in the linked list is empty. When the OSTaskCreate() function is called, the newly created task will be assigned an OS_TCB, and the members in this TCB will be assigned according to the actual situation.
.OSTCBStkPrt:
A pointer to the top of the stack of the current task. ucos2 allows each task to have its own stack, and the capacity of each task stack can be of any size. You just need to define its size yourself.
.OSTCBNext:
Used for linking the task control block OS_TCB. This linked list is used in the OSTimeTick() clock tick function to refresh the delay variable OSTCBDly of each task. The OS_TCB task control block of each task has been linked to the linked list when the task is established.
.OSTCBDly:
This variable is used when you need to delay a task for a number of clock ticks, or when you need to suspend a task for a period of time to wait for an event to occur, and this waiting is subject to a timeout limit. In this case, this variable stores the maximum number of clock ticks that the task is allowed to wait for the event to occur. If this variable is 0, it means that the task is not delayed. If this variable is 0, it means that the task is not delayed, or it means that there is no limit to the time to wait for the event to occur, that is, it will wait forever.
.OSTCBStat:
The task status word is used to store the current status of the task, for example: ready to run, suspended on semaphore, etc., which are defined in the system.
.OSTCBPrio:
The priority of the task. The higher the task priority, the smaller the OSTCBPrio value.
Several other variables were added to speed up the calculation.
Some global variables related to the task control block are defined in the ucos2 system.
OS_EXT OS_TCB *OSTCBCur;
OS_EXT OS_TCB *OSTCBFreeList;
OS_EXT OS_TCB *OSTCBHighRdy;
OS_EXT OS_TCB *OSTCBList;
OS_EXT OS_TCB *OSTCBPrioTBl[OS_LOWEST_PRIO+1];
OS_EXT OS_TCB OSTCBTbl[OS_MAX_TASKS+OS_N_SYS_TASKS];
These variables are used to manage the task control blocks. By managing these task control blocks, the task management function can be achieved. I will talk about the relationship between these variables after I understand them clearly.
Previous article:Learn Arm quickly (18) -- Understanding uC/OS-II task management
Next article:Quickly learn Arm (16)--PLL (Phase-Locked Loop 2)
Recommended ReadingLatest update time:2024-11-16 19:40
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Level shifter reverse circuit
- Please advise, is it necessary to consider the safety power when calculating the LED resistance?
- [RVB2601 creative application development] u8g2+IP
- What are the screw holes in this package for?
- Summary of learning about state machine scheduling design
- After adding a product to the ONENET platform, when adding a device, the automatic subscription option allows the device to subscribe to ONENET messages?
- Power chip static current
- Commonly used anti-collision algorithms in RFID systems
- Children's Poetry White Model Electronic Book--Why does the relationship between current parallel negative feedback circuits have a negative sign?
- How do sensors with different protocols achieve remote data transmission?