예제 #1
0
파일: slabs.c 프로젝트: mocchira/cherly
void slabs_free(slabs_t* pst, void *ptr, size_t size) {
    void *header;
    size += sizeof(slabheader_t);
    unsigned int id = slabs_clsid(pst, size);
    header = (void*)((char*)ptr - sizeof(slabheader_t));
    do_slabs_free(pst, header, size, id);
}
예제 #2
0
static void split_slab_page_into_freelist(char *ptr, const unsigned int id) {
    slabclass_t *p = &slabclass[id];
    int x;
    for (x = 0; x < p->perslab; x++) {
        do_slabs_free(ptr, 0, id);
        ptr += p->size;
    }
}
예제 #3
0
void Slab::split_slab_page_into_freelist(char* ptr, unsigned int id) {
    slabclass& p = mem_base[id];
    int i;
    for (i = 0; i < p.perslab; i++) {
        do_slabs_free(ptr, 0, id);
        ptr += p.size;
    }
}
예제 #4
0
static void do_smmgr_blck_free(struct default_engine *engine, sm_blck_t *blck)
{
    do_smmgr_used_blck_unlink(blck);
    do_slabs_free(engine, blck, sm_anchor.blck_tsize, sm_anchor.blck_clsid);
    if (sm_anchor.free_limit_space > 0) {
        sm_anchor.free_chunk_space += sm_anchor.blck_tsize;
    }
}
예제 #5
0
void slabs_free(struct default_engine *engine, void *ptr, size_t size, unsigned int id)
{
    if (id < POWER_SMALLEST || id > engine->slabs.power_largest)
        return;
    pthread_mutex_lock(&engine->slabs.lock);
    do_slabs_free(engine, ptr, size, id);
    pthread_mutex_unlock(&engine->slabs.lock);
}
/**
 * 将ptr所指向的slab初始化成item链表,链接到slabclass[id]的slot指针上。
 *
 */
static void split_slab_page_into_freelist(char *ptr, const unsigned int id) {
    slabclass_t *p = &slabclass[id];
    int x;
	 //每个slabclass有多个slab,对每个slab按slabclass对应的size进行切分  
    for (x = 0; x < p->perslab; x++) {
        do_slabs_free(ptr, 0, id); //创建空闲item
        ptr += p->size;
    }
}
예제 #7
0
//将ptr指向的内存页划分成一个个的item
static void split_slab_page_into_freelist(char *ptr, const unsigned int id) {
    slabclass_t *p = &slabclass[id];
    int x;
    for (x = 0; x < p->perslab; x++) {


        //将ptr指向的内存划分成一个个的item.一共划成perslab个  
        //并将这些item前后连起来。  
        //do_slabs_free函数本来是worker线程向内存池归还内存时调用的。但在这里  
        //新申请的内存也可以当作是向内存池归还内存。把内存注入内存池中
        do_slabs_free(ptr, 0, id);
        ptr += p->size;//size是item的大小
    }
}
예제 #8
0
static void split_slab_page_into_freelist(char *ptr, const unsigned int id) {
    slabclass_t *p = &slabclass[id];
    int x;
	
	// 初始化slab中的item的信息
	// 把item全放在slots中。所以以后给用户分配内存的时候
	// 直接从slots中找,不需要再遍历slab来找了。
	// 估计这是优化后的结构,以前在slabclass中应该有存储当前
	// 已用的slab的信息,而slots中存储free掉的item,这样当
	// sltos中的item用完后,再从slab中取。
	// 这把改为都从slots中取以后明显方便和快捷多了。 好改进!!
    for (x = 0; x < p->perslab; x++) {
        do_slabs_free(ptr, 0, id);
        ptr += p->size;
    }
}
예제 #9
0
파일: slabs.c 프로젝트: 4e/memcached
void slabs_free(void *ptr, size_t size, unsigned int id) {
    pthread_mutex_lock(&slabs_lock);
    do_slabs_free(ptr, size, id);
    pthread_mutex_unlock(&slabs_lock);
}
예제 #10
0
파일: slabs.c 프로젝트: hsharsha/memcached
void slabs_free(struct default_engine *engine, void *ptr, size_t size, unsigned int id) {
    cb_mutex_enter(&engine->slabs.lock);
    do_slabs_free(engine, ptr, size, id);
    cb_mutex_exit(&engine->slabs.lock);
}
예제 #11
0
void Slab::slabs_free(void* ptr, size_t size, unsigned int id) {
    slabs_lock.lock();
    do_slabs_free(ptr, size, id);
    slabs_lock.unlock();
}
예제 #12
0
void slabs_free(struct default_engine *engine, void *ptr, size_t size, unsigned int id) {
    pthread_mutex_lock(&engine->slabs.lock);
    do_slabs_free(engine, ptr, size, id);
    pthread_mutex_unlock(&engine->slabs.lock);
}