Massive CPU load using std::lock (c++11)

前端 未结 4 989
梦毁少年i
梦毁少年i 2020-12-07 15:09

My recent efforts to implement a thread/ mutex manager ended up in an 75% CPU load (4 core), while all four running threads were either in sleep or waiting for a mutex beein

4条回答
  •  青春惊慌失措
    2020-12-07 15:29

    First I want to thank for all answers.

    During the work on an example code, that reproduces the effect, I found the source of trouble.

    The conditional part locks both mutexes, while it uses just one for the std::condition_variable::wait() function.

    But I still wonder, what going on behind the scene, that produces such a high CPU load.

提交回复
热议问题