[dirty:segfault] stage 1
This commit is contained in:
34
inc/kernel.h
Normal file
34
inc/kernel.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#ifndef KERNEL_HEADER
|
||||
#define KERNEL_HEADER
|
||||
|
||||
#include "process.h"
|
||||
|
||||
struct RunQ {
|
||||
struct Process *current_proc;
|
||||
size_t max_procs;
|
||||
size_t proc_amount;
|
||||
size_t next_proc_id;
|
||||
};
|
||||
|
||||
struct RunQ *RunQ(size_t max_procs);
|
||||
void RUNQ_add_process(size_t max_page_accesses, size_t total_pages_owned);
|
||||
|
||||
static struct RunQ *runq;
|
||||
|
||||
|
||||
struct PhysPage {
|
||||
size_t ppn;
|
||||
size_t busy_flag;
|
||||
struct PhysPage *prev;
|
||||
struct PhysPage *next;
|
||||
struct PageTable *pt;
|
||||
size_t pt_index;
|
||||
};
|
||||
|
||||
static struct PhysPage *first_free_page;
|
||||
static struct PhysPage *first_busy_page;
|
||||
|
||||
|
||||
void KERNEL_page_fault(struct PageTableEntry *pt, size_t page_no);
|
||||
|
||||
#endif
|
||||
2
inc/mmu.h
Normal file
2
inc/mmu.h
Normal file
@@ -0,0 +1,2 @@
|
||||
void MMU_read(struct PageTableEntry *pt, size_t page_no);
|
||||
void MMU_write(struct PageTableEntry *pt, size_t page_no);
|
||||
0
inc/page_table.h
Normal file
0
inc/page_table.h
Normal file
29
inc/process.h
Normal file
29
inc/process.h
Normal file
@@ -0,0 +1,29 @@
|
||||
#ifndef PROCESS_HEADER
|
||||
#define PROCESS_HEADER
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
struct PageTableEntry {
|
||||
size_t p:1;
|
||||
size_t r:1;
|
||||
size_t m:1;
|
||||
size_t ppn;
|
||||
};
|
||||
|
||||
struct Process {
|
||||
struct Process *prev;
|
||||
struct Process *next;
|
||||
size_t id;
|
||||
size_t pages_accessed;
|
||||
size_t max_accesses;
|
||||
size_t total_pages_owned;
|
||||
struct PageTableEntry *pt;
|
||||
};
|
||||
|
||||
struct Process *Process(size_t proc_id,
|
||||
size_t max_accesses,
|
||||
size_t total_pages_owned);
|
||||
|
||||
size_t PROCESS_run_for(struct Process *p, size_t time_bits);
|
||||
|
||||
#endif
|
||||
6
inc/random.h
Normal file
6
inc/random.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#ifndef RANDOM_HEADER
|
||||
#define RANDOM_HEADER
|
||||
|
||||
size_t randint(size_t max);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user