<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Redlib malloc - thread safe? in LPCXpresso IDE</title>
    <link>https://community.nxp.com/t5/LPCXpresso-IDE/Redlib-malloc-thread-safe/m-p/534899#M4337</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by TheFallGuy on Tue Apr 26 13:20:12 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Have you tried Newlib instead? IIRC, that provides the lock functions.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 21:46:59 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T21:46:59Z</dc:date>
    <item>
      <title>Redlib malloc - thread safe?</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Redlib-malloc-thread-safe/m-p/534898#M4336</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by jharwood on Tue Apr 26 12:30:28 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I would like to use the stdlib functions malloc and friends, printf and friends in a RTOS environment. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It appears that malloc is not thread safe, I tried declaring a function &lt;/SPAN&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;void __malloc_lock(void)&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;SPAN&gt; but it was not called. I also stepped through the malloc code to see if there were any 'cpsie i' and 'cpsid i' instructions in there.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So I guess that I have to wrap every call to the standard library functions with the appropriate OS guard calls.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there any possibility that the __malloc_lock and __malloc_unlock stubs could be added to the Redlib library?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 21:46:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Redlib-malloc-thread-safe/m-p/534898#M4336</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T21:46:58Z</dc:date>
    </item>
    <item>
      <title>Re: Redlib malloc - thread safe?</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Redlib-malloc-thread-safe/m-p/534899#M4337</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by TheFallGuy on Tue Apr 26 13:20:12 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Have you tried Newlib instead? IIRC, that provides the lock functions.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 21:46:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Redlib-malloc-thread-safe/m-p/534899#M4337</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T21:46:59Z</dc:date>
    </item>
    <item>
      <title>Re: Redlib malloc - thread safe?</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Redlib-malloc-thread-safe/m-p/534900#M4338</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by jharwood on Tue Apr 26 14:45:34 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: TheFallGuy&lt;/STRONG&gt;&lt;BR /&gt;Have you tried Newlib instead? IIRC, that provides the lock functions.&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the suggestion TheFallGuy.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It's a much larger library, as CodeRed points out. Each of the function calls need to be changed to, for example; _printf_r() and the first argument is a pointer to a struct _reent.&amp;nbsp; Each thread of execution holds its own copy of the _reent structure which takes up 240 bytes of memory.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 21:47:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Redlib-malloc-thread-safe/m-p/534900#M4338</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T21:47:00Z</dc:date>
    </item>
    <item>
      <title>Re: Redlib malloc - thread safe?</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Redlib-malloc-thread-safe/m-p/534901#M4339</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by larryvc on Tue Apr 26 15:14:32 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: jharwood&lt;/STRONG&gt;&lt;BR /&gt;Each thread of execution holds its own copy of the _reent structure which takes up 240 bytes of memory.&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;That's a lot considering we were trying to get a simple blinky to weigh in at around 200 bytes.:) I know, slightly off topic, and I'm a bit bored.:D&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 21:47:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Redlib-malloc-thread-safe/m-p/534901#M4339</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T21:47:01Z</dc:date>
    </item>
    <item>
      <title>Re: Redlib malloc - thread safe?</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Redlib-malloc-thread-safe/m-p/534902#M4340</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by CodeRedSupport on Tue Apr 26 23:57:32 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: jharwood&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;Is there any possibility that the __malloc_lock and __malloc_unlock stubs could be added to the Redlib library?&lt;BR /&gt;&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;SPAN&gt;At present we have no plans to make Redlib thread safe - we have seen little or no demand for this (to date). Our recommendation if you want thread safe is to use Newlib, or wrap the Redlib functions yourself (as you have already suggested).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;CodeRedSupport&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 21:47:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Redlib-malloc-thread-safe/m-p/534902#M4340</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T21:47:01Z</dc:date>
    </item>
  </channel>
</rss>

