optinal finished
This commit is contained in:
@ -5,8 +5,9 @@
|
||||
#include "spinlock.h"
|
||||
#include "proc.h"
|
||||
#include "defs.h"
|
||||
#include "sysinfo.h"
|
||||
|
||||
uint64 load_avg = 0;
|
||||
uint64 current_load = 0;
|
||||
|
||||
struct cpu cpus[NCPU];
|
||||
|
||||
@ -453,6 +454,7 @@ scheduler(void)
|
||||
{
|
||||
struct proc *p;
|
||||
struct cpu *c = mycpu();
|
||||
/*update_load_avg();*/
|
||||
|
||||
c->proc = 0;
|
||||
for(;;){
|
||||
@ -469,6 +471,7 @@ scheduler(void)
|
||||
// before jumping back to us.
|
||||
p->state = RUNNING;
|
||||
c->proc = p;
|
||||
current_load += 1;
|
||||
swtch(&c->context, &p->context);
|
||||
|
||||
// Process is done running for now.
|
||||
@ -705,21 +708,6 @@ proc_size()
|
||||
}
|
||||
|
||||
int
|
||||
get_current_load() {
|
||||
struct proc *p;
|
||||
int current_load = 0;
|
||||
|
||||
for (p = proc; p < &proc[NPROC]; p++) {
|
||||
if (p->state == RUNNING || p->state == RUNNABLE) {
|
||||
current_load++;
|
||||
}
|
||||
}
|
||||
|
||||
update_load() {
|
||||
return current_load;
|
||||
}
|
||||
|
||||
void
|
||||
update_load_avg() {
|
||||
int current_load = get_current_load();
|
||||
load_avg = (load_avg * ALPHA) + (current_load * (1 - ALPHA));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user