This section studies the priority of the process and the setting of the nice value. In the case of high CPU load, high priority processes take precedence. RHEL7 priority = Priority coefficient +nice value to determine. The precedence factor can be seen as a static value for a kernel, so we can change the priority by resizing Nice. Nice's values range from 20 to 19, and the higher the number, the lower the priority. Nice defaults to 0
First change the CPU to a single core, so that it is easy to experiment, see Cpuinfo, is a single core
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/58/7D/wKiom1Sy_k2BvbNMAABuYKSRjrE250.jpg "style=" float: none; "title=" 1.PNG "alt=" Wkiom1sy_k2bvbnmaabuyksrjre250.jpg "/>
Input top, can display the change of Cpu,nice value in real time
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/58/7A/wKioL1Sy_xXA-xXBAAOW1OiQ5go369.jpg "style=" float: none; "title=" 2.PNG "alt=" Wkiol1sy_xxa-xxbaaow1oiq5go369.jpg "/>
Press and hold Ctrl+shift+t, open two more terminals, and then execute two dead loop commands, which will cause the CPU usage to rise continuously, pay attention to their PID number
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/58/7D/wKiom1Sy_k6QHEl3AACExOiRBoo031.jpg "style=" float: none; "title=" 3.PNG "alt=" Wkiom1sy_k6qhel3aacexoirboo031.jpg "/>
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/58/7A/wKioL1Sy_xfRLEb7AABJSNVU17Q616.jpg "style=" float: none; "title=" 4.PNG "alt=" Wkiol1sy_xfrleb7aabjsnvu17q616.jpg "/>
Inside the top window, you can see that CPU utilization is basically half-divided because their nice values are the default 0
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/58/7D/wKiom1Sy_lGTlcs0AACcoGoHJ_M164.jpg "style=" float: none; "title=" 5.PNG "alt=" Wkiom1sy_lgtlcs0aaccogohj_m164.jpg "/>
You can change the nice value by Renice command, note that you must use root permissions to change
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/58/7A/wKioL1Sy_xmiRlD3AABol_zl5_I220.jpg "style=" float: none; "title=" 6.PNG "alt=" Wkiol1sy_xmirld3aabol_zl5_i220.jpg "/>
You can see that the nice value of 20 has the highest priority, so the CPU resources allocated to him are up to 95%
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/58/7D/wKiom1Sy_lSyv5DcAALYY7mNsj8651.jpg "style=" float: none; "title=" 7.PNG "alt=" Wkiom1sy_lsyv5dcaalyy7mnsj8651.jpg "/>
This time has been a bit of a card, can be killall to terminate the process
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/58/7D/wKiom1Sy_lSwEMECAABWslY3Te0978.jpg "style=" float: none; "title=" 8.PNG "alt=" Wkiom1sy_lswemecaabwsly3te0978.jpg "/>
In addition, in the top window, the direct input R can also change Nice's, as shown below
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/58/7A/wKioL1Sy_xyxbS68AAIvizv3Y4A540.jpg "style=" float: none; "title=" 9.PNG "alt=" Wkiol1sy_xyxbs68aaivizv3y4a540.jpg "/>
So how do you specify a nice value to run at the beginning, and you can prepend a value by adding nice-n to a normal command
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/58/7D/wKiom1Sy_lXB9hkdAABOR1Yd3Ok299.jpg "style=" float: none; "title=" 10.PNG "alt=" Wkiom1sy_lxb9hkdaabor1yd3ok299.jpg "/>
The value inside top is displayed as-10
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/58/7A/wKioL1Sy_x2TomkLAAFCw5pRCNM418.jpg "style=" float: none; "title=" 11.PNG "alt=" Wkiol1sy_x2tomklaafcw5prcnm418.jpg "/>
This article is from the "Mapo Tofu" blog, please be sure to keep this source http://beanxyz.blog.51cto.com/5570417/1602322
RHCE Learning Notes (19) priority of the process