-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What should be the user-facing API #161
Comments
Link to the thread: #159 (comment) |
The legitimate uses of the thread API that I have encountered have to do with I/O. E.g., create a thread that waits for keyboard input and then schedule a physical action when getting that input. Generally, you need a thread in LF whenever you need to call a blocking function. Is there some other way to provide such functionality? |
With Zephyr I think we have three options:
I am not yet convinced that we should expose a thread API, isnt it likely that the users are familiar with the API of the underlying OS? Then they can create pthread instead of lf-threads when e.g. working in Linux |
If we already provide a platform, then why should hide it from users? More use of our platform APIs will lead to more portable code... That seems to be a clear advantage to me. Is there a cost to this that I'm not appreciating? |
I think one of the key advantages of having a minimal threading API exposed, in addition to portability, is the ability to make it clear what is NOT supported. For Zephyr, for example, I could see there being two distinct Zephyr platforms available, say, Zephyr-KThreads and Zephyr-Posix. The former could implement unimplementable functions by erroring out. |
I will have to think a bit about this. I think it makes sense with 2 Zephyr platforms to be compatible with Applications using both pthreads and kthreads. I think the optimal design of the kthreads-platform is to statically allocate the stacks for the worker-threads, which will be the first |
To me, number of workers is not the same as numbers of threads. I think these things need to be kept separate... |
To support federated execution, more threads than workers are needed (currently, although this may change). |
I think it makes sense to statically allocate the stack for NUM_WORKERS threads (or NUM_WORKERS+1(?) in the case of federated execution). Even though a worker is not a thread each worker consumes exactly one thread and the total number of workers is known compile-time. This is information which should be used to reduce dynamic memory allocation |
As discussed in #159, the Zephyr implementation of
lf_thread_create
uses statically allocated memory for stack and thread control blocks. It allocates space for a number of threads equal to the number of workers. This does not work if the users are gonna use reactor-c as a threading library and spawn threads and so on. There are also other functions, which are not prefixed with an underscore which I think should not be used by the user. E.g.lf_notify_of_event
lf_sleep_until_locked
lf_initialize_clock
I think this question also has to be addressed in supporting bodiless reactions. My opinion is to expose as little as possible and not try to be a threading library, but rather have the platform API as an internal API for runtime code only.
The text was updated successfully, but these errors were encountered: