From _mem_free (this is in all versions of MQX I have access to ...)
| /* Reset the _mem_test pointers */ |
| mem_pool_ptr->POOL_PHYSICAL_CHECK_BLOCK = (STOREBLOCK_STRUCT_PTR) mem_pool_ptr->POOL_PTR; |
| 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; |
| | _int_enable(); |
| | result = MQX_CORRUPT_STORAGE_POOL; |
| | break; |
| | } /* 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?