Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Server \ Unix average load average load calculation method     - Fragment Android developers learning to resolve (Programming)

- Spring-depth understanding of the various annotations (Programming)

- How to enhance the security of Linux systems (Linux)

- Spring classic face questions Share (Programming)

- C ++ multithreading and critical resource instance (Programming)

- CentOS terminal display Chinese (Linux)

- Linux common network tools: ping host sweep (Linux)

- Hibernate Search 5.5 in the search results sorted (Linux)

- MySQL 5.6.12 binary log path switching binlog (Database)

- Build Python3.4 + PyQt5.5.1 + Eric6.1.1 development platform under Mac OS X 10.11.1 (Server)

- Notebook computer forget password solution (Linux)

- Vi syntax highlighting settings (Linux)

- Ubuntu 14.04 / 14.10 how to install FFmpeg 2.5.1 (Linux)

- MySQL server after an unexpected power outage can not start (Database)

- Linux crontab command format example (Linux)

- Learning OpenCV: (VS2010-openCV2.4.3-win7 configuration instructions) (Linux)

- The source code compiler installation Nginx 1.8.0 under Ubuntu 14.10 (Server)

- Use Vagrant up a local development environment tutorials (Server)

- Graphics of Java Tools (Programming)

- SSH port forwarding application (Server)

  Unix average load average load calculation method
  Add Date : 2017-08-31      
  Average load? That the system in a period of time the average number of processes, which means that the system is busy. Average load and CPU utilization is not the same, more able to express the system's busy, the following will be the system's average load calculation and related to a brief introduction.

View method

Linux system using the uptime command, or view / proc / loadavg can see the system load average load. Use the uptime command to display the average load for the system in the last 1 minute, 5 minutes, and 10 minutes, respectively.

[Root @ localhost ~] # uptime
19:32:09 up 5 days, 8:53, 5 users, load average: 0.05, 0.04, 0.05
[Root @ localhost ~] # cat / proc / loadavg
0.04 0.04 0.05 1/394 23203

Then uptime command to calculate the load average of the working principle of what is it?

Calculation method

For a single cpu and multi-cpu situation, the system's average load situation is slightly different. Single cpu is the simplest case, such as the average of the past one minute inside to determine the system is running or waiting for the number of processes that the average load of the system, but slightly different in the linux system, those in io wait state of the process Will be incorporated into the calculation. This can lead to CPU utilization and the average load is very different in most of the processes are doing IO, even if the average load is great, there will be no great CPU utilization. In addition, some systems for the process and the thread is also very different, some for each thread will be calculated, some only concerned about the process, for Hyper-Threading Technology thread, it may be another way. For multi-CPU average load calculation, in the case of single-CPU divided by the number of CPU.

File: kernel / timer.c:

Unsigned long avenrun [3];

Static inline void calc_load (unsigned long ticks)
Unsigned long active_tasks; / * fixed-point * /
Static int count = LOAD_FREQ;

Count - = ticks;
If (count < 0) {
Count + = LOAD_FREQ;
Active_tasks = count_active_tasks ();
CALC_LOAD (avenrun [0], EXP_1, active_tasks);
CALC_LOAD (avenrun [1], EXP_5, active_tasks);
CALC_LOAD (avenrun [2], EXP_15, active_tasks);
The function sched.h in the kernel

/ *
 * These are the constant used to fake the fixed-point load-average
 * Counting. Some notes:
 * - 11 bit fractions expand to 22 bits by the multiplies: this gives
 * A load-average precision of 10 bits integer + 11 bits fractional
 * - if you want to count load-averages more often, you need more
 * Precision, or rounding will get you. With 2-second counting freq,
 * The EXP_n values would be 1981, 2034 and 2043 if still using only
 * 11 bit fractions.
 * /
Extern unsigned long avenrun []; / * Load averages * /
Extern void get_avenrun (unsigned long * loads, unsigned long offset, int shift);

#define FSHIFT 11 / * nr of bits of precision * /
#define FIXED_1 (1 < < FSHIFT) / * 1.0 as fixed-point * /
#define LOAD_FREQ (5 * HZ + 1) / * 5 sec intervals * /
#define EXP_1 1884 / * 1 / exp (5sec / 1min) as fixed-point * /
#define EXP_5 2014 / * 1 / exp (5sec / 5min) * /
#define EXP_15 2037 / * 1 / exp (5sec / 15min) * /

#define CALC_LOAD (load, exp, n) \
        Load * = exp; \
        Load + = n * (FIXED_1-exp); \
        Load >> = FSHIFT;

Extern unsigned long total_forks;
Extern int nr_threads;
DECLARE_PER_CPU (unsigned long, process_counts);
Extern int nr_processes (void);
Extern unsigned long nr_running (void);
Extern unsigned long nr_uninterruptible (void);
Extern unsigned long nr_iowait (void);
Extern unsigned long nr_iowait_cpu (int cpu);
Extern unsigned long this_cpu_load (void);
Ewma algorithm

Linux system in many ways the use of this algorithm, such as TC system in addition to this there is the CBQ algorithm, which is an algorithm of statistics
- Ubuntu users Steam controller does not work solutions (Linux)
- Debian (Wheezy) Install Redmine 2.6 (Programming)
- CentOS 6.5 x86_64 system customized automated deployment (Linux)
- Java multi-threaded shared communications variables (Programming)
- Redhat Close SELinux correct step (Linux)
- Linux System Getting Started Tutorial: Using the Linux common commands (Linux)
- C ++ precision performance test function (Programming)
- CentOS 7 virt-manager can not connect a local hypervisor (Linux)
- How to use Quagga BGP (Border Gateway Protocol) router to filter BGP routing (Linux)
- iOS Sensor Development - add to APP phone password, fingerprint security authentication (Programming)
- ORA-27054 NFS problem solving (Database)
- Linux non-root user uses less than 1024 ports (Linux)
- Linux environment variable configuration (Linux)
- How to use SVN to manage our source code (Server)
- Linux + Apache + PHP + Oracle based environment to build (Server)
- Openfire achieve load balancing cluster by Nginx (Server)
- CentOS / Debian configuration Gitlab 7.1x to build self Git repository (Linux)
- How to deploy Icinga client (Server)
- Linux Routine Task Scheduler (Linux)
- Getting Started with Linux system to learn: How to compress JPEG images on the command line (Linux)
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.