More small threads or few bigger ones ?
Posted: Tue Jun 02, 2020 5:10 pm
What is recommended use of threads (STM32F407) ?
In robot, I have one IMU thread reading data from two 6050 over I2C on Prio+2. There is about 3-4ms delay between reads (about 200Hz update from DMP on 6050s)
But now considering how to deal with other stuff - pwm stuff, some calculations, adc sensing, UART read/write. Right now I have about 5-6 additional threads handling this pieces of code with Prio+1 or NormalPrio on them and various sleep time (10s for RC stuff, 50 for rest).
Debug Thread window shows me that I have still plenty of Idle time so it should be ok from performance perspective but I would like to know how to consider one bigger thread with bigger stack space vs more smaller ones. Sure, more threads will consume more memory and I will loose more time in switching but code is much easier to read and maintain.
Is there some reason why to put all code from 5-6 threads (beside of mem/switch time) into one or this number of threads is ok for Chibios and I can enjoy them ?
In robot, I have one IMU thread reading data from two 6050 over I2C on Prio+2. There is about 3-4ms delay between reads (about 200Hz update from DMP on 6050s)
But now considering how to deal with other stuff - pwm stuff, some calculations, adc sensing, UART read/write. Right now I have about 5-6 additional threads handling this pieces of code with Prio+1 or NormalPrio on them and various sleep time (10s for RC stuff, 50 for rest).
Debug Thread window shows me that I have still plenty of Idle time so it should be ok from performance perspective but I would like to know how to consider one bigger thread with bigger stack space vs more smaller ones. Sure, more threads will consume more memory and I will loose more time in switching but code is much easier to read and maintain.
Is there some reason why to put all code from 5-6 threads (beside of mem/switch time) into one or this number of threads is ok for Chibios and I can enjoy them ?