Fix unoptimized loop when rounding to page size in sys_sbrk (#145)

This commit is contained in:
Ofek 2017-02-06 07:23:51 +02:00 committed by Kevin Lange
parent 38eb6a7e72
commit 353ae32697

View File

@ -176,9 +176,7 @@ static int sys_sbrk(int size) {
spin_lock(proc->image.lock);
uintptr_t ret = proc->image.heap;
uintptr_t i_ret = ret;
while (ret % 0x1000) {
ret++;
}
ret = (ret + 0xfff) & ~0xfff; /* Rounds ret to 0x1000 in O(1) */
proc->image.heap += (ret - i_ret) + size;
while (proc->image.heap > proc->image.heap_actual) {
proc->image.heap_actual += 0x1000;