Open qin-you opened 1 year ago
int countfree() { uint64_t sz0 = (uint64_t)sbrk(0); struct sysinfo info; int n = 0;
while (1) {
if ((uint64_t)sbrk(PGSIZE) == (uint64_t)-1) { /* Check if sbrk returns -1 when there's no more memory */
break;
}
n += PGSIZE;
}
return n;
}
int countfree() { uint64 sz0 = (uint64)sbrk(0); struct sysinfo info; int n = 0;
while(1){ if((uint64)sbrk(PGSIZE) == 0xffffffffffffffff){ / loop forever if there is no more mem originally?/ break; } n += PGSIZE; / undercount one if there is only one page left originally ?/ } }