简体   繁体   中英

Regarding PThread's and PThread Barriers

I'm writing an SMT program, and I'm trying to workaround an interesting problem.

I need all my functions to exit together, however some of the threads get stuck at barriers, even when i don't want them to.

My question is: what happens when i delete a barrier? Do threads stuck at the barrier release? Is there a way to signal a release to a certain barrier, even if the number of threads at the barrier hasn't been achieved?

Thanks

It's not legal to call pthread_barrier_destroy() if there's any threads blocked on the barrier.

When your thread decides to exit early in a situation where other threads could be waiting on it at a barrier, it should call pthread_barrier_wait() before exiting.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM