EmbDev.net

Forum: µC & Digital Electronics How to debug multi-threading problems


von Hossein H. (Company: Mehraris) (ht96)


Rate this post
useful
not useful
Hi everyone.

we had performed a project with discovery f746 board that within it 
there just was a GUI task to run emwin functions.

Another functions(such as reading and writing in sd card by fatfs , usb, 
spi and stuff) were placed in the routines of Buttons.

After several times the process of USB (writing in USB flash memory) was 
ran ,

the running process stuck in RTOS's functions.

After that we decided to add another thread for USB In such a way that, 
after pressing related button ,a message is sent to this thread.

At the first it works fine but after several times running this thread, 
mkdir function (for creating a folder in USB flash memory) returns 
FR_NOT_ENOUGH_CORE value and the program stops running.

For resolving this problem we increased stack and heap size and memory 
that is assigned to the thread but it didn't affect.

In new version of our project we just added a new thread and the routine 
that was placed in Notification sent by related button was moved into 
new thread and another sections of projects haven't changed.

In old version of project that there just was one thread , mkdir 
function never had returned FR_NOT_ENOUGH_CORE value.

It seems this problem is related to multi threading but we don't know 
how to find out running process and fix problem.

Could anyone help us to resolve this problem?

We'll appreciate your suggestions.

von Martin L. (Guest)


Rate this post
useful
not useful
Hi,

can you monitor the memory consumption of the threads? For me this 
sounds like a memory leak. (I.e. the thread allocates new memory every 
time it runs without freeing it afterwards.)

Best regards,
 Martin L.

von старший мудрый троль (Guest)


Rate this post
useful
not useful
Well, many external devices are to be considered a resource, and thus 
can only be accessed by one thread at the time. Protect them with a 
semaphore.

von Hossein H. (Company: Mehraris) (ht96)


Rate this post
useful
not useful
Hi Martin.

Thanks for your reply.
Actually i don't know how to monitor the memory consumption of the 
thread and i don't know if there is a function to free the memory 
allocated to thread.

von Hossein H. (Company: Mehraris) (ht96)


Rate this post
useful
not useful
Hi старший мудрый троль.

Thanks a lot.

: Edited by User
von Shiv K. (Company: CETPA) (shivk23)


Rate this post
useful
not useful
Above links broken, So, you can use Debugging Programs with Multiple 
Threads. When dealing with debugging multi-threaded application, it is 
better not to use standard breakpoints that suspend just the thread 
where the breakpoint is set. Defining a standard breakpoint in your 
application, will only break the related thread. The other threads will 
be still running. For more visit at this link
https://stackoverflow.com/questions/1695268/multi-threaded-debugging-tutorial-for-gdb-and-c

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.