コード例 #1
0
ファイル: pos-hashtable-stm.c プロジェクト: kunulee/f-stm
int 
stm_pos_create_hashtable( char *name, unsigned int minsize, 
		unsigned long (*hashfunction) (unsigned long *),
		int (*key_eq_fn)(unsigned long*,unsigned long*)){
	int rval ; 	
	int ret_val = 0 ; 	

	if(pos_create(name) == 0){ 
		return -1;
	}
	/* create for hashtable rollback-journal */
	ret_val = stm_pos_create_object(name , TOT_TM) ; 	
	if( ret_val == -1){ 
		PR_DEBUG("[%s] stm_pos_create_object error\n" ,__func__ );			return -1; 
	}	
        if (hashfunction == NULL && key_eq_fn == NULL) {
                //PR_DEBUG("key_rq_fn : %lu\n" , default_key_eq_fn );
                rval = create_hashtable(name, minsize, default_hashfunction, default_key_eq_fn);
        } else {
                rval = create_hashtable(name, minsize, hashfunction, key_eq_fn);
        }

	PR_DEBUG("[%s] log_unmap called\n", __func__ ) ; 	
	stm_pos_log_unmap(name) ; 	
	PR_DEBUG("[%s] unmap called\n" , __func__ ) ; 	
	pos_unmap(name) ; 	
	return 0 ;
} 	
コード例 #2
0
ファイル: suffixtree.c プロジェクト: pombredanne/nmergec
/**
 * Walk down the tree from the given node following the given path
 * @param st the suffixtree in question
 * @param v the node to start from its children
 * @param p the path to walk down and then free
 * @return a position corresponding to end
 */
static pos *walk_down( suffixtree *st, node *v, path *p )
{
    pos *q=NULL;
    int start = path_start( p );
    int len = path_len( p );
    v = node_find_child( v, st->str, st->str[start] );
    while ( len > 0 )
    {
        if ( len <= node_len(v) )
        {
            q = pos_create();
            q->loc = node_start(v)+len-1;
            q->v = v;
            break;
        }
        else
        {
            start += node_len(v);
            len -= node_len(v);
            v = node_find_child( v, st->str, st->str[start] );
        }
    }
    path_dispose( p );
    return q;
}
コード例 #3
0
ファイル: pos-hashtable.c プロジェクト: kunulee/keonwoo_heapo
int 
pos_create_hashtable(char *name, unsigned int minsize,
                 unsigned long (*hashfunction) (unsigned long*),
                 int (*key_eq_fn) (unsigned long*,unsigned long*))
{
	int rval;
	
	if (pos_create(name) == 0)
		return -1;
#if CONSISTENCY == 1
	#if UNDO_CONSISTENCY == 1 
	pos_log_create(name);
	pos_transaction_start(name, POS_TS_INSERT);
	#endif
#endif
	if (hashfunction == NULL && key_eq_fn == NULL) {
		//PR_DEBUG("key_rq_fn : %lu\n" , default_key_eq_fn );
		rval = create_hashtable(name, minsize, default_hashfunction, default_key_eq_fn);
	} else {
		rval = create_hashtable(name, minsize, hashfunction, key_eq_fn);
	}
	
#if CONSISTENCY == 1
	#if UNDO_CONSISTENCY == 1
	pos_transaction_end(name);
	pos_log_unmap(name);
	#endif
#endif
	pos_unmap(name);

	return rval;
}
コード例 #4
0
ファイル: pos-list.c プロジェクト: kunulee/f-stm
int pos_list_init(char *name)
{
	struct list_head *head;
	PR_DEBUG("%s name \n", name ) ;	
	if (pos_create(name) == 0)
		return -1;

#if CONSISTENCY == 1
	#if UNDO_CONSISTENCY == 1
	pos_log_create(name);
	pos_transaction_start(name, POS_TS_INSERT);
	#endif
#endif
	head = (struct list_head *)pos_malloc(name, sizeof(struct list_head));
	
	// Keonwoo Consistency Point//
	// IF crash here, garbage created because of function pos_malloc. 

	pos_set_prime_object(name, head);
	head->head = NULL;

#if CONSISTENCY == 1
	#if UNDO_CONSISTENCY == 1 
	pos_transaction_end(name);
	pos_log_unmap(name);
	#endif
#endif
	pos_unmap(name);
	return 0;
}
コード例 #5
0
ファイル: suffixtree.c プロジェクト: pombredanne/nmergec
/**
 * Find a location of the suffix in the tree.
 * @param st the suffixtree in question
 * @param j the extension number counting from 0
 * @param i the current phase - 1
 * @param log the log to record errors in
 * @return the position (combined node and edge-offset)
 */ 
static pos *find_beta( suffixtree *st, int j, int i, plugin_log *log )
{
    pos *p;
    if ( st->old_j > 0 && st->old_j == j )
    {
        p = pos_create();
        p->loc = st->old_beta.loc;
        p->v = st->old_beta.v;
    }
    else if ( j>i )  // empty string
    {
        p = pos_create();
        p->loc = 0;
        p->v = st->root;
    }
    else if ( j==0 )    // entire string
    {
        p = pos_create();
        p->loc = i;
        p->v = st->f;
    }
    else // walk across tree
    {
        node *v = st->last.v;
        int len = st->last.loc-node_start(st->last.v)+1;
        path *q = path_create( node_start(v), len, log );
        v = node_parent( v );
        while ( v != st->root && node_link(v)==NULL )
        {
            path_prepend( q, node_len(v) );
            v = node_parent( v );
        }
        if ( v != st->root )
        {
            v = node_link( v );
            p = walk_down( st, v, q );
        }
        else
        {
            path_dispose( q );
            p = walk_down( st, st->root, path_create(j,i-j+1,log) );
        }
    }
    st->last = *p;
    return p;
}
コード例 #6
0
ファイル: find-strings.c プロジェクト: bbyk/cwo
/**
 * Find a location of the suffix in the tree.
 * @param j the extension number counting from 0
 * @param i the current phase - 1
 * @return the position (combined node and edge-offset)
 */
static pos *find_beta( int j, int i )
{
    pos *p;
    if ( old_j > 0 && old_j == j )
    {
        p = pos_create();
        p->loc = old_beta.loc;
        p->v = old_beta.v;
    }
    else if ( j>i )  // empty string
    {
        p = pos_create();
        p->loc = 0;
        p->v = root;
    }
    else if ( j==0 )    // entire string
    {
        p = pos_create();
        p->loc = i;
        p->v = f;
    }
    else // walk across tree
    {
        node *v = last.v;
        int len = last.loc-node_start(last.v)+1;
        path *q = path_create( node_start(v), len );
        v = node_parent( v );
        while ( v != root && node_link(v)==NULL )
        {
            path_prepend( q, node_len(v) );
            v = node_parent( v );
        }
        if ( v != root )
        {
            v = node_link( v );
            p = walk_down( v, q );
        }
        else
        {
            path_dispose( q );
            p = walk_down( root, path_create(j,i-j+1) );
        }
    }
    last = *p;
    return p;
}
コード例 #7
0
ファイル: pos-list.c プロジェクト: kunulee/f-stm
int t_pos_list_init( char * name , int thread_num){ 
	#if (KEONWOO_DEBUG == 1) 
	PR_DEBUG("[%s] name,[%d]:thread_num\n",name,thread_num);
	#endif 
	if(core_num == -1){ 
		core_num = sysconf( _SC_NPROCESSORS_CONF) ;
		#if (KEONWOO_DEBUG == 1)
		PR_DEBUG("[%d]:core_num\n" ,core_num) ;
		#endif 
	}
	if( thread_num == 1 ){ 
		flags_num = NORMAL_ROUTINE ; 	
	}else if( thread_num > core_num ){ 
		flags_num = LOCK_ROUTINE | NORMAL_ROUTINE ; 	
	}else if( thread_num != 1 && thread_num <= core_num ){ 
		flags_num = STM_ROUTINE | NORMAL_ROUTINE ; 	
	}
	if( (flags_num & NORMAL_ROUTINE) && (flags_num & STM_ROUTINE )){ 
		#if (KEONWOO_DEBUG == 1)
		PR_DEBUG("STM ROUTINE\n") ; 	
		// software transactional memory initialization
		#endif  	
	//	PR_DEBUG("[TM_INIT]\n") ;	
	//	TM_INIT ; 	
	}else if( (flags_num & NORMAL_ROUTINE) && (flags_num & LOCK_ROUTINE)){ 
		#if (KEONWOO_DEBUG == 1)
		PR_DEBUG("LOCK ROUTINE\n") ; 	
		#endif 
	}else if( ( flags_num == 0x01 ) ){ 
		#if (KEONWOO_DEBUG == 1)
		PR_DEBUG("[NORMAL ROUTINE\n") ;
		#endif 
	}
	
	struct list_head * head ; 	
	#if (KEONWOO_DEBUG == 1)
	PR_DEBUG("[%s]:object name\n",name) ; 	
	#endif 	
	if(pos_create(name) == 0){ 
		PR_DEBUG("[pos_create] already create\n") ; 
		return -1;
	}
	head = (struct list_head *)pos_malloc(name ,sizeof(struct list_head)) ;	
	pos_set_prime_object(name , head) ; 	
	head->head = NULL ; 	
	pos_unmap(name) ; 	
	return 0 ; 	
}