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

Fix race condition when thread pinning is disabled #158

Merged
merged 1 commit into from
Aug 23, 2023

Conversation

kittobi1992
Copy link
Member

In many algorithms, we use the cpu ID as unique index of a thread to access data structures. However, if thread pinning is disabled (e.g., in our library interfaces), the cpu ID is not unique. This can cause undefined behaviour if a thread is preempted by the OS while performing a criticial operation (e.g. inserting something into a vector). The fix now uses the tbb::this_task_arena::current_thread_index() method as unique ID in case thread pinning is disabled.

@kittobi1992 kittobi1992 merged commit 858c9f0 into master Aug 23, 2023
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant