Last change
on this file since 399 was 389, checked in by coas-nagasima, 5 years ago |
ビルドが通るよう更新
|
-
Property svn:eol-style
set to
native
-
Property svn:mime-type
set to
text/x-csrc;charset=UTF-8
|
File size:
272 bytes
|
Rev | Line | |
---|
[388] | 1 | #define _GNU_SOURCE
|
---|
| 2 | #include <stdlib.h>
|
---|
| 3 | #include <sys/sysinfo.h>
|
---|
| 4 |
|
---|
| 5 | int getloadavg(double *a, int n)
|
---|
| 6 | {
|
---|
| 7 | struct sysinfo si;
|
---|
| 8 | if (n <= 0) return n ? -1 : 0;
|
---|
| 9 | sysinfo(&si);
|
---|
| 10 | if (n > 3) n = 3;
|
---|
| 11 | for (int i=0; i<n; i++)
|
---|
| 12 | a[i] = 1.0/(1<<SI_LOAD_SHIFT) * si.loads[i];
|
---|
| 13 | return n;
|
---|
| 14 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.