<?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: Mutexes in C++ Classes in MQX Software Solutions</title>
    <link>https://community.nxp.com/t5/MQX-Software-Solutions/Mutexes-in-C-Classes/m-p/391712#M13107</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Louie,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I assume that you may be able to reproduce the same project using the default K70 BSP. Am I right? Modifying the BSP should not affect the Kernel behavior.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I ask you this because I need to reproduce this issue on my side with K70 default BSP. Can you confirm this and provide the project where you see this problem? It is ok if you create a simple project just to test this case.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;Carlos&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 20 Oct 2015 00:12:36 GMT</pubDate>
    <dc:creator>Carlos_Musich</dc:creator>
    <dc:date>2015-10-20T00:12:36Z</dc:date>
    <item>
      <title>Mutexes in C++ Classes</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Mutexes-in-C-Classes/m-p/391711#M13106</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi - background dev tool info:&amp;nbsp; I'm using CW10.6, MQX 4.1, K70 processor, custom BSP cloned from K70 tower board. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I seem to be having issues when trying to initialize a mutex in my C++ class.&amp;nbsp; I can successfully create a mutex in my main task, however any attempt to create/init a mutex in a C++ class fails and returns !MQX_OK.&amp;nbsp; I tried several examples deom the MQX manuals, and from the forums, but no success.&amp;nbsp; My function (below) is successful if called from main, but unsuccessful if called from my C++ class.&amp;nbsp; I've also tried initializing using a mutex attribute and attribute init:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/***** CODE START *****/&lt;/P&gt;&lt;P&gt;MUTEX_STRUCT_PTR InitMutex()&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; MUTEX_STRUCT&amp;nbsp; newMutex;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; // Initialize the mutex&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; if (_mutex_init(&amp;amp;newMutex, 0) != MQX_OK) &lt;/P&gt;&lt;P&gt;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp; printf("Initialize print mutex failed.\n");&lt;/P&gt;&lt;P&gt;&amp;nbsp; _task_block();&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; // Test the new mutex&lt;/P&gt;&lt;P&gt;&amp;nbsp; if (_mutex_lock(&amp;amp;newMutex) == MQX_OK)&lt;/P&gt;&lt;P&gt;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp; printf("Mutex lock worked.\n");&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; _mutex_unlock(&amp;amp;newMutex);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; return (MUTEX_STRUCT_PTR)&amp;amp;newMutex;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;/***** CODE END *****/&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then call with &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/***** CODE START *****/&lt;/P&gt;&lt;P&gt;MUTEX_STRUCT_PTR m_ptrQueueMutex = InitMutex();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if (m_ptrQueueMutex != NULL)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("Got a mutex pointer\n");&lt;/P&gt;&lt;P&gt;/***** CODE END *****/&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In main, I get this output:&lt;/P&gt;&lt;P&gt;"Mutex lock worked"&lt;/P&gt;&lt;P&gt;"Got a mutex pointer"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And in my class I get:&lt;/P&gt;&lt;P&gt;"Initialize print mutex failed."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help or suggestions will be greatly appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Oct 2015 23:14:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Mutexes-in-C-Classes/m-p/391711#M13106</guid>
      <dc:creator>louiemoye</dc:creator>
      <dc:date>2015-10-13T23:14:25Z</dc:date>
    </item>
    <item>
      <title>Re: Mutexes in C++ Classes</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Mutexes-in-C-Classes/m-p/391712#M13107</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Louie,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I assume that you may be able to reproduce the same project using the default K70 BSP. Am I right? Modifying the BSP should not affect the Kernel behavior.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I ask you this because I need to reproduce this issue on my side with K70 default BSP. Can you confirm this and provide the project where you see this problem? It is ok if you create a simple project just to test this case.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;Carlos&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Oct 2015 00:12:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Mutexes-in-C-Classes/m-p/391712#M13107</guid>
      <dc:creator>Carlos_Musich</dc:creator>
      <dc:date>2015-10-20T00:12:36Z</dc:date>
    </item>
    <item>
      <title>Re: Mutexes in C++ Classes</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Mutexes-in-C-Classes/m-p/391713#M13108</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is your object a global, with a constructor that is being called before MQX is started perhaps?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://community.nxp.com/message/349610"&gt;https://community.freescale.com/message/349610&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Oct 2015 17:33:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Mutexes-in-C-Classes/m-p/391713#M13108</guid>
      <dc:creator>matthewkendall</dc:creator>
      <dc:date>2015-10-22T17:33:07Z</dc:date>
    </item>
  </channel>
</rss>

