*② 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.
Previous article:Design of network fingerprint access control system based on ARM and POE
Next article:A Brief Analysis of Embedded Operating Systems
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- Brief Analysis of Automotive Ethernet Test Content and Test Methods
- How haptic technology can enhance driving safety
- Let’s talk about the “Three Musketeers” of radar in autonomous driving
- Why software-defined vehicles transform cars from tools into living spaces
- How Lucid is overtaking Tesla with smaller motors
- Wi-Fi 8 specification is on the way: 2.4/5/6GHz triple-band operation
- Wi-Fi 8 specification is on the way: 2.4/5/6GHz triple-band operation
- Vietnam's chip packaging and testing business is growing, and supply-side fragmentation is splitting the market
- Vietnam's chip packaging and testing business is growing, and supply-side fragmentation is splitting the market
- Fundamentals of Spectrum Analysis
- Linux/UNIX System Programming Manual (Volumes 1 and 2)
- TMS320C6000 chip structure diagram and basic characteristics
- EEWORLD University Hall----Live Replay: TI's new generation of low-power Bluetooth microcontrollers helps you reduce application costs
- [Hua Diao Experience] 05 Building a development environment for Xingkong board: SSH connection and Jupyter programming
- What birthday gift should I give to my mother?
- Download the free NI white paper "Overcoming the Challenges of Production Test for Complex Devices Under Test"
- 2.4G module NRF24L01 debugging experience
- Design of analog signal source for remote sensing images with wide spectrum coverage
- DSP Basics--Fixed-point Decimal Operations