process_test_gen.o: process_test_gen.c
-process_test_run: process_test_run.o process.o core.o fuzix_fs_or_swap.o pool.o
+process_test_run: process_test_run.o process.o core.o fuzix_fs_or_swap.o block_pool.o pool.o
${CC} ${CFLAGS} -o $@ $^
process_test_run.o: process_test_run.c process.h core.h swap.h pool.h fuzix_fs.h util.h
process.o: process.c process.h core.h swap.h pool.h fuzix_fs.h
core.o: core.c core.h pool.h
fuzix_fs_or_swap.o: fuzix_fs_or_swap.c fuzix_fs.c swap.h core.h pool.h fuzix_fs.h
+block_pool.o: block_pool.c block_pool.h
ucp.o: ucp.c fuzix_fs.h
fuzix_fs.o: fuzix_fs.c fuzix_fs.h
--- /dev/null
+#include <stdlib.h>
+#include <string.h>
+#include "block_pool.h"
+#include "rassert.h"
+
+static uint8_t masks[8] = {0xff, 0xfe, 0xfc, 0xf8, 0xf0, 0xe0, 0xc0, 0x80};
+static uint8_t bits[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
+
+void block_pool_init(struct block_pool *block_pool, int n_blocks) {
+ block_pool->n_blocks = n_blocks;
+ block_pool->n_bitmap = (n_blocks + 7) >> 3;
+ block_pool->bitmap = malloc(block_pool->n_bitmap);
+ rassert(block_pool->bitmap);
+ memset(block_pool->bitmap, 0xff, block_pool->n_bitmap);
+ if (n_blocks & 7)
+ block_pool->bitmap[n_blocks >> 3] =
+ ~masks[n_blocks & 7];
+ block_pool->next = 0;
+ block_pool->avail = n_blocks;
+}
+
+bool block_pool_alloc(struct block_pool *block_pool, int *table, int size) {
+ int i, j, k;
+ uint8_t c;
+
+ if (block_pool->avail < size)
+ return false;
+
+ for (i = 0; i < size; ++i) {
+ j = block_pool->next >> 3;
+ c = block_pool->bitmap[j] & masks[block_pool->next & 7];
+ goto loop_entry;
+ for (; j < block_pool->n_bitmap; ++j) {
+ c = block_pool->bitmap[j];
+ loop_entry:
+ if (c) goto found;
+ }
+#if 1
+ for (j = 0; ; ++j) {
+ assert(j <= block_pool->next >> 3);
+ c = block_pool->bitmap[j];
+ if (c) goto found;
+ }
+#else
+ k = (block_pool->next >> 3) + 1;
+ for (j = 0; j < k; ++j) {
+ c = block_pool->bitmap[j];
+ if (c) goto found;
+ }
+ core_block_free(table, i);
+ return false;
+#endif
+
+ found:
+ for (k = 0; (c & 1) == 0; ++k)
+ c >>= 1;
+ block_pool->bitmap[j] &= ~bits[k];
+ block_pool->next = (j << 3) | k;
+
+#ifndef NDEBUG // makes us remove the following line in gen.sh as appropriate
+ assert(table[i] == 0x55555555);
+#endif
+ table[i] = block_pool->next++;
+ if (block_pool->next >= block_pool->n_blocks)
+ block_pool->next = 0;
+ }
+
+ block_pool->avail -= size;
+ return true;
+}
+
+void block_pool_free(struct block_pool *block_pool, int *table, int size) {
+ int i, j, k;
+
+ for (i = 0; i < size; ++i) {
+ j = table[i];
+ assert(j >= 0 && j < block_pool->n_blocks);
+ k = j & 7;
+ j >>= 3;
+ assert((block_pool->bitmap[j] & bits[k]) == 0);
+ block_pool->bitmap[j] |= bits[k];
+#ifndef NDEBUG
+ table[i] = 0x55555555;
+#endif
+ }
+
+ block_pool->avail += size;
+}
--- /dev/null
+#ifndef _BLOCK_POOL_H
+#define _BLOCK_POOL_H 1
+
+#include <stdbool.h>
+#include <stdint.h>
+
+struct block_pool {
+ int n_blocks;
+ int n_bitmap;
+ uint8_t *bitmap;
+ int next;
+ int avail;
+};
+
+void block_pool_init(struct block_pool *block_pool, int n_blocks);
+bool block_pool_alloc(struct block_pool *block_pool, int *blocks, int size);
+void block_pool_free(struct block_pool *block_pool, int *blocks, int size);
+
+#endif
struct pool_head core_table;
#ifdef INDIRECT_CORE
int *core_table_mem;
-
-static uint8_t masks[8] = {0xff, 0xfe, 0xfc, 0xf8, 0xf0, 0xe0, 0xc0, 0x80};
-static uint8_t bits[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
-
-int n_core_blocks;
-int n_core_block_bitmap;
-uint8_t *core_block_bitmap;
-int core_block_next;
-int core_block_avail;
+struct block_pool core_block_pool;
#endif
#ifdef PREALLOCATE_CORE
rassert(core_table_mem);
memset(core_table_mem, 0x55, table_size * sizeof(int));
- n_core_blocks = n_blocks;
- n_core_block_bitmap = (n_core_blocks + 7) >> 3;
- core_block_bitmap = malloc(n_core_block_bitmap);
- rassert(core_block_bitmap);
- memset(core_block_bitmap, 0xff, n_core_block_bitmap);
- if (n_core_blocks & 7)
- core_block_bitmap[n_core_blocks >> 3] = ~masks[n_core_blocks & 7];
- core_block_next = 0;
- core_block_avail = n_core_blocks;
-#endif
-}
-
-#ifdef INDIRECT_CORE
-bool core_block_alloc(int *table, int size) {
- int i, j, k;
- uint8_t c;
-
- if (core_block_avail < size)
- return false;
-
- for (i = 0; i < size; ++i) {
- j = core_block_next >> 3;
- c = core_block_bitmap[j] & masks[core_block_next & 7];
- goto loop_entry;
- for (; j < n_core_block_bitmap; ++j) {
- c = core_block_bitmap[j];
- loop_entry:
- if (c) goto found;
- }
-#if 1
- for (j = 0; ; ++j) {
- assert(j <= core_block_next >> 3);
- c = core_block_bitmap[j];
- if (c) goto found;
- }
-#else
- k = (core_block_next >> 3) + 1;
- for (j = 0; j < k; ++j) {
- c = core_block_bitmap[j];
- if (c) goto found;
- }
- core_block_free(table, i);
- return false;
-#endif
-
- found:
- for (k = 0; (c & 1) == 0; ++k)
- c >>= 1;
- core_block_bitmap[j] &= ~bits[k];
- core_block_next = (j << 3) | k;
-
-#ifndef NDEBUG // makes us remove the following line in gen.sh as appropriate
- assert(table[i] == 0x55555555);
+ block_pool_init(&core_block_pool, n_blocks);
#endif
- table[i] = core_block_next++;
- if (core_block_next >= n_core_blocks)
- core_block_next = 0;
- }
-
- core_block_avail -= size;
- return true;
}
-
-void core_block_free(int *table, int size) {
- int i, j, k;
-
- for (i = 0; i < size; ++i) {
- j = table[i];
- assert(j >= 0 && j < n_core_blocks);
- k = j & 7;
- j >>= 3;
- assert((core_block_bitmap[j] & bits[k]) == 0);
- core_block_bitmap[j] |= bits[k];
-#ifndef NDEBUG
- table[i] = 0x55555555;
-#endif
- }
-
- core_block_avail += size;
-}
-#endif
#ifndef _CORE_H
#define _CORE_H 1
-#include <stdint.h>
-#include "pool.h"
-
//#define PREALLOCATE_CORE 1
//#define INDIRECT_CORE 1
#define MOVEABLE_CORE 1
+#include <stdint.h>
#ifdef INDIRECT_CORE
-#define CORE_AVAIL core_block_avail
+#include "block_pool.h"
+#endif
+#include "pool.h"
+
+#ifdef INDIRECT_CORE
+#define CORE_AVAIL core_block_pool.avail
#else
#define CORE_AVAIL core_table.avail
#endif
extern struct pool_head core_table;
#ifdef INDIRECT_CORE
extern int *core_table_mem;
-
-extern int n_core_blocks;
-int n_core_block_bitmap;
-extern uint8_t *core_block_bitmap;
-extern int core_block_next;
-extern int core_block_avail;
+extern struct block_pool core_block_pool;
#endif
#ifdef PREALLOCATE_CORE
#ifdef INDIRECT_CORE
void core_init(int n_table, int n_blocks);
-bool core_block_alloc(int *blocks, int size);
-void core_block_free(int *blocks, int size);
#else
void core_init(int n_table);
sed -e 's/^#define INODE_SWAP 1/\/\/#define INODE_SWAP 1/' -i process.h
sed -e 's/^#define INDIRECT_SWAP 1/\/\/#define INDIRECT_SWAP 1/' -i swap.h
./pp.sh moveable_core_preallocate_swap $1
+rm moveable_core_preallocate_swap/block_pool.[ch]
cp rassert.h moveable_core_preallocate_swap
sed -e 's/^\/\/#define INDIRECT_SWAP 1/#define INDIRECT_SWAP 1/' -i swap.h
sed -e 's/^\/\/#define INODE_SWAP 1/#define INODE_SWAP 1/' -i process.h
./pp.sh moveable_core_inode_swap $1
-rm moveable_core_inode_swap/swap.[ch]
+rm moveable_core_inode_swap/block_pool.[ch] moveable_core_inode_swap/swap.[ch]
cp rassert.h fuzix_fs.[ch] util.[ch] moveable_core_inode_swap
CFLAGS=-g -Wall
-process_test_run: process_test_run.o process.o core.o swap.o pool.o
+process_test_run: process_test_run.o process.o core.o swap.o block_pool.o pool.o
${CC} ${CFLAGS} -o $@ $^
process_test_run.o: process_test_run.c process.h core.h swap.h pool.h
process.o: process.c process.h core.h swap.h pool.h
core.o: core.c core.h pool.h
swap.o: swap.c swap.h pool.h
+block_pool.o: block_pool.c block_pool.h
+pool.o: pool.c pool.h
clean:
rm -f *.o process_test_run
CFLAGS=-g -Wall
-process_test_run: process_test_run.o process.o core.o fuzix_fs.o util.o pool.o
+process_test_run: process_test_run.o process.o core.o fuzix_fs.o util.o block_pool.o pool.o
${CC} ${CFLAGS} -o $@ $^
process_test_run.o: process_test_run.c process.h core.h fuzix_fs.h util.h pool.h
process.o: process.c process.h core.h fuzix_fs.h util.h pool.h
core.o: core.c core.h pool.h
fuzix_fs.o: fuzix_fs.c fuzix_fs.h
+block_pool.o: block_pool.c block_pool.h
+pool.o: pool.c pool.h
clean:
rm -f *.o process_test_run
CFLAGS=-g -Wall
-process_test_run: process_test_run.o process.o core.o swap.o pool.o
+process_test_run: process_test_run.o process.o core.o swap.o block_pool.o pool.o
${CC} ${CFLAGS} -o $@ $^
process_test_run.o: process_test_run.c process.h core.h swap.h pool.h
process.o: process.c process.h core.h swap.h pool.h
core.o: core.c core.h pool.h
swap.o: swap.c swap.h pool.h
+block_pool.o: block_pool.c block_pool.h
+pool.o: pool.c pool.h
clean:
rm -f *.o process_test_run
CFLAGS=-g -Wall
-process_test_run: process_test_run.o process.o core.o swap.o pool.o
+process_test_run: process_test_run.o process.o core.o swap.o block_pool.o pool.o
${CC} ${CFLAGS} -o $@ $^
process_test_run.o: process_test_run.c process.h core.h swap.h pool.h
process.o: process.c process.h core.h swap.h pool.h
core.o: core.c core.h pool.h
swap.o: swap.c swap.h pool.h
-
+block_pool.o: block_pool.c block_pool.h
+pool.o: pool.c pool.h
+
clean:
rm -f *.o process_test_run
process.o: process.c process.h core.h fuzix_fs.h util.h pool.h
core.o: core.c core.h pool.h
fuzix_fs.o: fuzix_fs.c fuzix_fs.h
+pool.c: pool.o pool.h
clean:
rm -f *.o process_test_run
process.o: process.c process.h core.h swap.h pool.h
core.o: core.c core.h pool.h
swap.o: swap.c swap.h pool.h
+pool.o: pool.c pool.h
clean:
rm -f *.o process_test_run
./process_test_gen 16 248 1024 32 >process_test.txt
echo "run test script"
-#./process_test_run 16 64 192 8 384 384 <process_test.txt
-rm -f fs.bin
-# need 1536 x 0.5 kbyte for 192 x 4 = 768 kbytes, plus 1 x 0.5 kbyte root dir
-./mkfs fs.bin 63 1600
-./process_test_run 16 64 fs.bin 8 384 384 <process_test.txt
+./process_test_run 16 64 192 8 384 384 <process_test.txt
+#rm -f fs.bin
+## need 1536 x 0.5 kbyte for 192 x 4 = 768 kbytes, plus 1 x 0.5 kbyte root dir
+#./mkfs fs.bin 63 1600
+#./process_test_run 16 64 fs.bin 8 384 384 <process_test.txt
#include "pool.h"
#define MOVEABLE_POOL 1
+#ifdef MOVEABLE_POOL
#define TRY_BLOCKER 1
+#endif
#ifndef NDEBUG
void check_invariants(struct pool_head *head) {
int new_base, new_limit, avail;
bool dir;
struct pool_item *p, *q;
-#if defined(MOVEABLE_POOL) && defined(TRY_BLOCKER)
+#ifdef TRY_BLOCKER
struct pool_item *r, *target_item;
int target_size;
#endif
new_limit = item->limit - gap;
new_base = new_limit - size;
}
-#if !defined(MOVEABLE_POOL) || !defined(TRY_BLOCKER)
+#ifndef TRY_BLOCKER
if (new_base >= item->prev->limit && new_limit <= item->next->base)
goto resize;
#endif
p = &head->item;
q = &head->item;
-#if defined(MOVEABLE_POOL) && defined(TRY_BLOCKER)
+#ifdef TRY_BLOCKER
blocker_test:
// enter here when either blocker has changed
target_item = item;
// see if target fits in current gap
gap = q->base - p->limit;
-#if defined(MOVEABLE_POOL) && defined(TRY_BLOCKER)
+#ifdef TRY_BLOCKER
if (target_size <= gap) {
//printf("target\n");
if (target_item == item)
mkdir --parents $1
sed -e 's/^#include </$include </; s/^#include "rassert\.h"/$include "rassert.h"/; s/^#define DISK_/$define DISK_/; s/^#define BLOCK_/$define BLOCK_/; s/^#define UCP/$define UCP/; s/^#define TRANSFER_/$define TRANSFER_/; s/^#define POOL_ALLOC_MODE_/$define POOL_ALLOC_MODE_/' -i *.[ch]
for i in \
+block_pool.c \
+block_pool.h \
core.c \
core.h \
pool.c \
// transfer data to swap
#ifdef INDIRECT_SWAP
- rassert(swap_block_alloc(swap_table_mem + swap_base, blocks));
+ rassert(
+ block_pool_alloc(&swap_block_pool, swap_table_mem + swap_base, blocks)
+ );
#endif
#ifdef INODE_SWAP
printf("write core [%d,%d) to swap [%d,%d)\n", core_base, core_base + blocks, victim_swap_blocks, victim_swap_blocks + blocks);
printf("\n");
#endif
#ifdef INDIRECT_CORE
- core_block_free(core_table_mem + core_base, blocks);
+ block_pool_free(&core_block_pool, core_table_mem + core_base, blocks);
#endif
victim_swap_blocks += blocks;
#ifdef INDIRECT_CORE
// populate new table with physical blocks
rassert(
- core_block_alloc(
+ block_pool_alloc(
+ &core_block_pool,
core_table_mem + process->core_item.base,
blocks
)
// populate new table with physical blocks or discard them
if (blocks_change >= 0)
rassert(
- core_block_alloc(
+ block_pool_alloc(
+ &core_block_pool,
core_table_mem + process->core_item.limit - blocks_change,
blocks_change
)
);
else
- core_block_free(
+ block_pool_free(
+ &core_block_pool,
core_table_mem + process->core_item.limit,
-blocks_change
);
// transfer data to core
#ifdef INDIRECT_CORE
- core_block_alloc(core_table_mem + core_base, blocks);
+ block_pool_alloc(&core_block_pool, core_table_mem + core_base, blocks);
#endif
#ifdef INODE_SWAP
printf("read swap [%d,%d) to core [%d,%d)\n", process_swap_blocks, process_swap_blocks + blocks, core_base, core_base + blocks);
printf("\n");
#endif
#ifdef INDIRECT_SWAP
- swap_block_free(swap_table_mem + swap_base, blocks);
+ block_pool_free(&swap_block_pool, swap_table_mem + swap_base, blocks);
#endif
} while (process_swap_blocks);
#ifdef INDIRECT_CORE
int core_base = process->core_item.base;
- core_block_free(
+ block_pool_free(
+ &core_block_pool,
core_table_mem + core_base,
process->core_item.limit - core_base
);
#ifndef PREALLOCATE_SWAP
victim_swap_blocks = victim->swap_item.limit - swap_base;
#endif
- swap_block_free(swap_table_mem + swap_base, victim_swap_blocks);
+ block_pool_free(
+ &swap_block_pool,
+ swap_table_mem + swap_base,
+ victim_swap_blocks
+ );
#endif
#if !defined(INODE_SWAP) && !defined(PREALLOCATE_SWAP)
pool_free(&swap_table, &victim->swap_item);
core_base = victim->core_item.base;
victim_core_blocks = victim->core_item.limit - core_base;
#endif
- core_block_free(core_table_mem + core_base, victim_core_blocks);
+ block_pool_free(
+ &core_block_pool,
+ core_table_mem + core_base,
+ victim_core_blocks
+ );
#endif
#ifndef PREALLOCATE_CORE
pool_free(&core_table, &victim->core_item);
// fully in swap, remove from swap pool
#ifdef INDIRECT_SWAP
int swap_base = process->swap_item.base;
- swap_block_free(
+ block_pool_free(
+ &swap_block_pool,
swap_table_mem + swap_base,
process->swap_item.limit - swap_base
);
#ifndef _PROCESS_H
#define _PROCESS_H 1
-#include "pool.h"
-
#define BLOCK_SIZE 0x1000
#define BLOCK_SHIFT 12
#define INODE_SWAP 1
+#ifdef INODE_SWAP
#define DISK_BLOCK_SIZE 0x200
#define DISK_BLOCK_SHIFT 9
#define DISK_INDIRECT_SIZE 0x100
#define DISK_INDIRECT_SHIFT 8
+#endif
+
+#include "pool.h"
struct lru_item {
struct lru_item *prev;
swap_size
);
#ifdef INDIRECT_CORE
- core_block_free(core_table_mem + core_base, core_blocks);
+ block_pool_free(
+ &core_block_pool,
+ core_table_mem + core_base,
+ core_blocks
+ );
#endif
swap_hash_verify(
i,
//printf("deref inode %d\n", processes[i].swap_inode->c_num);
i_deref(processes[i].swap_inode);
#elif defined(INDIRECT_SWAP)
- swap_block_free(swap_table_mem + swap_base, swap_blocks);
+ block_pool_free(
+ &swap_block_pool,
+ swap_table_mem + swap_base,
+ swap_blocks
+ );
#endif
}
}
rassert(core_table_mem[i] == 0x55555555);
#endif
{
- k = n_core_blocks >> 3;
+ k = core_block_pool.n_blocks >> 3;
for (j = 0; j < k; ++j)
- rassert(core_block_bitmap[j] == 0xff);
- k = n_core_blocks & 7;
+ rassert(core_block_pool.bitmap[j] == 0xff);
+ k = core_block_pool.n_blocks & 7;
if (k)
- rassert(core_block_bitmap[j] == (uint8_t)~(-1 << k));
+ rassert(core_block_pool.bitmap[j] == (uint8_t)~(-1 << k));
}
#endif
j = n_core_blocks << BLOCK_SHIFT;
rassert(swap_table_mem[i] == 0x55555555);
#endif
{
- k = n_swap_blocks >> 3;
+ k = swap_block_pool.n_blocks >> 3;
for (j = 0; j < k; ++j)
- rassert(swap_block_bitmap[j] == 0xff);
- k = n_swap_blocks & 7;
+ rassert(swap_block_pool.bitmap[j] == 0xff);
+ k = swap_block_pool.n_blocks & 7;
if (k)
- rassert(swap_block_bitmap[j] == (uint8_t)~(-1 << k));
+ rassert(swap_block_pool.bitmap[j] == (uint8_t)~(-1 << k));
}
#endif
j = n_swap_blocks << BLOCK_SHIFT;
struct pool_head swap_table;
#ifdef INDIRECT_SWAP
int *swap_table_mem;
-
-static uint8_t masks[8] = {0xff, 0xfe, 0xfc, 0xf8, 0xf0, 0xe0, 0xc0, 0x80};
-static uint8_t bits[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
-
-int n_swap_blocks;
-int n_swap_block_bitmap;
-uint8_t *swap_block_bitmap;
-int swap_block_next;
-int swap_block_avail;
+struct block_pool swap_block_pool;
#endif
#ifdef PREALLOCATE_SWAP
#ifdef INDIRECT_SWAP
int i;
#else
+ struct process *process;
long size;
#endif
}
#else
// see if incomplete last block, if so don't copy extra part
- struct process *process =
+ process =
(struct process *)((char *)item - offsetof(struct process, swap_item));
size = (long)blocks << BLOCK_SHIFT;
if (size > process->size)
rassert(swap_table_mem);
memset(swap_table_mem, 0x55, table_size * sizeof(int));
- n_swap_blocks = n_blocks;
- n_swap_block_bitmap = (n_swap_blocks + 7) >> 3;
- swap_block_bitmap = malloc(n_swap_block_bitmap);
- rassert(swap_block_bitmap);
- memset(swap_block_bitmap, 0xff, n_swap_block_bitmap);
- if (n_swap_blocks & 7)
- swap_block_bitmap[n_swap_blocks >> 3] = ~masks[n_swap_blocks & 7];
- swap_block_next = 0;
- swap_block_avail = n_swap_blocks;
-#endif
-}
-
-#ifdef INDIRECT_SWAP
-bool swap_block_alloc(int *table, int size) {
- int i, j, k;
- uint8_t c;
-
- if (swap_block_avail < size)
- return false;
-
- for (i = 0; i < size; ++i) {
- j = swap_block_next >> 3;
- c = swap_block_bitmap[j] & masks[swap_block_next & 7];
- goto loop_entry;
- for (; j < n_swap_block_bitmap; ++j) {
- c = swap_block_bitmap[j];
- loop_entry:
- if (c) goto found;
- }
-#if 1
- for (j = 0; ; ++j) {
- assert(j <= swap_block_next >> 3);
- c = swap_block_bitmap[j];
- if (c) goto found;
- }
-#else
- k = (swap_block_next >> 3) + 1;
- for (j = 0; j < k; ++j) {
- c = swap_block_bitmap[j];
- if (c) goto found;
- }
- swap_block_free(table, i);
- return false;
-#endif
-
- found:
- for (k = 0; (c & 1) == 0; ++k)
- c >>= 1;
- swap_block_bitmap[j] &= ~bits[k];
- swap_block_next = (j << 3) | k;
-
-#ifndef NDEBUG // makes us remove the following line in gen.sh as appropriate
- assert(table[i] == 0x55555555);
-#endif
- table[i] = swap_block_next++;
- if (swap_block_next >= n_swap_blocks)
- swap_block_next = 0;
- }
-
- swap_block_avail -= size;
- return true;
-}
-
-void swap_block_free(int *table, int size) {
- int i, j, k;
-
- for (i = 0; i < size; ++i) {
- j = table[i];
- assert(j >= 0 && j < n_swap_blocks);
- k = j & 7;
- j >>= 3;
- assert((swap_block_bitmap[j] & bits[k]) == 0);
- swap_block_bitmap[j] |= bits[k];
-#ifndef NDEBUG
- table[i] = 0x55555555;
+ block_pool_init(&swap_block_pool, n_blocks);
#endif
- }
-
- swap_block_avail += size;
}
-#endif
#ifndef _SWAP_H
#define _SWAP_H 1
-#include <stdint.h>
-#include "pool.h"
-
#define PREALLOCATE_SWAP 1
#define INDIRECT_SWAP 1
//#define MOVEABLE_SWAP 1
+#include <stdint.h>
#ifdef INDIRECT_SWAP
-#define SWAP_AVAIL swap_block_avail
+#include "block_pool.h"
+#endif
+#include "pool.h"
+
+#ifdef INDIRECT_SWAP
+#define SWAP_AVAIL swap_block_pool.avail
#else
#define SWAP_AVAIL swap_table.avail
#endif
extern struct pool_head swap_table;
#ifdef INDIRECT_SWAP
extern int *swap_table_mem;
-
-extern int n_swap_blocks;
-int n_swap_block_bitmap;
-extern uint8_t *swap_block_bitmap;
-extern int swap_block_next;
-extern int swap_block_avail;
+extern struct block_pool swap_block_pool;
#endif
#ifdef PREALLOCATE_SWAP
#ifdef INDIRECT_SWAP
void swap_init(int n_table, int n_blocks);
-bool swap_block_alloc(int *blocks, int size);
-void swap_block_free(int *blocks, int size);
#else
void swap_init(int n_table);