update lab1-8 codes and docs. now version is 0.2
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
#include <vmm.h>
|
||||
#include <proc.h>
|
||||
#include <kdebug.h>
|
||||
#include <monitor.h>
|
||||
#include <kmonitor.h>
|
||||
#include <assert.h>
|
||||
|
||||
#define STACKFRAME_DEPTH 20
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <string.h>
|
||||
#include <mmu.h>
|
||||
#include <trap.h>
|
||||
#include <monitor.h>
|
||||
#include <kmonitor.h>
|
||||
#include <kdebug.h>
|
||||
|
||||
/* *
|
||||
@@ -82,7 +82,7 @@ runcmd(char *buf, struct trapframe *tf) {
|
||||
/***** Implementations of basic kernel monitor commands *****/
|
||||
|
||||
void
|
||||
monitor(struct trapframe *tf) {
|
||||
kmonitor(struct trapframe *tf) {
|
||||
cprintf("Welcome to the kernel debug monitor!!\n");
|
||||
cprintf("Type 'help' for a list of commands.\n");
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include <trap.h>
|
||||
|
||||
void monitor(struct trapframe *tf);
|
||||
void kmonitor(struct trapframe *tf);
|
||||
|
||||
int mon_help(int argc, char **argv, struct trapframe *tf);
|
||||
int mon_kerninfo(int argc, char **argv, struct trapframe *tf);
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <defs.h>
|
||||
#include <stdio.h>
|
||||
#include <intr.h>
|
||||
#include <monitor.h>
|
||||
#include <kmonitor.h>
|
||||
|
||||
static bool is_panic = 0;
|
||||
|
||||
@@ -27,7 +27,7 @@ __panic(const char *file, int line, const char *fmt, ...) {
|
||||
panic_dead:
|
||||
intr_disable();
|
||||
while (1) {
|
||||
monitor(NULL);
|
||||
kmonitor(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,9 +12,10 @@
|
||||
#include <ide.h>
|
||||
#include <swap.h>
|
||||
#include <proc.h>
|
||||
#include <kmonitor.h>
|
||||
|
||||
int kern_init(void) __attribute__((noreturn));
|
||||
|
||||
void grade_backtrace(void);
|
||||
static void lab1_switch_test(void);
|
||||
|
||||
int
|
||||
|
||||
@@ -487,7 +487,7 @@ check_slab(void) {
|
||||
void *v0, *v1;
|
||||
|
||||
size_t nr_free_pages_store = nr_free_pages();
|
||||
size_t slab_allocated_store = slab_allocated();
|
||||
size_t kernel_allocated_store = slab_allocated();
|
||||
|
||||
/* slab must be empty now */
|
||||
check_slab_empty();
|
||||
@@ -633,7 +633,7 @@ check_pass:
|
||||
check_slab_empty();
|
||||
assert(slab_allocated() == 0);
|
||||
assert(nr_free_pages_store == nr_free_pages());
|
||||
assert(slab_allocated_store == slab_allocated());
|
||||
assert(kernel_allocated_store == slab_allocated());
|
||||
|
||||
cprintf("check_slab() succeeded!\n");
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@ check_swap(void)
|
||||
list_entry_t *le = &free_list;
|
||||
while ((le = list_next(le)) != &free_list) {
|
||||
struct Page *p = le2page(le, page_link);
|
||||
//assert(PageProperty(p));
|
||||
assert(PageProperty(p));
|
||||
count ++, total += p->property;
|
||||
}
|
||||
assert(total == nr_free_pages());
|
||||
@@ -277,7 +277,7 @@ check_swap(void)
|
||||
struct Page *p = le2page(le, page_link);
|
||||
count --, total -= p->property;
|
||||
}
|
||||
cprintf("count is %d, total is %d\n",count,total);
|
||||
cprintf("count is %d, total is %d\n",count,total);
|
||||
//assert(count == 0);
|
||||
|
||||
cprintf("check_swap() succeeded!\n");
|
||||
|
||||
@@ -460,6 +460,15 @@ do_pgfault(struct mm_struct *mm, uint32_t error_code, uintptr_t addr) {
|
||||
* page_insert : build the map of phy addr of an Page with the linear addr la
|
||||
* swap_map_swappable : set the page swappable
|
||||
*/
|
||||
/*
|
||||
* LAB5 CHALLENGE ( the implmentation Copy on Write)
|
||||
There are 2 situlations when code comes here.
|
||||
1) *ptep & PTE_P == 1, it means one process try to write a readonly page.
|
||||
If the vma includes this addr is writable, then we can set the page writable by rewrite the *ptep.
|
||||
This method could be used to implement the Copy on Write (COW) thchnology(a fast fork process method).
|
||||
2) *ptep & PTE_P == 0 & but *ptep!=0, it means this pte is a swap entry.
|
||||
We should add the LAB3's results here.
|
||||
*/
|
||||
if(swap_init_ok) {
|
||||
struct Page *page=NULL;
|
||||
//(1)According to the mm AND addr, try to load the content of right disk page
|
||||
|
||||
@@ -103,6 +103,12 @@ alloc_proc(void) {
|
||||
* uint32_t flags; // Process flag
|
||||
* char name[PROC_NAME_LEN + 1]; // Process name
|
||||
*/
|
||||
//LAB5 YOUR CODE : (update LAB4 steps)
|
||||
/*
|
||||
* below fields(add in LAB5) in proc_struct need to be initialized
|
||||
* uint32_t wait_state; // waiting state
|
||||
* struct proc_struct *cptr, *yptr, *optr; // relations between processes
|
||||
*/
|
||||
}
|
||||
return proc;
|
||||
}
|
||||
@@ -389,6 +395,15 @@ do_fork(uint32_t clone_flags, uintptr_t stack, struct trapframe *tf) {
|
||||
// 5. insert proc_struct into hash_list && proc_list
|
||||
// 6. call wakup_proc to make the new child process RUNNABLE
|
||||
// 7. set ret vaule using child proc's pid
|
||||
|
||||
//LAB5 YOUR CODE : (update LAB4 steps)
|
||||
/* Some Functions
|
||||
* set_links: set the relation links of process. ALSO SEE: remove_links: lean the relation links of process
|
||||
* -------------------
|
||||
* update step 1: set child proc's parent to current process, make sure current process's wait_state is 0
|
||||
* update step 5: insert proc_struct into hash_list && proc_list, set the relation links of process
|
||||
*/
|
||||
|
||||
fork_out:
|
||||
return ret;
|
||||
|
||||
@@ -771,7 +786,7 @@ user_main(void *arg) {
|
||||
static int
|
||||
init_main(void *arg) {
|
||||
size_t nr_free_pages_store = nr_free_pages();
|
||||
size_t slab_allocated_store = kallocated();
|
||||
size_t kernel_allocated_store = kallocated();
|
||||
|
||||
int pid = kernel_thread(user_main, NULL, 0);
|
||||
if (pid <= 0) {
|
||||
@@ -788,7 +803,7 @@ init_main(void *arg) {
|
||||
assert(list_next(&proc_list) == &(initproc->list_link));
|
||||
assert(list_prev(&proc_list) == &(initproc->list_link));
|
||||
assert(nr_free_pages_store == nr_free_pages());
|
||||
assert(slab_allocated_store == kallocated());
|
||||
assert(kernel_allocated_store == kallocated());
|
||||
cprintf("init check memory pass.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ trap_dispatch(struct trapframe *tf) {
|
||||
break;
|
||||
case IRQ_OFFSET + IRQ_TIMER:
|
||||
#if 0
|
||||
LAB3 : If some page replacement algorithm need tick to change the priority of pages,
|
||||
LAB3 : If some page replacement algorithm(such as CLOCK PRA) need tick to change the priority of pages,
|
||||
then you can add code here.
|
||||
#endif
|
||||
/* LAB1 YOUR CODE : STEP 3 */
|
||||
|
||||
@@ -512,6 +512,45 @@ run_test -prog 'forktest' -check default_check
|
||||
! 'wait got too many' \
|
||||
! - 'user panic at .*'
|
||||
|
||||
pts=10
|
||||
run_test -prog 'forktree' -check default_check \
|
||||
'kernel_execve: pid = 2, name = "forktree".' \
|
||||
- '....: I am '\'''\' \
|
||||
- '....: I am '\''0'\' \
|
||||
- '....: I am '\'''\' \
|
||||
- '....: I am '\''1'\' \
|
||||
- '....: I am '\''0'\' \
|
||||
- '....: I am '\''01'\' \
|
||||
- '....: I am '\''00'\' \
|
||||
- '....: I am '\''11'\' \
|
||||
- '....: I am '\''10'\' \
|
||||
- '....: I am '\''101'\' \
|
||||
- '....: I am '\''100'\' \
|
||||
- '....: I am '\''111'\' \
|
||||
- '....: I am '\''110'\' \
|
||||
- '....: I am '\''001'\' \
|
||||
- '....: I am '\''000'\' \
|
||||
- '....: I am '\''011'\' \
|
||||
- '....: I am '\''010'\' \
|
||||
- '....: I am '\''0101'\' \
|
||||
- '....: I am '\''0100'\' \
|
||||
- '....: I am '\''0111'\' \
|
||||
- '....: I am '\''0110'\' \
|
||||
- '....: I am '\''0001'\' \
|
||||
- '....: I am '\''0000'\' \
|
||||
- '....: I am '\''0011'\' \
|
||||
- '....: I am '\''0010'\' \
|
||||
- '....: I am '\''1101'\' \
|
||||
- '....: I am '\''1100'\' \
|
||||
- '....: I am '\''1111'\' \
|
||||
- '....: I am '\''1110'\' \
|
||||
- '....: I am '\''1001'\' \
|
||||
- '....: I am '\''1000'\' \
|
||||
- '....: I am '\''1011'\' \
|
||||
- '....: I am '\''1010'\' \
|
||||
'all user-mode processes have quit.' \
|
||||
'init check memory pass.'
|
||||
|
||||
## print final-score
|
||||
show_final
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#define DEPTH 2
|
||||
#define DEPTH 4
|
||||
|
||||
void forktree(const char *cur);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user