|
发表于 2020-8-25 19:15:01
|
显示全部楼层
/*
**************************************************************************
*
* This allows us to better catch runaway realtime processes that
* might otherwise hang the whole system (if they're POSIX realtime
* processes).
*
* We do this by getting a "lease" on CPU time, and then extending
* the lease every so often as real time elapses. Since we only
* extend the lease by a bounded amount computed on the basis of an
* upper bound of how much CPU the code is "expected" to consume during
* the lease interval, this means that if we go into an infinite
* loop, it is highly probable that this will be detected and our
* process will be terminated by the operating system with a SIGXCPU.
*
* If you want to handle this signal, then fine... Do so...
*
* If not, the default is to terminate the process and produce a core
* dump. This is a great default for debugging...
*
*
* The process is basically this:
* - Set the CPU percentage limit with cl_cpu_limit_setpercent()
* according to what you expect the CPU percentage to top out at
* measured over an interval at >= 60 seconds
* - Call cl_cpu_limit_ms_interval() to figure out how often to update
* the CPU limit (it returns milliseconds)
* - At least as often as indicated above, call cl_cpu_limit_update()
* to update our current CPU limit.
*
* These limits are approximate, so be a little conservative.
* If you've gone into an infinite loop, it'll likely get caught ;-)
*
* As of this writing, this code will never set the soft CPU limit less
* than four seconds, or greater than 60 seconds.
*
*/
|
|