AnsweredAssumed Answered

Why are _mem_test and _mem_free changing the same pointers in the memory pool?

Question asked by Don Marquardt on Mar 27, 2014
Latest reply on Apr 24, 2014 by Don Marquardt

From _mem_free (this is in all versions of MQX I have access to ...)


/* Reset the _mem_test pointers */
mem_pool_ptr->POOL_FREE_CHECK_BLOCK = mem_pool_ptr->POOL_FREE_LIST_PTR;




And from _mem_test


  next_block_ptr = NEXT_PHYS(mem_pool_ptr->POOL_PHYSICAL_CHECK_BLOCK);
  if (next_block_ptr->PREVBLOCK != mem_pool_ptr->POOL_PHYSICAL_CHECK_BLOCK){
     mem_pool_ptr->POOL_BLOCK_IN_ERROR = next_block_ptr;
  } /* Endif */
  mem_pool_ptr->POOL_PHYSICAL_CHECK_BLOCK = next_block_ptr;



The problem, if I understand correctly, is that if _mem_free gets called from another task while _mem_test is running, the "POOL_PHYSICAL_CHECK_BLOCK" gets reset to the beginning of the pool and the _mem_test starts over again.


The MQX Manual states...


The function can be called by only one task at a time because it keeps state-inprogress

variables that MQX controls. This mechanism lets other tasks allocate

and free memory while _mem_test() runs.



In the case of my system this means that my call to _mem_test never completes.


Does anyone have a solution that does not disable interrupts for the duration of the _mem_test?