The change implemented in https://github.com/lf-lang/reactor-c/pull/437 skips worker thread creation for worker 0. This seems to be Ok, but it also leaves env->thread_ids[0] uninitialized. Consequently, we cannot use lf_thread_set_cpu or similar API functions to set affinity or priority of the main thread from LF code. In fact, code that simply loops over all threads to set their affinity segfaults on the first worker.
A fix for this bug would assign the thread id of the main thread to env->thread_ids[0]. However, it is unclear for me how to do this in a portable way.
The change implemented in https://github.com/lf-lang/reactor-c/pull/437 skips worker thread creation for worker 0. This seems to be Ok, but it also leaves
env->thread_ids[0]
uninitialized. Consequently, we cannot uself_thread_set_cpu
or similar API functions to set affinity or priority of the main thread from LF code. In fact, code that simply loops over all threads to set their affinity segfaults on the first worker.A fix for this bug would assign the thread id of the main thread to
env->thread_ids[0]
. However, it is unclear for me how to do this in a portable way.