Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable number of sub priorites #106

Open
CezaryGapinski opened this issue May 1, 2024 · 0 comments
Open

Configurable number of sub priorites #106

CezaryGapinski opened this issue May 1, 2024 · 0 comments
Assignees

Comments

@CezaryGapinski
Copy link

CMSIS-RTOS2 priorities available to user (Low, BelowNormal, Normal, AboveNormal, High, Realtime) are extended with a 3-bit sub priority and CMSIS-RTOS2 implementation can support flexible number of sub priorities (1, 2, 4 or 8).

Is it possible to implement reduced number of priorities for CMSIS-FreeRTOS port? I think it is a simple bit shift operation in few parts of the code.

Currently configMAX_PRIORITIES must be set to 56. Each priority needs a slot in RAM memory. For 56 priorities it causes high memory consumption. Maybe configMAX_PRIORITIES can be configurable?

configMAX_PRIORITIES 56 support all 8 sub priorities => shift = 0
configMAX_PRIORITIES 28 support 4 sub priorities (ex. Low..Low+1 are effectively the same) => shift = 1
configMAX_PRIORITIES 14 support 2 sub priorities (ex. Low..Low+3 are effectively the same) => shift = 2
configMAX_PRIORITIES 7 support 1 sub priority (ex. Low..Low+8 are effectively the same) => shift = 3

In the simplest form osPriority numbering can be scaled down (ex. for 1 sub priority => shift = 3):

osPriorityLow           =  8,   (8 >> 3) => FreeRTOS priority = 1
osPriorityLow1          =  8+1, ((8+1) >> 3) => FreeRTOS priority = 1
osPriorityLow2          =  8+2, ((8+2) >> 3) => FreeRTOS priority = 1
...
osPriorityLow7          =  8+7, ((8+7) >> 3) => FreeRTOS priority = 1
osPriorityBelowNormal   = 16,   (16 >> 3) => FreeRTOS priority = 2
...
osPriorityRealtime      = 48,   (48 >> 3) => FreeRTOS priority = 6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants