コード例 #1
0
ファイル: palloc.c プロジェクト: robby35us/asg1
/* Initializes all the pages of physical memory, divides them evenly into
   into kernel and user pages. Also intializes the frame table, which grabs
   all of the user pages. All user pages must be obtained through the virtual
   memory construct. */
void
palloc_init (size_t user_page_limit)
{
   /* calculates the number of pages available
      to allocate after the bitmap is initialized */
   int num_user_pages = old_palloc_init(user_page_limit); 
   size_t bm_pages = DIV_ROUND_UP (bitmap_buf_size (num_user_pages), PGSIZE);
   frame_table_init(num_user_pages - bm_pages);
}
コード例 #2
0
ファイル: swap.c プロジェクト: xuruiyang/CS5600
void init_swap(){
	swap_blk = block_get_role(BLOCK_SWAP);
	ASSERT(swap_blk!=NULL);
	uint32_t sectors_num = block_size (swap_blk);
	// each sector is 512K, one page has 8 sectors
	uint32_t slots_num = sectors_num/8;
	size_t bm_pages = DIV_ROUND_UP (bitmap_buf_size (slots_num), PGSIZE);
	uint8_t* base = palloc_get_multiple (PAL_ZERO|PAL_ASSERT, bm_pages);
	swap_table = bitmap_create_in_buf (slots_num, base, bm_pages * PGSIZE);
	lock_init(&swap_lock);
}
コード例 #3
0
ファイル: palloc.c プロジェクト: jonhtheapstl/Pintos
/* Initializes pool P as starting at START and ending at END,
   naming it NAME for debugging purposes. */
static void
init_pool (struct pool *p, void *base, size_t page_cnt, const char *name) 
{
  /* We'll put pool's used_map at its base.
     Calculate the space needed for the bitmap
     and subtract it from the pool's size. */
  size_t bm_pages = DIV_ROUND_UP (bitmap_buf_size (page_cnt), PGSIZE);
  if (bm_pages > page_cnt)
    PANIC ("Not enough memory in %s for bitmap.", name);
  page_cnt -= bm_pages;

  printf ("%zu pages available in %s.\n", page_cnt, name);

  /* Initialize the pool. */
  lock_init (&p->lock);
  p->used_map = bitmap_create_in_buf (page_cnt, base, bm_pages * PGSIZE);
  p->base = base + bm_pages * PGSIZE;
}