Beispiel #1
0
// swap_init - init swap fs, two swap lists, alloc memory & init for swap_entry record array mem_map
//           - init the hash list.
void
swap_init(void) {
    swapfs_init();
    swap_list_init(&active_list);
    swap_list_init(&inactive_list);

    if (!(512 <= max_swap_offset && max_swap_offset < MAX_SWAP_OFFSET_LIMIT)) {
        panic("bad max_swap_offset %08x.\n", max_swap_offset);
    }

    mem_map = kmalloc(sizeof(short) * max_swap_offset);
    assert(mem_map != NULL);

    size_t offset;
    for (offset = 0; offset < max_swap_offset; offset ++) {
        mem_map[offset] = SWAP_UNUSED;
    }

    int i;
    for (i = 0; i < HASH_LIST_SIZE; i ++) {
        list_init(hash_list + i);
    }

    sem_init(&swap_in_sem, 1);

    check_swap();
    check_mm_swap();
    check_mm_shm_swap();

    wait_queue_init(&kswapd_done);
    swap_init_ok = 1;
}
Beispiel #2
0
int swap_init(void)
{
	swapfs_init();

	if (!(1024 <= max_swap_offset && max_swap_offset < MAX_SWAP_OFFSET_LIMIT))
	{
		panic("bad max_swap_offset %08x.\n", max_swap_offset);
	}

	sm = &swap_manager_fifo;
	int r = sm->init();

	if (r == 0)
	{
		swap_init_ok = 1;
		cprintf("SWAP: manager = %s\n", sm->name);
		check_swap();
	}

	return r;
}