lf-lang / reactor-c

A reactor runtime written in C
Other
10 stars 23 forks source link

Generalize RP2040 (and in the future, STM32) support to NUM_CORES #438

Open sberkun opened 1 month ago

sberkun commented 1 month ago

Currently, the rp2040 support assumes that there is one main core and one other core: https://github.com/lf-lang/reactor-c/blob/b58a3a5cc1d9c6854104719597db21895872081c/low_level_platform/impl/src/lf_rp2040_support.c#L223-L258

However, future versions of this chip (i.e. an RP4040) may have more cores. Ideally, lf_thread_create and lf_thread_join should be revised to account for this. The generalization probably won't be perfect (since multicore_launch_core1 doesn't lend itself well to more cores), but should be aimed at a potential future with a 4-core RP4040. Something like the following may be used to abstract away multicore_launch_core1:

// assume this function will exist in some future version of the pico-sdk
void multicore_launch(int core, void (*entry)(void)) {
    multicore_launch_core1(entry); // for now, assume core == 1
}

This work on generalization will probably lend itself well to future STM32 support, as many STM32 devices do have more than 2 cores.