Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years, 5 months ago.
LPC1768 freezes when memory pool is full
Hi all,
I'm having this problem where the LPC1768 (on a UBLOX C027 dev board) freezes when the memory pool is full. My program has an architecture very much similar to the example for Memory Pool on the RTOS page: https://developer.mbed.org/handbook/RTOS#memorypool . One thread collects GPS data and one thread transmit data via GPRS to my remote server.
The problem arises when I lose the connection to my remote server. At this point the GPS data is still appended to a queue , which is governed by a fixed size memory pool.
Queue and Memory Pool declaration
typedef struct { char gps_mess[128]; } MemoryPool<message_t , 16> message_pool; Queue<message_t , 16> message_pool;>
When the memory pool is full, the LPC1768 freezes. My workaround is have a flag to check whether or not the GPRS connection is still good. If the connection to the remote server is busted then don't append anything else to the queue.
So my question is:
1 - Is there another way to check if the memory pool is full?
2 - Why should my program become frozen? I'm using a queue anyway, so any new message should be written into the queue like a ring buffer. But from the evidence I'm seeing, this is not consistent with my understanding. An explanation is much appreciated.
Many thanks,
1 Answer
9 years, 5 months ago.
The documentation says that thhe alloc returns a NULL pointer when there is a error . Do you test this ? (the sample program forgets to do this test)
Thanks for the suggestion. I tried this check before putting a message into the queue but after 16 messages, any message after that is not put into the queue. The alloc function always return zero even though the messages are consumed in another thread (ie. the messages appear on the remote server and free function is called ). In general, the LPC1768 doesn't freeze but new messages are not appended into the queue.
posted by 17 Mar 2015