Skip to content

Using HPX's mutex and condition_variable leads to 99% CPU usage #6545

Answered by hkaiser
phil-skillwon asked this question in Q&A
Discussion options

You must be logged in to vote

The HPX synchronization primitives (semaphore, condition_variable, etc.) suspend the running HPX (user-level) thread, not the underlying kernel (p-) thread. This is done to allow for other HPX threads to run while a particular one is blocked.

For this reason, the CPUs are still utilized 100% as the kernel threads that run the scheduling loop for HPX threads keep churning along.

If you want to reduce CPU utilization in case if no HPX work is available and ready to run, you can use

hpx::threads::set_scheduler_mode(hpx::threads::policies::scheduler_mode::fast_idle_mode);

first thing inside hpx_main that instructs the main scheduling loop to put the underlying kernel thread to sleep much fas…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by phil-skillwon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants