getloadavg

This commit is contained in:
Ben Gras 2005-11-14 15:58:07 +00:00
parent 1266ebcc93
commit f9c1f3172d
5 changed files with 22 additions and 0 deletions

View file

@ -325,6 +325,7 @@
# define GET_MACHINE 12 /* get machine information */ # define GET_MACHINE 12 /* get machine information */
# define GET_LOCKTIMING 13 /* get lock()/unlock() latency timing */ # define GET_LOCKTIMING 13 /* get lock()/unlock() latency timing */
# define GET_BIOSBUFFER 14 /* get a buffer for BIOS calls */ # 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_PROC_NR m7_i4 /* calling process */
#define I_VAL_PTR m7_p1 /* virtual address at caller */ #define I_VAL_PTR m7_p1 /* virtual address at caller */
#define I_VAL_LEN m7_i1 /* max length of value */ #define I_VAL_LEN m7_i1 /* max length of value */

View file

@ -106,6 +106,7 @@ _PROTOTYPE(int sys_segctl, (int *index, u16_t *seg, vir_bytes *off,
/* Shorthands for sys_getinfo() system call. */ /* Shorthands for sys_getinfo() system call. */
#define sys_getkmessages(dst) sys_getinfo(GET_KMESSAGES, dst, 0,0,0) #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_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_getmachine(dst) sys_getinfo(GET_MACHINE, dst, 0,0,0)
#define sys_getproctab(dst) sys_getinfo(GET_PROCTAB, 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) #define sys_getprivtab(dst) sys_getinfo(GET_PRIVTAB, dst, 0,0,0)

View file

@ -107,6 +107,24 @@ struct kinfo {
int relocking; /* relocking check (for debugging) */ 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 { struct machine {
int pc_at; int pc_at;
int ps_mca; int ps_mca;

View file

@ -71,6 +71,7 @@ _PROTOTYPE( char *initstate, (unsigned _seed, char *_state,
_PROTOTYPE( long random, (void) ); _PROTOTYPE( long random, (void) );
_PROTOTYPE( char *setstate, (const char *state) ); _PROTOTYPE( char *setstate, (const char *state) );
_PROTOTYPE( void srandom, (unsigned seed) ); _PROTOTYPE( void srandom, (unsigned seed) );
_PROTOTYPE( int getloadavg, (double *, int) );
#endif #endif
#ifdef _MINIX #ifdef _MINIX

View file

@ -42,6 +42,7 @@
#define SI_DMAP_TAB 3 /* get device <-> driver mappings */ #define SI_DMAP_TAB 3 /* get device <-> driver mappings */
#define SI_MEM_ALLOC 4 /* get memory allocation data */ #define SI_MEM_ALLOC 4 /* get memory allocation data */
#define SI_DATA_STORE 5 /* get copy of data store */ #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 <unistd.h> according to POSIX Sec. 2.7.1. */ /* NULL must be defined in <unistd.h> according to POSIX Sec. 2.7.1. */
#define NULL ((void *)0) #define NULL ((void *)0)