heliosproj / HeliOS

A community delivered, open source embedded operating system project.
http://www.heliosproj.org
GNU General Public License v2.0
352 stars 42 forks source link

Default size of heap block #30

Closed JakubRakus closed 2 years ago

JakubRakus commented 2 years ago

Default size of the OS's heap block (array static Byte_t heap[HEAP_RAW_SIZE] in mem.c) is IMHO a way too big for most usage scenarios. With the default values of CONFIG_HEAP_SIZE_IN_BLOCKS = 512 and CONFIG_HEAP_BLOCK_SIZE = 32 it takes 16 kB of RAM memory which is ridiculous number for most popular AVR-based Arduino boards like Uno, Mini, Micro, Leonardo with around 2 kB of SRAM. Even Arduino Mega has only 8 kB. For the ESP8266 boards, like Wemos D1 and clones, it eats half of RAM.

My proposal is to move these configs into defines.h section with architecture specific options. Then for example ARDUINO_ARCH_AVR should set defaults to no more than 128 B, current value of 16 kB may be usable only on architectures like ARDUINO_ARCH_SAM, ARDUINO_ARCH_SAMD, ESP32 ond other bigger ones with RAM counted in hundreds of kB or more.

MannyPeterson commented 2 years ago

Hi @JakubRakus

Thank you for your proposal. I agree and would like your thoughts on the following approach. My goal is to keep all of the user definable stuff in config.h. But what may be needed is to, by default, have CONFIG_HEAP_SIZE_IN_BLOCKS commented out in config.h in which case the compiler will fallback on the architecture specific define for the size of the heap in blocks.

#if defined(ARDUINO_ARCH_AVR)
#include <Arduino.h>
#define CURRENTTIME() micros()
#define DISABLE_INTERRUPTS() noInterrupts()
#define ENABLE_INTERRUPTS() interrupts()
#define TIME_T_TYPE uint32_t
#if !defined(CONFIG_HEAP_SIZE_IN_BLOCKS)
#define CONFIG_HEAP_SIZE_IN_BLOCKS 32u
#endif

How do you feel about that approach?

Thank You,

Manny

MannyPeterson commented 2 years ago

@JakubRakus haven't heard back from you but your recommendation is addressed in 0.3.1. Thanks!