. load average calculation changed to calculate it all over every tick
instead of keeping a running total of enqueued processes (because somehow the load average was broken) . added SI_KPROC_TAB to get a copy of kernel process table from PM, for a top implementation . fixed arg to sys_nice() to make it an endpoint, not a slot number
This commit is contained in:
parent
e61522402a
commit
eae250dea4
|
@ -121,7 +121,6 @@ struct kinfo {
|
||||||
|
|
||||||
/* Runnable processes and other load-average information. */
|
/* Runnable processes and other load-average information. */
|
||||||
struct loadinfo {
|
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_load_history[_LOAD_HISTORY]; /* history of proc_s_cur */
|
||||||
u16_t proc_last_slot;
|
u16_t proc_last_slot;
|
||||||
clock_t last_clock;
|
clock_t last_clock;
|
||||||
|
|
|
@ -46,6 +46,7 @@
|
||||||
#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 */
|
#define SI_LOADINFO 6 /* get copy of load average structure */
|
||||||
|
#define SI_KPROC_TAB 7 /* copy of kernel process table */
|
||||||
|
|
||||||
/* 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)
|
||||||
|
|
|
@ -288,6 +288,8 @@ PUBLIC unsigned long read_clock()
|
||||||
PRIVATE void load_update(void)
|
PRIVATE void load_update(void)
|
||||||
{
|
{
|
||||||
u16_t slot;
|
u16_t slot;
|
||||||
|
int enqueued = -1, q; /* -1: special compensation for IDLE. */
|
||||||
|
struct proc *p;
|
||||||
|
|
||||||
/* Load average data is stored as a list of numbers in a circular
|
/* Load average data is stored as a list of numbers in a circular
|
||||||
* buffer. Each slot accumulates _LOAD_UNIT_SECS of samples of
|
* buffer. Each slot accumulates _LOAD_UNIT_SECS of samples of
|
||||||
|
@ -301,8 +303,12 @@ PRIVATE void load_update(void)
|
||||||
kloadinfo.proc_last_slot = slot;
|
kloadinfo.proc_last_slot = slot;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Cumulation. */
|
/* Cumulation. How many processes are ready now? */
|
||||||
kloadinfo.proc_load_history[slot] += kloadinfo.procs_enqueued;
|
for(q = 0; q < NR_SCHED_QUEUES; q++)
|
||||||
|
for(p = rdy_head[q]; p != NIL_PROC; p = p->p_nextready)
|
||||||
|
enqueued++;
|
||||||
|
|
||||||
|
kloadinfo.proc_load_history[slot] += enqueued;
|
||||||
|
|
||||||
/* Up-to-dateness. */
|
/* Up-to-dateness. */
|
||||||
kloadinfo.last_clock = realtime;
|
kloadinfo.last_clock = realtime;
|
||||||
|
|
|
@ -145,9 +145,6 @@ PUBLIC void main()
|
||||||
alloc_segments(rp);
|
alloc_segments(rp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Special compensation for IDLE - don't let it count in the load average. */
|
|
||||||
kloadinfo.procs_enqueued--;
|
|
||||||
|
|
||||||
#if ENABLE_BOOTDEV
|
#if ENABLE_BOOTDEV
|
||||||
/* Expect an image of the boot device to be loaded into memory as well.
|
/* Expect an image of the boot device to be loaded into memory as well.
|
||||||
* The boot device is the last module that is loaded into memory, and,
|
* The boot device is the last module that is loaded into memory, and,
|
||||||
|
|
|
@ -536,8 +536,6 @@ register struct proc *rp; /* this process is now runnable */
|
||||||
/* Now select the next process to run. */
|
/* Now select the next process to run. */
|
||||||
pick_proc();
|
pick_proc();
|
||||||
|
|
||||||
kloadinfo.procs_enqueued++;
|
|
||||||
|
|
||||||
#if DEBUG_SCHED_CHECK
|
#if DEBUG_SCHED_CHECK
|
||||||
rp->p_ready = 1;
|
rp->p_ready = 1;
|
||||||
check_runqueues("enqueue");
|
check_runqueues("enqueue");
|
||||||
|
@ -587,13 +585,9 @@ register struct proc *rp; /* this process is no longer runnable */
|
||||||
prev_xp = *xpp; /* save previous in chain */
|
prev_xp = *xpp; /* save previous in chain */
|
||||||
}
|
}
|
||||||
|
|
||||||
kloadinfo.procs_enqueued--;
|
|
||||||
|
|
||||||
#if DEBUG_SCHED_CHECK
|
#if DEBUG_SCHED_CHECK
|
||||||
rp->p_ready = 0;
|
rp->p_ready = 0;
|
||||||
check_runqueues("dequeue");
|
check_runqueues("dequeue");
|
||||||
if(kloadinfo.procs_enqueued < 0)
|
|
||||||
kprintf("%d processes enqueued\n", kloadinfo.procs_enqueued);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,6 @@ U16_t parmoff, parmsize; /* boot parameters offset and length */
|
||||||
kinfo.kmem_size = (phys_bytes) &end;
|
kinfo.kmem_size = (phys_bytes) &end;
|
||||||
|
|
||||||
/* Load average data initialization. */
|
/* Load average data initialization. */
|
||||||
kloadinfo.procs_enqueued = 0;
|
|
||||||
kloadinfo.proc_last_slot = 0;
|
kloadinfo.proc_last_slot = 0;
|
||||||
for(h = 0; h < _LOAD_HISTORY; h++)
|
for(h = 0; h < _LOAD_HISTORY; h++)
|
||||||
kloadinfo.proc_load_history[h] = 0;
|
kloadinfo.proc_load_history[h] = 0;
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include <lib.h>
|
#include <lib.h>
|
||||||
#include "mproc.h"
|
#include "mproc.h"
|
||||||
#include "param.h"
|
#include "param.h"
|
||||||
|
#include "../../kernel/proc.h"
|
||||||
|
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* do_allocmem *
|
* do_allocmem *
|
||||||
|
@ -83,6 +84,7 @@ PUBLIC int do_getsysinfo()
|
||||||
vir_bytes src_addr, dst_addr;
|
vir_bytes src_addr, dst_addr;
|
||||||
struct kinfo kinfo;
|
struct kinfo kinfo;
|
||||||
struct loadinfo loadinfo;
|
struct loadinfo loadinfo;
|
||||||
|
static struct proc proctab[NR_PROCS+NR_TASKS];
|
||||||
size_t len;
|
size_t len;
|
||||||
static struct pm_mem_info pmi;
|
static struct pm_mem_info pmi;
|
||||||
int s, r;
|
int s, r;
|
||||||
|
@ -103,6 +105,12 @@ PUBLIC int do_getsysinfo()
|
||||||
src_addr = (vir_bytes) mproc;
|
src_addr = (vir_bytes) mproc;
|
||||||
len = sizeof(struct mproc) * NR_PROCS;
|
len = sizeof(struct mproc) * NR_PROCS;
|
||||||
break;
|
break;
|
||||||
|
case SI_KPROC_TAB: /* copy entire process table */
|
||||||
|
if((r=sys_getproctab(proctab)) != OK)
|
||||||
|
return r;
|
||||||
|
src_addr = (vir_bytes) proctab;
|
||||||
|
len = sizeof(proctab);
|
||||||
|
break;
|
||||||
case SI_MEM_ALLOC:
|
case SI_MEM_ALLOC:
|
||||||
holesize = sizeof(pmi.pmi_holes);
|
holesize = sizeof(pmi.pmi_holes);
|
||||||
if((r=mem_holes_copy(pmi.pmi_holes, &holesize,
|
if((r=mem_holes_copy(pmi.pmi_holes, &holesize,
|
||||||
|
@ -252,7 +260,7 @@ PUBLIC int do_getsetpriority()
|
||||||
|
|
||||||
/* We're SET, and it's allowed. Do it and tell kernel. */
|
/* We're SET, and it's allowed. Do it and tell kernel. */
|
||||||
rmp->mp_nice = arg_pri;
|
rmp->mp_nice = arg_pri;
|
||||||
return sys_nice(rmp_nr, arg_pri);
|
return sys_nice(rmp->mp_endpoint, arg_pri);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
|
|
Loading…
Reference in a new issue