add working set change chance for processes
This commit is contained in:
parent
819379055d
commit
585c820853
2
Makefile
2
Makefile
|
@ -13,7 +13,7 @@ kernel.o: src/kernel.c config.h
|
|||
mmu.o: src/mmu.c
|
||||
gcc $(CCFLAGS) -c -o mmu.o src/mmu.c
|
||||
|
||||
process.o: src/process.c
|
||||
process.o: src/process.c config.h
|
||||
gcc $(CCFLAGS) -c -o process.o src/process.c
|
||||
|
||||
random.o: src/random.c
|
||||
|
|
2
config.h
2
config.h
|
@ -3,3 +3,5 @@
|
|||
#define WSCLOCK_TIME_WINDOW 1500
|
||||
|
||||
#define VERBOSE_SANITY_CHECK 0
|
||||
|
||||
#define WS_CHANGE_INVERSE_CHANCE 1000
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
#include "mmu.h"
|
||||
#include "random.h"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
struct Process *
|
||||
Process(size_t proc_id, size_t max_accesses, size_t total_pages_owned, size_t ws_size)
|
||||
{
|
||||
|
@ -27,7 +29,8 @@ Process(size_t proc_id, size_t max_accesses, size_t total_pages_owned, size_t ws
|
|||
return p;
|
||||
}
|
||||
|
||||
size_t PROCESS_run_for(struct Process *p, size_t time_bits)
|
||||
size_t
|
||||
PROCESS_run_for(struct Process *p, size_t time_bits)
|
||||
{
|
||||
if (!p) {
|
||||
printf("[process ?] p == NULL, something is very wrong\n");
|
||||
|
@ -49,7 +52,19 @@ size_t PROCESS_run_for(struct Process *p, size_t time_bits)
|
|||
printf("[process %d] Reading from page #%d\n", p->id, accessed_page_no);
|
||||
MMU_read(p->pt, accessed_page_no);
|
||||
}
|
||||
|
||||
if (!randint(WS_CHANGE_INVERSE_CHANCE))
|
||||
PROCESS_change_working_set(p);
|
||||
}
|
||||
|
||||
return p->pages_accessed >= p->max_accesses;
|
||||
}
|
||||
|
||||
void
|
||||
PROCESS_change_working_set(struct Process *p)
|
||||
{
|
||||
printf("[process %d] Changing working set after %d accesses\n", p->id, p->pages_accessed);
|
||||
|
||||
for (size_t i = 0; i < p->ws_size; i++)
|
||||
p->ws[i] = randint(p->total_pages_owned);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue