• AVR Freaks

Hot!PIC32MZ : XC32 (2.10) libraries are thread safety ?

Author
Emcy
Super Member
  • Total Posts : 568
  • Reward points : 0
  • Joined: 2008/01/09 03:37:06
  • Location: 0
  • Status: offline
2019/04/24 00:31:13 (permalink)
0

PIC32MZ : XC32 (2.10) libraries are thread safety ?

Hello,
I have a problem : I use PIC32MZ with FreeRTOS and it reboots because there are pointer address cirtical errors.
 
I'm not sure but I think problem come from snprintf function : snprintf fuction, malloc function and floating-point functions/operations are thread safety ?
How can I solve my problem (and to guarantee my functios are thread safety) ?
 
post edited by Emcy - 2019/04/24 00:47:39
#1

7 Replies Related Threads

    LostInSpace
    Super Member
    • Total Posts : 259
    • Reward points : 0
    • Joined: 2016/03/11 22:47:59
    • Location: 0
    • Status: offline
    Re: PIC32MZ : XC32 (2.10) libraries are thread safety ? 2019/04/25 18:26:50 (permalink)
    0
    You will find no mention of threading in the XC32 documentation at all (that should be a clue).
     
    To get any information at all you should search with your favorite search engine: "gcc threading", or "gcc thread safety", etc... XC32 is based on GCC.
     
    HTH
    #2
    andersm
    Super Member
    • Total Posts : 2621
    • Reward points : 0
    • Joined: 2012/10/07 14:57:44
    • Location: 0
    • Status: offline
    Re: PIC32MZ : XC32 (2.10) libraries are thread safety ? 2019/04/25 22:42:01 (permalink)
    0
    SteveHagemanTo get any information at all you should search with your favorite search engine: "gcc threading", or "gcc thread safety", etc... XC32 is based on GCC.

    The C standard libary is not part of GCC. The question isn't limited to threads, but also to whether the functions can safely be called from interrupts.
     
    Of the functions listed by OP, malloc almost certainly isn't re-entrant, math functions set errno and have a shared rounding mode state, but should otherwise be safe. You may want to consider switching to Newlib, which documents this, and offers re-entrant versions of functions that normally aren't (though I don't know off the top of my head how the XC32 distribution was configured).
    #3
    Emcy
    Super Member
    • Total Posts : 568
    • Reward points : 0
    • Joined: 2008/01/09 03:37:06
    • Location: 0
    • Status: offline
    Re: PIC32MZ : XC32 (2.10) libraries are thread safety ? 2019/04/26 00:02:38 (permalink)
    0
    I thank you.
    It's disconcerting to don't find documentation about it :(
    #4
    friesen
    Super Member
    • Total Posts : 2066
    • Reward points : 0
    • Joined: 2008/05/08 05:23:35
    • Location: Indiana, USA
    • Status: offline
    Re: PIC32MZ : XC32 (2.10) libraries are thread safety ? 2019/04/26 08:19:10 (permalink)
    0
    There is a fair bit of documentation in the FreeRTOS docs about this.
     
    xc32 malloc isn't going to be threadsafe, at minimum you need to be wrapping it in freertos' wrapper or similar to only allow single threaded malloc access.
     
    I'm not sure about snprintf.

    Erik Friesen
    #5
    Emcy
    Super Member
    • Total Posts : 568
    • Reward points : 0
    • Joined: 2008/01/09 03:37:06
    • Location: 0
    • Status: offline
    Re: PIC32MZ : XC32 (2.10) libraries are thread safety ? 2019/04/29 00:02:32 (permalink)
    0
    I thank you.
    I modified my code to use FreeRTOS malloc function wihich is thread safety. I have always my problem : I think problem come from (snf)printf functions. Where can I find source code of thread safety (snf)printf for PIC32MZ (I need to print float) ?
     
    #6
    qhb
    Superb Member
    • Total Posts : 9998
    • Reward points : 0
    • Joined: 2016/06/05 14:55:32
    • Location: One step ahead...
    • Status: offline
    Re: PIC32MZ : XC32 (2.10) libraries are thread safety ? 2019/04/29 01:59:58 (permalink)
    0
    Note, the term is "thread safe", not "thread safety" ...
     

    Nearly there...
    #7
    friesen
    Super Member
    • Total Posts : 2066
    • Reward points : 0
    • Joined: 2008/05/08 05:23:35
    • Location: Indiana, USA
    • Status: offline
    Re: PIC32MZ : XC32 (2.10) libraries are thread safety ? 2019/04/29 05:27:09 (permalink)
    0
    snprintf may well be calling malloc.  The right way is to wrap malloc, and possibly snprintf.

    Erik Friesen
    #8
    Jump to:
    © 2019 APG vNext Commercial Version 4.5