Ejemplo n.º 1
0
void getDoneRowInfoNew(ParallelETree *tree,const int *postorder,const int *postorder_inv,const int treeInternalSize)
{	
	int i;

	int *priorityTable = getMempoolSet(sizeof(int)*(treeInternalSize+1));
	for(i=0;i<treeInternalSize+1;i++) priorityTable[i] = treeInternalSize - postorder_inv[i];

	gdsl_queue_t freeSinkList = gdsl_queue_alloc("freeSinkListTemp",alloc_int,free_int);
	getInitSinkList(freeSinkList,tree);
	// set the doneRow information
	while(gdsl_queue_get_size(freeSinkList)!=0)
	{
		int *indexInQueue = gdsl_queue_get_head(freeSinkList);
		gdsl_queue_remove(freeSinkList);
		updateFreeSinkList(freeSinkList,tree,*indexInQueue,treeInternalSize,priorityTable);
		retMempoolSet(indexInQueue,sizeof(int));
	}

	// recover the setting of visiting the tree
	for(i=0;i<tree->size;i++)
	{
		if(tree->node[i] == NULL) continue;
		else tree->node[i]->visitLog = notvisit;
	}

	gdsl_queue_free(freeSinkList);
	retMempoolSet(priorityTable,sizeof(int)*(treeInternalSize+1));
}
Ejemplo n.º 2
0
SparseGControlInfoMonte *createSparseGControlInfoMonte(void)
{
	SparseGControlInfoMonte *ptr = (SparseGControlInfoMonte *)malloc(sizeof(SparseGControlInfoMonte));
	ptr->row = -1;
	ptr->col = -1;
	ptr->queue = gdsl_queue_alloc("queue",allocGControlInfoMonteQueue,freeGControlInfoMonteQueue);
	ptr->rowLink = NULL;
	ptr->colLink = NULL;
	return ptr;
}
Ejemplo n.º 3
0
void *voole_init (struct fuse_conn_info *conn)
{
/*	voolefs.cache.nodes = gdsl_hash_alloc("voolefs node hash cache",
			NULL,NULL,NULL,NULL,NULL);
	voolefs.cache.file_mem = gdsl_hash_alloc("voolefs file mem cache",
			NULL,NULL,NULL,addrcomp,NULL);
*/	voolefs.registration = gdsl_queue_alloc(NULL, NULL, NULL);
	voolefs.accesses = gdsl_hash_alloc(NULL, NULL, NULL, (gdsl_key_func_t)keyHash,  /* Session Table */
			         (gdsl_hash_func_t)hashHash, (gdsl_comp_func_t)compHash, 200);
	pthread_mutex_init(&voolefs.lock,NULL);
	voolefs.cache_file_size = 1*1024*1024; // 1M 
//	int ncon = tcp_cin_init();
	int nsem = tcp_sem_init();
	printf("i iam init \n	%d semphere\n",nsem);
	return NULL;
}   
Ejemplo n.º 4
0
SparseNetlistQuad *parseSparseQuadInput(SparseNetlistQuad *ptr, const char *filename)
{

	FILE *fp = fopen(filename,"r");
	char line[1024];
	char *status;
	int i,j,k;
	//==========================================================
	
	ptr->a = createSparseQuadMatrix(ptr->nodeNum,ptr->nodeNum,ptr->gvNum);
	ptr->b = createSparseQuadMatrix(ptr->nodeNum,ptr->nodeNum,ptr->gvNum);
	ptr->c = createSparseQuadMatrix(ptr->nodeNum,ptr->nodeNum,ptr->gvNum);
	ptr->u = createQuadMatrix(ptr->nodeNum,ptr->stepNum,ptr->gvNum);
	ptr->gVarientTable = createSparseGVarientTable(ptr->nodeNum,ptr->nodeNum);	
	
	gdsl_queue_t voltageInNode = gdsl_queue_alloc("voltageInNode",allocInt,freeInt);
	double maxG = 10;

	LinearNodeList *linearNodeList = createLinearNodeList();
	ptr->nonlinearNodeList = createNonlinearNodeList();

	while( (status=fgetl(line,1024,fp))!=NULL )
	{
		if(line[0] == 'G' || line[0] == 'g')
		{
			CircuitEntryQuad *circuit = createCircuitEntryQuad();
			setCircuitEntryQuad(circuit,line);
	
			QuadElement *tempQuadElement = createQuadElement(ptr->gvNum);
			const QuadElement *quadElementInList = getLinearNodeList(linearNodeList,circuit->val,circuit->alphaName,circuit->betaName,circuit->gammaName);
			if(quadElementInList == NULL)
			{
				tempQuadElement->m = circuit->val;
				tempQuadElement->alpha = getAlpha(circuit->alphaName);
			
				gsl_matrix *betaFromDlmread = gsl_matrix_alloc(ptr->gvNum,1);
				dlmread(betaFromDlmread,circuit->betaName," ",0,0,ptr->gvNum-1,0);
				gsl_matrix_to_double(tempQuadElement->beta,betaFromDlmread);
				gsl_matrix_free(betaFromDlmread);
			
				gsl_matrix *gammaFromDlmread = gsl_matrix_alloc(ptr->gvNum,ptr->gvNum);
				dlmread(gammaFromDlmread,circuit->gammaName," ",0,0,ptr->gvNum-1,ptr->gvNum-1);
				gsl_matrix_to_double(tempQuadElement->gamma,gammaFromDlmread);
				gsl_matrix_free(gammaFromDlmread);

				insertLinearNodeList(linearNodeList,circuit->val,circuit->alphaName,circuit->betaName,circuit->gammaName,tempQuadElement);
			}
			else
			{
				copyQuadElement(tempQuadElement,quadElementInList);
			}
			const int pos = toZeroBase(circuit->pos);
			const int neg = toZeroBase(circuit->neg);
			if(pos != -1)
			{
				decSparseQuadMatrix(ptr->a,tempQuadElement,pos,pos);
			}
			if(neg != -1)
			{
				decSparseQuadMatrix(ptr->a,tempQuadElement,neg,neg);
			}
			if(pos!=-1 && neg!=-1)
			{
				incSparseQuadMatrix(ptr->a,tempQuadElement,neg,pos);
				incSparseQuadMatrix(ptr->a,tempQuadElement,pos,neg);
			}
			
			if(abs(circuit->val) > maxG )	maxG = abs(circuit->val);
			freeCircuitEntryQuad(circuit);
			freeQuadElement(tempQuadElement);
		}		
		else if(line[0] == 'C' || line[0] == 'c')
		{
			CircuitEntryQuad *circuit = createCircuitEntryQuad();
			setCircuitEntryQuad(circuit,line);
			
			QuadElement *tempQuadElement = createQuadElement(ptr->gvNum);
			const QuadElement *quadElementInList = getLinearNodeList(linearNodeList,circuit->val,circuit->alphaName,circuit->betaName,circuit->gammaName);
			if(quadElementInList == NULL)
			{
				tempQuadElement->m = circuit->val;
				tempQuadElement->alpha = getAlpha(circuit->alphaName);
			
				gsl_matrix *betaFromDlmread = gsl_matrix_alloc(ptr->gvNum,1);
				dlmread(betaFromDlmread,circuit->betaName," ",0,0,ptr->gvNum-1,0);
				gsl_matrix_to_double(tempQuadElement->beta,betaFromDlmread);
				gsl_matrix_free(betaFromDlmread);
			
				gsl_matrix *gammaFromDlmread = gsl_matrix_alloc(ptr->gvNum,ptr->gvNum);
				dlmread(gammaFromDlmread,circuit->gammaName," ",0,0,ptr->gvNum-1,ptr->gvNum-1);
				gsl_matrix_to_double(tempQuadElement->gamma,gammaFromDlmread);
				gsl_matrix_free(gammaFromDlmread);

				insertLinearNodeList(linearNodeList,circuit->val,circuit->alphaName,circuit->betaName,circuit->gammaName,tempQuadElement);
			}
			else
			{
				copyQuadElement(tempQuadElement,quadElementInList);
			}
			const int pos = toZeroBase(circuit->pos);
			const int neg = toZeroBase(circuit->neg);
			if(pos != -1)
			{
				incSparseQuadMatrix(ptr->c,tempQuadElement,pos,pos);
			}
			if(neg != -1)
			{
				incSparseQuadMatrix(ptr->c,tempQuadElement,neg,neg);
			}
			if(pos!=-1 && neg!=-1)
			{
				decSparseQuadMatrix(ptr->c,tempQuadElement,pos,neg);
				decSparseQuadMatrix(ptr->c,tempQuadElement,neg,pos);
			}
			freeCircuitEntryQuad(circuit);
			freeQuadElement(tempQuadElement);
		}
		else if(line[0] =='V' || line[0] =='v')
		{
			CircuitEntryQuad *circuit = createCircuitEntryQuad();
			setVoltageIn(circuit,line);
			gsl_matrix *tempM = gsl_matrix_calloc(1,ptr->stepNum);
			gsl_matrix *tempAlpha = gsl_matrix_calloc(1,ptr->stepNum);
			gsl_matrix *tempBeta = gsl_matrix_calloc(ptr->gvNum,ptr->stepNum);
			gsl_matrix *tempGamma = gsl_matrix_calloc(ptr->gvNum*ptr->gvNum,ptr->stepNum);
			dlmread(tempM,circuit->mName,",",0,0,0,ptr->stepNum-1);
			dlmread(tempAlpha,circuit->alphaName,",",0,0,0,ptr->stepNum-1);
			dlmread(tempBeta,circuit->betaName,",",0,0,ptr->gvNum-1,ptr->stepNum-1);
			dlmread(tempGamma,circuit->gammaName,",",0,0,ptr->gvNum*ptr->gvNum-1,ptr->stepNum-1);	
			const int pos = toZeroBase(circuit->pos);
			const int neg = toZeroBase(circuit->neg);
			if(neg == -1)
			{
				// save the pos to the voltageInNode ~ used in pass 2 , to setup B
				gdsl_queue_insert(voltageInNode,&(circuit->pos));
				// for each step, set m, alpha, beta, and gamma
				for(i=0;i<ptr->stepNum;i++)
				{
					QuadElement *tempVin = createQuadElement(ptr->gvNum);
					gsl_matrix *betaVin = gsl_matrix_calloc(ptr->gvNum,1);
					gsl_matrix *gammaVin = gsl_matrix_calloc(ptr->gvNum,ptr->gvNum);
					// set beta
					for(j=0;j<ptr->gvNum;j++)
					{
						const double temp = gsl_matrix_get(tempBeta,j,i);
						gsl_matrix_set(betaVin,j,0,temp);
					}
					// set gamma
					for(j=0;j<ptr->gvNum;j++)
					{
						for(k=0;k<ptr->gvNum;k++)
						{
							const double temp = gsl_matrix_get(tempGamma,j*ptr->gvNum+k,i);
							gsl_matrix_set(gammaVin,j,k,temp);
						}
					}
					double *betaVinDouble = getMempoolSet(sizeof(double)*ptr->gvNum);
					double *gammaVinDouble = getMempoolSet(sizeof(double)*ptr->gvNum*ptr->gvNum);
					gsl_matrix_to_double(betaVinDouble,betaVin);
					gsl_matrix_to_double(gammaVinDouble,gammaVin);
					setQuadElement(tempVin,gsl_matrix_get(tempM,0,i),gsl_matrix_get(tempAlpha,0,i),betaVinDouble,gammaVinDouble);
					setQuadMatrix(ptr->u,tempVin,pos,i);
					freeQuadElement(tempVin);
					gsl_matrix_free(betaVin);
					gsl_matrix_free(gammaVin);
					retMempoolSet(betaVinDouble,sizeof(double)*ptr->gvNum);
					retMempoolSet(gammaVinDouble,sizeof(double)*ptr->gvNum*ptr->gvNum);
				}
			}
			else
			{
				fprintf(stderr,"voltage source does not connect to gnd\n");
			}
			gsl_matrix_free(tempM);
			gsl_matrix_free(tempAlpha);
			gsl_matrix_free(tempBeta);
			gsl_matrix_free(tempGamma);
			freeCircuitEntryQuad(circuit);
		}
		else if(line[0] == 'M' || line[0] =='m')
		{
			// ========================================================

			MosName *mosName = createMosName();
			setMosName(mosName,line);
			const NonlinearInfo *nonlinearNodeInList = getNonlinearNodeList(ptr->nonlinearNodeList,mosName->mName,mosName->alphaName,mosName->betaName,mosName->gammaName,mosName->configName);
			const NonlinearInfo *data = NULL;

			if(nonlinearNodeInList == NULL)
			{
				MosInfo *mosInfo = createAndSetMosInfo(mosName,ptr->gvNum);
				NonlinearInfo *input = createNonlinearInfo(mosInfo->vdsListSize,mosInfo->vgsListSize,mosInfo->vdsList,mosInfo->vgsList,mosInfo->ivTable,mosInfo->cgs,mosInfo->cgd);
				insertNonlinearNodeList(ptr->nonlinearNodeList,mosName->mName,mosName->alphaName,mosName->betaName,mosName->gammaName,mosName->configName,input);
				freeMosInfo(mosInfo);
				freeNonlinearInfo(input);
				data  = getNonlinearNodeList(ptr->nonlinearNodeList,mosName->mName,mosName->alphaName,mosName->betaName,mosName->gammaName,mosName->configName);
			}
			else
			{
				data = nonlinearNodeInList;
			}
			GControlInfo *newGControlInfo = createGControlInfo(data->vdsListSize,data->vgsListSize,ptr->gvNum);
			newGControlInfo->gate = mosName->gate;
			newGControlInfo->drain = mosName->drain;
			newGControlInfo->source = mosName->source;
			newGControlInfo->vdsList = data->vdsList;
			newGControlInfo->vgsList = data->vgsList;
			freeMosName(mosName);

			const int drain = toZeroBase(newGControlInfo->drain);
			const int gate = toZeroBase(newGControlInfo->gate);
			const int source = toZeroBase(newGControlInfo->source);
			
			newGControlInfo->type = gm;
			newGControlInfo->partialIdsVxs = data->partialIdsVgs;
			if(drain!=-1 && gate!=-1)
			{
				newGControlInfo->sign = -1;
				insertSparseGVarientTable(ptr->gVarientTable,newGControlInfo,drain,gate);
			}
			if(source!=-1)
			{
				newGControlInfo->sign = -1;
				insertSparseGVarientTable(ptr->gVarientTable,newGControlInfo,source,source);	
			}
			if(drain!=-1 && source!=-1)
			{
				newGControlInfo->sign = 1;
				insertSparseGVarientTable(ptr->gVarientTable,newGControlInfo,drain,source);	
			}
			if(gate!=-1 && source!=-1)
			{
				newGControlInfo->sign = 1;
				insertSparseGVarientTable(ptr->gVarientTable,newGControlInfo,gate,source);	
			}
			

			newGControlInfo->type = ro_1;
			newGControlInfo->partialIdsVxs = data->partialIdsVds;
			if(drain!=-1)
			{
				newGControlInfo->sign = -1;
				insertSparseGVarientTable(ptr->gVarientTable,newGControlInfo,drain,drain);	
			}
			if(source!=-1)
			{
				newGControlInfo->sign = -1;
				insertSparseGVarientTable(ptr->gVarientTable,newGControlInfo,source,source);	
			}
			if(drain!=-1 && source!=-1)
			{
				newGControlInfo->sign = 1;
				insertSparseGVarientTable(ptr->gVarientTable,newGControlInfo,drain,source);	
				insertSparseGVarientTable(ptr->gVarientTable,newGControlInfo,source,drain);	
			}
			freeGControlInfo(newGControlInfo);

			// ===== cgd =====
			QuadElement *cgd = createQuadElement(ptr->gvNum);
			copyQuadElement(cgd,data->cgd);
			if(gate!=-1 && drain!=-1)
			{
				decSparseQuadMatrix(ptr->c,cgd,gate,drain);
				decSparseQuadMatrix(ptr->c,cgd,drain,gate);
			}
			if(gate!=-1)
			{
				incSparseQuadMatrix(ptr->c,cgd,gate,gate);
			}
			if(drain!=-1)
			{
				incSparseQuadMatrix(ptr->c,cgd,drain,drain);
			}
			freeQuadElement(cgd);
			// ===== cgs =====
			QuadElement *cgs = createQuadElement(ptr->gvNum);
			copyQuadElement(cgs,data->cgs);
			if(gate!=-1 && source!=-1)
			{
				decSparseQuadMatrix(ptr->c,cgs,gate,source);
				decSparseQuadMatrix(ptr->c,cgs,source,gate);
			}
			if(gate!=-1)
			{
				incSparseQuadMatrix(ptr->c,cgs,gate,gate);
			}
			if(source!=-1)
			{
				incSparseQuadMatrix(ptr->c,cgs,source,source);
			}
			freeQuadElement(cgs);
		}
		else
		{
//			fprintf(stderr,"%s",line);
//			fprintf(stderr,"not defined yet\n");
		}
	}
	// the while loop of the first pass 
	fclose(fp);
//	dumpLinearNodeList(stdout,linearNodeList);
	freeLinearNodeList(linearNodeList);

	// pass 2 , to setup B and the diagonal of A
	QuadElement *maxGQuad = createQuadElement(ptr->gvNum);
	addConstantQuadElement(maxGQuad,maxG,maxGQuad);
	scaleQuadElement(maxGQuad,100,maxGQuad);
	while(!gdsl_queue_is_empty(voltageInNode))
	{
		int *ret = gdsl_queue_remove(voltageInNode);
		const int posNodeIndex = toZeroBase(*ret);
		// set A
		decSparseQuadMatrix(ptr->a,maxGQuad,posNodeIndex,posNodeIndex);
		// set B
		incSparseQuadMatrix(ptr->b,maxGQuad,posNodeIndex,posNodeIndex);
	}
	freeQuadElement(maxGQuad);
	gdsl_queue_free(voltageInNode);

	return ptr;
}
Ejemplo n.º 5
0
int main (void)
{
    int choice = 0;
    gdsl_queue_t q = gdsl_queue_alloc ("Q", alloc_integer, free_integer);
  
    do
	{
	    printf ("\t\tMENU - QUEUE\n\n");
	    printf ("\t1> Put\n");
	    printf ("\t2> Pop\n");
	    printf ("\t3> Get Head\n");
	    printf ("\t4> Get Tail\n");
	    printf ("\t5> Flush\n");
	    printf ("\t6> Search\n");
	    printf ("\t7> Display\n");
	    printf ("\t8> Dump\n");
	    printf ("\t9> XML display\n");
	    printf ("\t0> Quit\n\n" );
	    printf ("\t\tYour choice: " );
	    scanf ("%d", &choice );

	    switch (choice)
		{
		case 1:
		    {
			int value;
			printf ("Enter an integer value: ");
			scanf ("%d", &value);
			gdsl_queue_insert (q, (void*) &value);
		    }
		    break;

		case 2:
		    if (!gdsl_queue_is_empty (q))
			{
			    int* value = (int*) gdsl_queue_remove (q);
			    printf ("Value: %d\n", *value);
			    free_integer (value);
			}
		    else
			{
			    printf ("The queue '%s' is empty\n", gdsl_queue_get_name (q));
			}
		    break;
	  
		case 3:
		    {
			if (!gdsl_queue_is_empty (q)) 
			    {
				int head = *(int*) gdsl_queue_get_head (q);
				printf ("Head = %d\n", head);
			    }
			else
			    {
				printf ("The queue '%s' is empty\n", gdsl_queue_get_name (q));
			    }
		    }
		    break;

		case 4:
		    {
			if (!gdsl_queue_is_empty (q)) 
			    {
				int tail = *(int*) gdsl_queue_get_tail (q);
				printf ("Tail = %d\n", tail);
			    }
			else
			    {
				printf ("The queue '%s' is empty\n", gdsl_queue_get_name (q));
			    }
		    }
		    break;

		case 5:
		    if (gdsl_queue_is_empty (q))
			{
			    printf ("The queue '%s' is empty\n", gdsl_queue_get_name (q));
			}
		    else
			{
			    gdsl_queue_flush (q);
			}
		    break;

		case 6:
		    {
			int pos;
			int* value;
			printf ("Enter an integer value to search an element by its position: ");
			scanf ("%d", &pos);

			value = (int*) gdsl_queue_search_by_position (q, pos);
			if (value != NULL)
			    {
				printf ("Value found at position %d = %d\n", pos, *value);
			    }
		    }
		    break;

		case 7:
		    if (gdsl_queue_is_empty (q))
			{
			    printf ("The queue '%s' is empty\n", gdsl_queue_get_name (q));
			}
		    else
			{
			    printf ("%s = ", gdsl_queue_get_name (q));
			    gdsl_queue_map_forward (q, my_display_integer, NULL);
			}
		    break;

		case 8:
		    gdsl_queue_dump (q, my_write_integer, stdout, NULL);
		    break;

		case 9:
		    gdsl_queue_write_xml (q, my_write_integer, stdout, NULL);
		    break;
		}
	} 
    while (choice != 0);

    gdsl_queue_free (q);

    exit (EXIT_SUCCESS);
}
Ejemplo n.º 6
0
centernode_t * centernode_init (const char *progname, const char *cfgfile)
{
    char filename[100];

    centernode_t *cn = (centernode_t *) calloc(sizeof(centernode_t), sizeof(char));
    if (!cn) abort();

    //Initialize the global mutex.
    pthread_mutex_init(&cn->seqlock, 0);
    pthread_mutex_init(&cn->objlock, 0);
    pthread_mutex_init(&cn->reglock, 0);
    pthread_mutex_init(&cn->evtlock, 0);
    pthread_mutex_init(&cn->glock, 0);
    pthread_mutex_init(&cn->sqllock, 0);

    //Initialiaze and load the config file.
    cn->config = calloc(sizeof(config_t), sizeof(char));
    if (!cn->config) abort();
    config_init(cn->config); /* initialize configuration */
    if (!config_read_file(cn->config, cfgfile)) {
#ifdef CDNDEBUG
        fprintf(stderr, "%s.\n", config_error_text(cn->config));
#endif
        return (free(cn), NULL);
    }
    if (centernode_config(cn))  /* load config */
        return NULL;
    strncpy(cn->confile, cfgfile, sizeof(cn->confile) -1);
    if (archive_init(cn->homepath, progname, ATASR|ATLOG, (cbsink_t)NULL, cn))
        return NULL; /* archive module */
    /*    
          if (mysqldb_init(cn->dbhost, cn->dbname, cn->dbuser, cn->dbpasswd)) // db 
          return (centernode_cleanup(cn), NULL);
          */  
    mongoc_init ();
    cn->MongoNum = cn->threads;
    cn->Mongo = (struct Mongo*)calloc (sizeof(struct Mongo)*cn->MongoNum, sizeof(char));
    int i = 0;
    for (i=0; i<cn->MongoNum; i++) {
        cn->Mongo[i].MongoClient = mongoc_client_new (cn->mongoString);
        cn->Mongo[i].MongoCollection = mongoc_client_get_collection (cn->Mongo[i].MongoClient, "mydb", "mycoll");
        pthread_mutex_init (&cn->Mongo[i].MongoLock, 0);
        if (cn->Mongo[i].MongoClient == NULL )
            abort();
    }
    cn->rdb_conn = (redisContext *) redisConnect(cn->rdb_host, cn->rdb_port);//, cn->rdb_pswd);
    printf("init cn %p rdb %p\n", cn, cn->rdb_conn);
    if (cn->rdb_conn == NULL)
    {
        LOG("WR", "Conn redis er\n");
        abort();
        return NULL;
    }
    pthread_mutex_init (&cn->rdb_lk, 0);
    redis_get_udpinfo(cn, (char **)&cn->udp_addr, &cn->udp_port);


    //Allocate management object
    cn->accesses = gdsl_hash_alloc(NULL, NULL, NULL, (gdsl_key_func_t)keyHash,
            (gdsl_hash_func_t)hashHash, (gdsl_hash_comp_t)compHash, 20000);
    cn->events = gdsl_queue_alloc(NULL, NULL, NULL);
    cn->registration = gdsl_queue_alloc(NULL, NULL, NULL);
    cn->oemconfig_lt = gdsl_list_alloc(NULL, NULL, NULL);
    cn->service_lt = gdsl_list_alloc(NULL,NULL,NULL);

    if (!(cn->tpool = threadpool_init(cn->threads, 4))) 
        return NULL;

    cn->rdbInterval = 0;
    cn->rdbLastNull = time(NULL);
    cn->rdbStatus   = 0;
    //Bind the network interface.
    cnaccess_t *ca = NULL;
    //Connect management server
    for (i=0; i<cn->local_num; ++i) 
    { /* Bind the network devices */
        ca = centernode_server(cn, cn->local[i].host, cn->local[i].port, NT_INETSRV, cn->local[i].isp);
        if (!ca) 
        {    
            return NULL;
        }    
    }  

#if 0
    if ((cn->isservice & 0x02) > 0) {
        for( i=0; i<cn->service_num; ++i )
        {
            ca = centernode_connect(cn, cn->service[i].host, cn->service[i].port, 0, NT_SERVICE_CLIENT, 0);
            if( ca )
            {
                centernode_cmd_service_startup(cn, ca,NULL,i);
                //break;
            }
        }
        if( !ca )
            return (centernode_cleanup(cn), NULL);    
    }
#endif
    sprintf(filename, "%s/%s.pid", cn->homepath, progname);
    FILE *fp = fopen(filename, "w+"); /* version number */
    assert(fp && fprintf(fp, "%u", getpid()) > 0);
    fclose(fp);

    kill(getpid(), SIGUSR1);
#ifdef CDNDEBUG
    LOG("WR", "Service CCN %s startup.\n", cn->nodeid);
#endif

    //if (appinit(cn) != 0)
    //return (centernode_cleanup(cn), NULL);
    return cn;
}