Managing the working area of a thread

Discussions and support about ChibiOS/RT, the free embedded RTOS.
gujoseleite
Posts: 4
Joined: Mon Apr 16, 2018 10:37 pm

Managing the working area of a thread

Postby gujoseleite » Wed Apr 18, 2018 7:41 pm

Hi,

I use RTOS Chibios / RT on the Arduino platform. I developed my project using 3 threads of size 100 bytes for the working area parameter. But I think I'm wasting my memory. I tried to run some tests and I got a strange result.
When defining the working area in 0 bytes, the program works in the same way as for 10, 20 ... 50 or 100 bytes (each thread has operations to flash LEDs, start motors, read digital and analog pins among other functions). I've even used a code to determine the ram memory consumption and in fact each thread uses a portion of the memory. I wonder if anyone knows why this occurred and if there is any way to determine the size of the threads since on the arduino platform the debug is difficult to perform.

Thanks!

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: Managing the working area of a thread

Postby Giovanni » Wed Apr 18, 2018 8:26 pm

Hi,

Without debug capability there is no way to assess the stack usage. You may try to measure it at runtime by counting the filler in stacks (you need to enable the option for stack filling in chconf.h).

The effect of stack overflows can also not be immediately evident, you may think it is OK but it is overflowing and bite you afterward.

An API to measure stack usage is in the to-do list but results could be unreliable.

Unless you really need it to be an Arduino I would suggest to get a cheap Nucleo board a solve a lot of problems in one go.

Giovanni


Return to “ChibiOS/RT”

Who is online

Users browsing this forum: No registered users and 6 guests