函数buf_pool_init_instance

 

 buff_pool_t 结构体 详见

/********************************************************************//**
Initialize a buffer pool instance.
@return DB_SUCCESS if all goes well. */
UNIV_INTERN
ulint
buf_pool_init_instance(
/*===================*/
    buf_pool_t*    buf_pool,    /*!< in: buffer pool instance */
    ulint        buf_pool_size,    /*!< in: size in bytes */
    ulint        instance_no)    /*!< in: id of the instance */
{
    ulint        i;
    buf_chunk_t*    chunk;

    /* 1. Initialize general fields
    ------------------------------- */
    mutex_create(buf_pool_mutex_key,
             &buf_pool->mutex, SYNC_BUF_POOL);
    mutex_create(buf_pool_zip_mutex_key,
             &buf_pool->zip_mutex, SYNC_BUF_BLOCK);

    buf_pool_mutex_enter(buf_pool);

    if (buf_pool_size > 0) {
        buf_pool->n_chunks = 1;
        buf_pool->chunks = chunk = mem_zalloc(sizeof *chunk);

        UT_LIST_INIT(buf_pool->free);
        /**
*为chunk->mem分配buf_pool_size大小的内存,该内存大小须能被16K整除
*每16K对应一个frame,也对应一个控制chunk
*/
if (!buf_chunk_init(buf_pool, chunk, buf_pool_size)) { //详见 mem_free(chunk); mem_free(buf_pool); buf_pool_mutex_exit(buf_pool); return(DB_ERROR); } buf_pool->instance_no = instance_no; buf_pool->old_pool_size = buf_pool_size; buf_pool->curr_size = chunk->size; buf_pool->curr_pool_size = buf_pool->curr_size * UNIV_PAGE_SIZE; buf_pool->page_hash = hash_create(2 * buf_pool->curr_size); buf_pool->zip_hash = hash_create(2 * buf_pool->curr_size); buf_pool->last_printout_time = ut_time(); } /* 2. Initialize flushing fields -------------------------------- */ mutex_create(flush_list_mutex_key, &buf_pool->flush_list_mutex, SYNC_BUF_FLUSH_LIST); for (i = BUF_FLUSH_LRU; i < BUF_FLUSH_N_TYPES; i++) { buf_pool->no_flush[i] = os_event_create(NULL); } /* 3. Initialize LRU fields --------------------------- */ /* All fields are initialized by mem_zalloc(). */ buf_pool_mutex_exit(buf_pool); return(DB_SUCCESS); }

 

你可能感兴趣的:(函数buf_pool_init_instance)