controlling CPU utilization

后端 未结 2 1637
有刺的猬
有刺的猬 2021-01-06 06:08

how is it advisable to control the cpu utilization during run time ?

poll the cpu load and insert sleeps ?

2条回答
  •  不知归路
    2021-01-06 06:22

    The easiest way would be to modify your main loop to either wait on input - the classic event driven model - or to periodically sleep for a short period of time.

    If putting the application to sleep I would only use a very short timeout, somewhere within 10-100ms range as any more and some user input would be delayed, and any less would involve a lot more OS level overhead in switching your application.

提交回复
热议问题