Fast Math Arm (17) --uC/OS-II Task Management Block TCB

Publisher:徽宗古泉Latest update time:2021-01-19 Source: eefocusKeywords:Arm  OS-II Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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. 


Keywords:Arm  OS-II Reference address:Fast Math Arm (17) --uC/OS-II Task Management Block TCB

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

Arm launches TCS23, what are the highlights?
Recently, Arm announced the launch of 2023 Total Computing Solution (TCS23). TCS23 provides a complete set of the latest IP designed and optimized for specific workloads, including the latest CPU IP Cortex-X4, Cortex-A720 and Cortex-A520, the latest GPU Immortalis-G720, Mali-G720 and Mali-G620, as well as important up
[Mobile phone portable]
Arm launches TCS23, what are the highlights?
IAR Embedded Workbench for Arm version 9.40 improves code security by integrating PACBTI
IAR Embedded Workbench version 9.40 introduces seamless compatibility with the Pointer Validation and Branch Target Identification (PACBTI) extension, protecting embedded applications from a variety of security attacks. Uppsala, Sweden – June 7, 2023 – IAR, a global leader in embedded software and services, has rele
[Embedded]
Research and application of embedded GUI based on uc/os-ii
1 Introduction The human-computer interface is an important part of the embedded system. The popular GUIs are: Nano-X, microwindows, Minigui, QT/Embedded, OpenGUI, etc. generally adopt client/server structure and multi-threading concept, and are mainly used in embedded Linux systems. UC/OS-II is a simple a
[Microcontroller]
Research and application of embedded GUI based on uc/os-ii
ARM basic learning-register addressing mode and instructions
Addressing mode Data is stored in memory. Addressing is simply to find the address of the stored data or instructions. The memory has many storage units for storing data. In other words, addressing is to read the content stored in the corresponding address number in the storage device where the data is located; the
[Microcontroller]
ARM basic learning-register addressing mode and instructions
Overview of 11 embedded operating systems based on ARM
Embedded Operation System (EOS) refers to an operating system used in embedded systems. Embedded systems are divided into four layers: hardware layer, driver layer, operating system layer and application layer. The embedded operating system is responsible for the allocation of all software and hardware resources of th
[Microcontroller]
Design of wireless multi-bed ECG monitor based on ARM9
1 Introduction With the accelerated pace of social life and the gradual aging of the population, cardiovascular disease has become one of the most important diseases threatening human life. Such diseases are often characterized by suddenness, short-term and dangerous. If they are not discovered and treated in t
[Industrial Control]
Design of wireless multi-bed ECG monitor based on ARM9
How do ARM processors switch between different modes?
1. How to switch between different modes of ARM processor? A: The other six modes besides the user mode are called privileged modes. In these modes, programs can access all system resources and switch processor modes at will. Processor modes can be switched through software control (directly setting the last five bi
[Microcontroller]
How to install Linux system on ARM development board
      Note: This section assumes that you have connected the serial port and USB port between the development board and the PC, and set the development board to boot from NOR  Flash  . After the system update and installation is complete, please set it to boot from Nand  Flash  .       The bootloader, kernel and file
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号