Changes to μC/OS-II Ready List Algorithm on ARM Architecture

Publisher:渤海湾Latest update time:2021-04-30 Source: eefocusKeywords:μC Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

*② Interrupts need to be disabled when this function is called

*************************************

//New algorithm for ready priority scheduling, expanding the number of priorities from 8×8=64 to

//16×16=256

static void OS_SchedNew (void) {

#if OS_LOWEST_PRIO <= 63 // Reference provides up to 64 priorities

INT8Uy;

/*The function of array OSUnMapTbl[256]:

When given a binary unsigned integer, such as OSRdyGrp, how do you determine which bit is the least significant bit that is set to 1, that is, how do you find the position of the first 1 from right to left? When the processor does not have a ready-made instruction, you can first convert the 256 states of the number

Stored in the array OSUnMapTbl[256], when determining the minimum weight, query the array

OSUnMapTbl[OSRdyGrp]*/

y = OSUnMapTbl[OSRdyGrp];

OSPrioHighRdy = (INT8U)((y << 3) + OSUnMapTbl[OSRdyTbl[y]]);

#else//Now can provide 256 priorities

INT8Uy; //Ready table group, marked with 1 or 0

Are there any ready tasks?

INT16U *ptbl; //Pointer to a certain item in the ready list, determine which item it is after calculation

/*When the lower 8 bits of the 16-bit integer OSRdyGrp are not zero, get the least weighted bits 0~7 set to 1 in the ready list group,

Then get 8~15 digits*/

if ((OSRdyGrp & 0xFF) != 0) {

y = OSUnMapTbl[OSRdyGrp & 0xFF];

} else {

y = OSUnMapTbl[(OSRdyGrp >> 8) & 0xFF] + 8;

}

ptbl = &OSRdyTbl[y];/*Assign a pointer to a ready list array*/

if ((*ptbl & 0xFF) != 0) {

OSPrioHighRdy = (INT8U)((y << 4) + OSUnMapTbl[(*ptbl & 0xFF)]);

} else {

OSPrioHighRdy = (INT8U)((y << 4) + OSUnMapTbl[(*ptbl >> 8) & 0xFF] + 8);

}

#endif

}


The clz highest priority search algorithm is different from the new algorithm of μC/OS: the returned results are 8-bit and 16-bit integers respectively. This is because 8 bits can no longer represent values ​​> 255; the clz algorithm uses more 16- or 32-bit integers in the process to make full use of chip performance.


3 Scope of application

The waiting task list uses a similar process to the ready list operation. Note that the data type and algorithm must be changed at the same time. Although the algorithm is executed on CortexM3, it is applicable to ARM9 and later chips. Chips that support the ARM instruction set can use inline assembly in C language, and there is no need to write assembly search functions.


The algorithm described in this article is applicable to the following two situations.

① Using μC/OSII system:

◆ Request more task priorities;

◆ Applications that require superior product performance or are time-critical and want to further improve efficiency;

◆ Study, research or hope to optimize μC/OSII to expand its application scope.


② μC/OSII system not used:

◆ Transplant and modify the ready list algorithms of other operating systems;

◆ Write new operating systems or implement schedulers;

◆ Programming enthusiasts learn from and improve programming methods.


[1] [2]
Keywords:μC Reference address:Changes to μC/OS-II Ready List Algorithm on ARM Architecture

Previous article:Design of network fingerprint access control system based on ARM and POE
Next article:A Brief Analysis of Embedded Operating Systems

Latest Microcontroller Articles
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号