Mercurial > hg > Members > menikon > CbC_xv6
diff src/impl/vm_impl.cbc @ 211:66db83ec1ec2
kpt_alloc_check_impl and freerange
author | tobaru |
---|---|
date | Thu, 23 Jan 2020 20:48:16 +0900 |
parents | 02bb0f8be908 |
children | 6e03cee9733e |
line wrap: on
line diff
--- a/src/impl/vm_impl.cbc Thu Jan 23 18:08:22 2020 +0900 +++ b/src/impl/vm_impl.cbc Thu Jan 23 20:48:16 2020 +0900 @@ -53,14 +53,35 @@ goto next(...); } -__code kpt_freerangevm_impl(struct vm_impl* vm, uint low, uint hi, __code next(...)) { +extern struct run { + struct run *next; +}; - goto next(...); +static void _kpt_free (char *v) +{ + struct run *r; + + r = (struct run*) v; + r->next = kpt_mem.freelist; + kpt_mem.freelist = r; } -__code kpt_allocvm_impl(struct vm_impl* vm ,__code next(...)) { +__code kpt_freerangevm_impl(struct vm_impl* vm, uint low, uint hi, __code next(...)) { + + if (low < hi) { + _kpt_free((char*)low); + goto kpt_freerangevm_impl(vm, low + PT_SZ, hi, next(...)); + + } + goto next(...); +} +__code kpt_allocvm_impl(struct vm_impl* vm, __code next(...)) { + struct run *r; + acquire(&kpt_mem.lock); - goto next(...); + goto kpt_alloc_check_impl(vm_impl, r, next(...)); + + goto next(...); } typedef struct proc proc;