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

HG examples: Possible data races #563

Open
ryancaicse opened this issue Apr 14, 2022 · 1 comment
Open

HG examples: Possible data races #563

ryancaicse opened this issue Apr 14, 2022 · 1 comment

Comments

@ryancaicse
Copy link

Hi, should thread-shared static variable hg_progress_shutdown_flag be protected by locks?

hg_engine_finalize(void)
{
int ret;
/* tell progress thread to wrap things up */
hg_progress_shutdown_flag = 1;
/* wait for it to shutdown cleanly */
ret = pthread_join(hg_progress_tid, NULL);
assert(ret == 0);
(void) ret;
return;
}

static void *
hg_progress_fn(void *foo)
{
hg_return_t ret;
unsigned int actual_count;
(void) foo;
while (!hg_progress_shutdown_flag) {
do {
ret = HG_Trigger(hg_context, 0, 1, &actual_count);
} while (
(ret == HG_SUCCESS) && actual_count && !hg_progress_shutdown_flag);
if (!hg_progress_shutdown_flag)
HG_Progress(hg_context, 100);
}
return (NULL);
}

@soumagne
Copy link
Member

Yes you're right sorry, that's been low-priority for me on my list but that should be fixed to either use an atomic variable or use a lock.

@soumagne soumagne added this to the mercury-2.3.0 milestone Dec 9, 2022
@soumagne soumagne changed the title Possible data races HG examples: Possible data races Dec 9, 2022
@soumagne soumagne modified the milestones: mercury-2.3.0, future Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants