Makefile:: add tags options; vmm.[ch] fix bug in find_vma Function, and update check_vma_struct Funciton from lab3-lab8
This commit is contained in:
@@ -84,7 +84,7 @@ find_vma(struct mm_struct *mm, uintptr_t addr) {
|
||||
list_entry_t *list = &(mm->mmap_list), *le = list;
|
||||
while ((le = list_next(le)) != list) {
|
||||
vma = le2vma(le, list_link);
|
||||
if (addr < vma->vm_end) {
|
||||
if (vma->vm_start<=addr && addr < vma->vm_end) {
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
@@ -270,7 +270,7 @@ check_vma_struct(void) {
|
||||
int step1 = 10, step2 = step1 * 10;
|
||||
|
||||
int i;
|
||||
for (i = step1; i >= 0; i --) {
|
||||
for (i = step1; i >= 1; i --) {
|
||||
struct vma_struct *vma = vma_create(i * 5, i * 5 + 2, 0);
|
||||
assert(vma != NULL);
|
||||
insert_vma_struct(mm, vma);
|
||||
@@ -284,21 +284,35 @@ check_vma_struct(void) {
|
||||
|
||||
list_entry_t *le = list_next(&(mm->mmap_list));
|
||||
|
||||
for (i = 0; i <= step2; i ++) {
|
||||
for (i = 1; i <= step2; i ++) {
|
||||
assert(le != &(mm->mmap_list));
|
||||
struct vma_struct *mmap = le2vma(le, list_link);
|
||||
assert(mmap->vm_start == i * 5 && mmap->vm_end == i * 5 + 2);
|
||||
le = list_next(le);
|
||||
}
|
||||
|
||||
for (i = 0; i < 5 * step2 + 2; i ++) {
|
||||
struct vma_struct *vma = find_vma(mm, i);
|
||||
assert(vma != NULL);
|
||||
int j = i / 5;
|
||||
if (i >= 5 * j + 2) {
|
||||
j ++;
|
||||
for (i = 5; i <= 5 * step2; i +=5) {
|
||||
struct vma_struct *vma1 = find_vma(mm, i);
|
||||
assert(vma1 != NULL);
|
||||
struct vma_struct *vma2 = find_vma(mm, i+1);
|
||||
assert(vma2 != NULL);
|
||||
struct vma_struct *vma3 = find_vma(mm, i+2);
|
||||
assert(vma3 == NULL);
|
||||
struct vma_struct *vma4 = find_vma(mm, i+3);
|
||||
assert(vma4 == NULL);
|
||||
struct vma_struct *vma5 = find_vma(mm, i+4);
|
||||
assert(vma5 == NULL);
|
||||
|
||||
assert(vma1->vm_start == i && vma1->vm_end == i + 2);
|
||||
assert(vma2->vm_start == i && vma2->vm_end == i + 2);
|
||||
}
|
||||
|
||||
for (i =4; i>=0; i--) {
|
||||
struct vma_struct *vma_below_5= find_vma(mm,i);
|
||||
if (vma_below_5 != NULL ) {
|
||||
cprintf("vma_below_5: i %x, start %x, end %x\n",i, vma_below_5->vm_start, vma_below_5->vm_end);
|
||||
}
|
||||
assert(vma->vm_start == j * 5 && vma->vm_end == j * 5 + 2);
|
||||
assert(vma_below_5 == NULL);
|
||||
}
|
||||
|
||||
mm_destroy(mm);
|
||||
|
||||
@@ -11,11 +11,12 @@
|
||||
//pre define
|
||||
struct mm_struct;
|
||||
|
||||
// the virtual continuous memory area(vma)
|
||||
// the virtual continuous memory area(vma), [vm_start, vm_end),
|
||||
// addr belong to a vma means vma.vm_start<= addr <vma.vm_end
|
||||
struct vma_struct {
|
||||
struct mm_struct *vm_mm; // the set of vma using the same PDT
|
||||
uintptr_t vm_start; // start addr of vma
|
||||
uintptr_t vm_end; // end addr of vma
|
||||
uintptr_t vm_start; // start addr of vma
|
||||
uintptr_t vm_end; // end addr of vma, not include the vm_end itself
|
||||
uint32_t vm_flags; // flags of vma
|
||||
list_entry_t list_link; // linear list link which sorted by start addr of vma
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user