diff --git a/include/minix/com.h b/include/minix/com.h index e4bf92c88..850882610 100755 --- a/include/minix/com.h +++ b/include/minix/com.h @@ -325,6 +325,7 @@ # define GET_MACHINE 12 /* get machine information */ # define GET_LOCKTIMING 13 /* get lock()/unlock() latency timing */ # define GET_BIOSBUFFER 14 /* get a buffer for BIOS calls */ +# define GET_LOADINFO 15 /* get load average information */ #define I_PROC_NR m7_i4 /* calling process */ #define I_VAL_PTR m7_p1 /* virtual address at caller */ #define I_VAL_LEN m7_i1 /* max length of value */ diff --git a/include/minix/syslib.h b/include/minix/syslib.h index 4de6e077a..8317ea6f5 100755 --- a/include/minix/syslib.h +++ b/include/minix/syslib.h @@ -106,6 +106,7 @@ _PROTOTYPE(int sys_segctl, (int *index, u16_t *seg, vir_bytes *off, /* Shorthands for sys_getinfo() system call. */ #define sys_getkmessages(dst) sys_getinfo(GET_KMESSAGES, dst, 0,0,0) #define sys_getkinfo(dst) sys_getinfo(GET_KINFO, dst, 0,0,0) +#define sys_getloadinfo(dst) sys_getinfo(GET_LOADINFO, dst, 0,0,0) #define sys_getmachine(dst) sys_getinfo(GET_MACHINE, dst, 0,0,0) #define sys_getproctab(dst) sys_getinfo(GET_PROCTAB, dst, 0,0,0) #define sys_getprivtab(dst) sys_getinfo(GET_PRIVTAB, dst, 0,0,0) diff --git a/include/minix/type.h b/include/minix/type.h index a3aa7de54..8c2603356 100755 --- a/include/minix/type.h +++ b/include/minix/type.h @@ -107,6 +107,24 @@ struct kinfo { int relocking; /* relocking check (for debugging) */ }; +/* Load data accounted every this no. of seconds. */ +#define _LOAD_UNIT_SECS 6 + +/* Load data history is kept for this long. */ +#define _LOAD_HISTORY_MINUTES 15 +#define _LOAD_HISTORY_SECONDS (60*_LOAD_HISTORY_MINUTES) + +/* We need this many slots to store the load history. */ +#define _LOAD_HISTORY (_LOAD_HISTORY_SECONDS/_LOAD_UNIT_SECS) + +/* Runnable processes and other load-average information. */ +struct loadinfo { + u16_t procs_enqueued; /* current no. of runnable processes */ + u16_t proc_load_history[_LOAD_HISTORY]; /* history of proc_s_cur */ + u16_t proc_last_slot; + clock_t last_clock; +}; + struct machine { int pc_at; int ps_mca; diff --git a/include/stdlib.h b/include/stdlib.h index 827a69164..670893f3c 100755 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -71,6 +71,7 @@ _PROTOTYPE( char *initstate, (unsigned _seed, char *_state, _PROTOTYPE( long random, (void) ); _PROTOTYPE( char *setstate, (const char *state) ); _PROTOTYPE( void srandom, (unsigned seed) ); +_PROTOTYPE( int getloadavg, (double *, int) ); #endif #ifdef _MINIX diff --git a/include/unistd.h b/include/unistd.h index f05e94add..c45f94500 100755 --- a/include/unistd.h +++ b/include/unistd.h @@ -42,6 +42,7 @@ #define SI_DMAP_TAB 3 /* get device <-> driver mappings */ #define SI_MEM_ALLOC 4 /* get memory allocation data */ #define SI_DATA_STORE 5 /* get copy of data store */ +#define SI_LOADINFO 6 /* get copy of load average structure */ /* NULL must be defined in according to POSIX Sec. 2.7.1. */ #define NULL ((void *)0)