- return extendPages(n);
- }
-
- /**
- * Extend Pool by n pages.
- * Returns OPFAIL on failure.
- */
- size_t extendPages(size_t n)
- {
- //debug(PRINTF) printf("Pool::extendPages(n = %d)\n", n);
- if (ncommitted + n <= npages)
- {
- size_t tocommit;
-
- tocommit = (n + (COMMITSIZE/PAGESIZE) - 1) & ~(COMMITSIZE/PAGESIZE - 1);
- if (ncommitted + tocommit > npages)
- tocommit = npages - ncommitted;
- //debug(PRINTF) printf("\tlooking to commit %d more pages\n", tocommit);
- //fflush(stdout);
- if (os_mem_commit(baseAddr, ncommitted * PAGESIZE, tocommit * PAGESIZE) == 0)
- {
- cstring.memset(pagetable + ncommitted, B_FREE, tocommit);
- auto i = ncommitted;
- ncommitted += tocommit;
-
- while (i && pagetable[i - 1] == B_FREE)
- i--;
-
- return i;
- }
- //debug(PRINTF) printf("\tfailed to commit %d pages\n", tocommit);
- }
-