Menu

#142 MPU support: xTaskCreateRestricted() needs to guard ucStaticallyAllocated

v1.0 (example)
closed-invalid
nobody
None
5
2017-02-23
2017-02-22
No

FreeRTOS v9.0.0:

f MPU support is enabled with portUSING_MPU_WRAPPERS
compilation fails with
'TCB_t' has no member named 'ucStaticallyAllocated' tasks.c
if configSUPPORT_DYNAMIC_ALLOCATION is set to 1 and configSUPPORT_STATIC_ALLOCATION set to 0.
The reason is that ucStaticallyAllocated is only available if both are turned on.

Solution: guard it with:
#if( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE != 0 )
{
/ Tasks can be created statically or dynamically, so note
this task had a statically allocated stack in case it is
later deleted. The TCB was allocated dynamically.
/
pxNewTCB->ucStaticallyAllocated = tskSTATICALLY_ALLOCATED_STACK_ONLY;
}

Thanks
Erich

Discussion

  • Richard Barry

    Richard Barry - 2017-02-22

    Hi Erich - thanks for taking the time to report this. I think it has
    already been fixed. Please take a look at the head revision code here to
    see if you agree:
    https://sourceforge.net/p/freertos/code/HEAD/tree/trunk/FreeRTOS/Source/tasks.c

     
  • Erich Styger

    Erich Styger - 2017-02-22

    Yes, I already checked the version on SVN, and it is not fixed (it is fixed in some places).
    Have a look at line 746 (inside xTaskCreateRestricted()), that one is not guarded as in other places.

     

    Last edit: Erich Styger 2017-02-22
    • Richard Barry

      Richard Barry - 2017-02-22

      Referring to the link above, line 764 is a #endif statement, maybe you
      meant line 746? The whole of the xTaskCreateRestricted() function is
      protected by the following:

      if( ( portUSING_MPU_WRAPPERS == 1 ) && (

      tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE != 0 ) )

      on line 722 (again referring to the line number on the link above at the
      time of writing), so an attempt to compile ->ucStaticallyAllocated
      should only be made if tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE is 1
      (or at least, not 0).

      Am I missing something?

       
  • Erich Styger

    Erich Styger - 2017-02-23

    Yes, it is line 746.
    And I see now that the original v9.0.0

    if( ( portUSING_MPU_WRAPPERS == 1 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )

    has been changed on SVN to

    if( ( portUSING_MPU_WRAPPERS == 1 ) && ( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE != 0 ) )

    which solves the problem :-)
    I have missed that change, so issue is closed for me.

    thank you!

     
  • Richard Barry

    Richard Barry - 2017-02-23
    • status: open --> closed-invalid
     

Log in to post a comment.

Monday.com Logo