tasklwIP - A Lightweight TCP/IP stack - Tasks: task #16181, Priority desynchronization between...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

task #16181: Priority desynchronization between LwIP and FreeRTOS

Submitter:  Jonathan D <jona>
Submitted:  Thu 05 May 2022 03:08:10 PM UTC
   
 
Category:  Contrib Should Start On:  Thu 05 May 2022 12:00:00 AM UTC
Should be Finished on:  Thu 05 May 2022 12:00:00 AM UTC Priority:  4
Status:  None Privacy:  Public
Assigned to:  None Percent Complete:  0%
Open/Closed:  Closed Planned Release:  None
Effort:  0.00

Fri 06 May 2022 01:53:31 PM UTC, comment #1: 

Sorry for the confusion, what is in sys_arch.c is fine.
In our implementation, we mixed "FreeRTOS" priorities (0 to 6) and "CMIS_OS" priorities (-3 to 3).
This can be closed

Jonathan D <jona>
Thu 05 May 2022 03:08:10 PM UTC, original submission:  

In LwIP, priorities for tasks span from -3 to +3.
In FreeRTOS, priorities span from 0 to 6.

Here is a patch to resynchronize both scales:

---
diff --git a/ports/freertos/sys_arch.c b/ports/freertos/sys_arch.c
index 84bd463..7d40f83 100644
--- a/ports/freertos/sys_arch.c
+++ b/ports/freertos/sys_arch.c
@@ -477,7 +477,7 @@ sys_thread_new(const char *name, lwip_thread_fn thread, void *arg, int stacksize
 
   /* lwIP's lwip_thread_fn matches FreeRTOS' TaskFunction_t, so we can pass the
      thread function without adaption here. */
-  ret = xTaskCreate(thread, name, (configSTACK_DEPTH_TYPE)rtos_stacksize, arg, prio, &rtos_task);
+  ret = xTaskCreate(thread, name, (configSTACK_DEPTH_TYPE)rtos_stacksize, arg, makeFreeRtosPriority(prio), &rtos_task);
   LWIP_ASSERT("task creation failed", ret == pdTRUE);
 
   lwip_thread.thread_handle = rtos_task;
---

With:
---
/* Convert from CMSIS type osPriority to FreeRTOS priority number */
unsigned portBASE_TYPE makeFreeRtosPriority (osPriority priority)
{
  unsigned portBASE_TYPE fpriority = tskIDLE_PRIORITY;
 
  if (priority != osPriorityError) {
    fpriority += (priority - osPriorityIdle);
  }
 
  return fpriority;
}
---

Jonathan D <jona>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by goldsimon (Updated the item)
  • -email is unavailable- added by jona (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-05-06 goldsimon Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code