)
return false;
- // free up as much core as we need to
#ifndef INDIRECT_CORE
+ // free up as much core as we need to
rassert(do_swap_out(blocks - core_table.avail));
-#else /* INDIRECT_CORE */
- rassert(do_swap_out(blocks - core_block_pool.avail));
-#endif /* INDIRECT_CORE */
// allocate core and possible swap
-#ifndef INDIRECT_CORE
rassert(
pool_alloc(
+ &core_table,
+ &process->core_item,
+ blocks,
+ POOL_ALLOC_MODE_MOVEABLE
+ )
+ );
#else /* INDIRECT_CORE */
+ // free up as much core as we need to
+ rassert(do_swap_out(blocks - core_block_pool.avail));
+
+ // allocate core and possible swap
if (
!pool_alloc(
-#endif /* INDIRECT_CORE */
&core_table,
&process->core_item,
blocks,
-#ifndef INDIRECT_CORE
- POOL_ALLOC_MODE_MOVEABLE
-#else /* INDIRECT_CORE */
0
)
) {
return false;
}
- // populate new table with physical blocks
+ // populate physical blocks as needed
rassert(
block_pool_alloc(
&core_block_pool,
core_table_mem + process->core_item.base,
blocks
-#endif /* INDIRECT_CORE */
)
);
+#endif /* INDIRECT_CORE */
// insert at head of LRU list
process->lru_item.prev = &lru_head;
return false;
}
- // free up as much core as we need to
#ifndef INDIRECT_CORE
+ // free up as much core as we need to
rassert(do_swap_out(blocks_change - core_table.avail));
-#else /* INDIRECT_CORE */
- rassert(do_swap_out(blocks_change - core_block_pool.avail));
-#endif /* INDIRECT_CORE */
// reallocate core and possible swap
-#ifndef INDIRECT_CORE
rassert(
pool_alloc(
+ &core_table,
+ &process->core_item,
+ blocks,
+ dir | (POOL_ALLOC_MODE_MOVEABLE | POOL_ALLOC_MODE_REALLOC)
+ )
+ );
#else /* INDIRECT_CORE */
+ // free up as much core as we need to
+ rassert(do_swap_out(blocks_change - core_block_pool.avail));
+
+ // reallocate core and possible swap
if (
!pool_alloc(
-#endif /* INDIRECT_CORE */
&core_table,
&process->core_item,
blocks,
-#ifndef INDIRECT_CORE
- dir | (POOL_ALLOC_MODE_MOVEABLE | POOL_ALLOC_MODE_REALLOC)
-#else /* INDIRECT_CORE */
dir | POOL_ALLOC_MODE_REALLOC
-#endif /* INDIRECT_CORE */
)
-#ifndef INDIRECT_CORE
- );
-#else /* INDIRECT_CORE */
) {
pool_free(&swap_table, &process->swap_item);
rassert(
return false;
}
- // populate new table with physical blocks or discard them
- if (blocks_change >= 0)
+ if (blocks_change < 0)
+ // discard physical blocks as needed
+ block_pool_free(
+ &core_block_pool,
+ core_table_mem + (
+ dir ?
+ process->core_item.base + blocks_change :
+ process->core_item.limit
+ ),
+ -blocks_change
+ );
+ else
+ // populate physical blocks as needed
rassert(
block_pool_alloc(
&core_block_pool,
- core_table_mem + process->core_item.limit - blocks_change,
+ core_table_mem + (
+ dir ?
+ process->core_item.base :
+ process->core_item.limit - blocks_change
+ ),
blocks_change
)
);
- else
- block_pool_free(
- &core_block_pool,
- core_table_mem + process->core_item.limit,
- -blocks_change
- );
#endif /* INDIRECT_CORE */
// track total allocation