Common variables of UCOS-II

Source: Internet
Author: User
Tags constant definition

1, osrunning

Defined in ucos_ii.h and declared as boolean data type. This variable is used to indicate whether the OS is running.

"1" indicates the running status, and vice versa.

2. ospriocur

Defined in ucos_ii.h and declared as int8u data type, indicating the priority of the current task.

3. ospriohighrdy

Defined in ucos_ii.h, declared as int8u data type, indicating the priority of the highest priority task.

4. ostcbhighrdy

Defined in ucos_ii.h as an OS _tcb pointer pointing to the highest priority task TCB.

Prototype: OS _tcb * ostcbhighrdy;

5. ostcbcur

Defined in ucos_ii.h and declared as an OS _tcb pointer pointing to the currently running task TCB.

Prototype: OS _tcb * ostcbcur;

6. osrdygrp

Defined in ucos_ii.h, the data type declared as int8u, ready task group, used in identifying the priority of the ready state task, used to find the priority of the ready state task. It is used to find the task with the highest priority during task scheduling. To switch tasks.

7. osrdytbl []

Defined in ucos_ii.h as the data type declared as int8u. It is a one-dimensional array that stores the task table of ready tasks. Work with osrdygrp to find the task with the highest priority.

8, osintexity

9, osunmaptbl []

10, ostcbpriotbl [ospriohighrdy]

Define in ucos_ii.h and declare it as an OS _tcb pointer array to create a needle table for the task block. The prototype is as follows:

11, ostcbx; // used to quickly obtain the data of the ready table.

Ostcby;

Ostcbbitx;

Ostcbbity;

12. ostcblist; // The head pointer of the task control block linked list.

Ostcbfreelist; // the header pointer to the list of idle task control blocks. In osinit (), the empty task pointer must be initialized first. After a new task is called, the new task obtains a task control block in the idle task chain table as the task control block of the new task. Ostcbfreelist will update the header pointer so that the next idle task block is used as the header pointer.

Note: The task control block uses a two-way linked list. To speed up the access to the task control block, ucoⅱ also defines another array OSTCB * ostcbtbl []; this function is used to store pointers to the control blocks of each worker task in an array element in the order of task priority. This allows you to access the task control blocks of a task very quickly, instead of traversing the task control block linked list.

The task scheduling is based on the task readiness table. Osrdytbl []; In order to facilitate the search of ready tables, another variable int8u osrdygrp is defined; to speed up the operation, we recommend an array osmaptbl [] = {0x01,0x02,0x04,0x08,0x10 ,0x20,0x40,0x80 };

Similarly, osunmaptbl []; is an array defined to accelerate the priority.

13. The event data structure composed of semaphores, message mailboxes, and message queues should be managed as well-functional event processing tasks. This management function includes two aspects. First, record and sort all tasks waiting for events. Second, the task should be allowed to have a certain waiting period. For recording and processing of these event tasks, ucoⅱ adopts a method similar to the task readiness table, and uses an array int8u oseventtbl [] as the record table for recording wait event tasks, that is, the waiting task table. Similarly, int8u oseventgrp is added to speed up the response to this table. This event table is the same as the task-ready table. It is called a task wait table.

This chapter describes Initialization Configuration items in the μC/OS-II. Because the μC/OS-II provides the source code to the user, the Initialization Configuration item consists of a series of # define constant statements, all in the file OS _cfg.h. The user's project file group should contain this file. This section describes each constant defined by # define constant. The sequence of introduction is the same as the sequence in which they appear in OS _cfg.h. Table 12.1 lists the μC/OS-II functions controlled by constants. "Type" is the type of the function, "set 1" indicates that when the definition constant is 1, the corresponding function can be opened, and "other constants" are other control constants related to this function. Note that OS _cfg.h must be included when compiling the project file to make the defined constant take effect. Table t12.1
μC/OS-II functions and related constants (# define constant definition)

OS _max_events

OS _max_events defines the maximum number of event control blocks in the system. Each message mailbox, message queue, and semaphore in the system requires an event control block. For example, if there are 10 message mailboxes, 5 message queues, and 3 semaphores in the system, the minimum OS _max_events value is 18. As long as the message mailbox, message queue, or semaphore is used in the program, the minimum OS _max_events value should be set to 2.

OS _max_mem_parts

OS _max_mem_parts defines the maximum number of memory blocks in the system. memory blocks are operated by memory management functions (defined in the OS _mem.c file ). If you want to use a memory block, the minimum OS _max_mem_parts value should be set to 2, and the constant OS _mem_en must be set to 1 at the same time.

OS _max_qs

OS _max_qs defines the maximum number of message queues in the system. To use message queue...

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.