EmbDev.net

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


Author: Hossein H. (Company: Mehraris) (ht96)
Posted on:

Rate this post
0 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.

Author: Martin L. (Guest)
Posted on:

Rate this post
0 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.

Author: старший мудрый троль (Guest)
Posted on:

Rate this post
0 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.

Author: Hossein H. (Company: Mehraris) (ht96)
Posted on:

Rate this post
0 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.

Author: Hossein H. (Company: Mehraris) (ht96)
Posted on:

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

Thanks a lot.

: Edited by User

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig