lf-lang / reactor-c

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

Thread id for worker 0 is uninitialized #452

Closed cmnrd closed 1 week ago

cmnrd commented 1 week ago

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.