Skip to content
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

Fixed initialization of the master worker thread id #454

Merged
merged 4 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/threaded/reactor_threaded.c
Original file line number Diff line number Diff line change
Expand Up @@ -1112,6 +1112,7 @@ int lf_reactor_c_main(int argc, const char* argv[]) {
// run on the main thread, rather than creating a new thread.
// This is important for bare-metal platforms, who can't
// afford to have the main thread sit idle.
env->thread_ids[j] = lf_thread_self();
continue;
}
if (lf_thread_create(&env->thread_ids[j], worker, env) != 0) {
Expand Down
7 changes: 7 additions & 0 deletions low_level_platform/impl/src/lf_arduino_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,13 @@ typedef void* (*lf_function_t)(void*);
*/
int lf_available_cores() { return 1; }

lf_thread_t lf_thread_self() {
// Not implemented. Although Arduino mbed provides a ThisThread API and a
// get_id() function, it does not provide a way to get the current thread as a
// Thread object.
return NULL;
}

int lf_thread_create(lf_thread_t* thread, void* (*lf_thread)(void*), void* arguments) {
lf_thread_t t = thread_new();
long int start = thread_start(t, *lf_thread, arguments);
Expand Down
5 changes: 5 additions & 0 deletions low_level_platform/impl/src/lf_flexpret_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ int lf_available_cores() {
return FP_THREADS - 1; // Return the number of Flexpret HW threads
}

lf_thread_t lf_thread_self() {
// Not implemented.
return NULL;
}

int lf_thread_create(lf_thread_t* thread, void* (*lf_thread)(void*), void* arguments) {
/**
* Need to select between HRTT or SRTT; see
Expand Down
2 changes: 2 additions & 0 deletions low_level_platform/impl/src/lf_windows_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ int lf_available_cores() {
return sysinfo.dwNumberOfProcessors;
}

lf_thread_t lf_thread_self() { return GetCurrentThread(); }

int lf_thread_create(lf_thread_t* thread, void* (*lf_thread)(void*), void* arguments) {
uintptr_t handle = _beginthreadex(NULL, 0, lf_thread, arguments, 0, NULL);
*thread = (HANDLE)handle;
Expand Down
Loading