Beispiel #1
0
S32	dInitRADIUSProc(stMEMSINFO **pstMEMSINFO, stHASHOINFO **pstHASHOINFO, stTIMERNINFO **pstTIMERNINFO)
{
	int 	dRet;

	SetUpSignal();

	if((*pstMEMSINFO = nifo_init_zone((U8*)"A_RADIUS", SEQ_PROC_A_RADIUS, FILE_NIFO_ZONE)) == NULL) {
		log_print(LOGN_CRI, LH"FAILED IN nifo_init NULL", LT);
		return -1;
	}

	if((gpCIFO = gifo_init_group(FILE_CIFO_CONF, FILE_GIFO_CONF)) == NULL ){
		log_print(LOGN_CRI, LH"FAILED IN gifo_init_group, cifo=%s, gifo=%s",
			LT, FILE_CIFO_CONF, FILE_GIFO_CONF);
		return -2;
	}

	gACALLCnt = get_block_num(FILE_MC_INIT, "A_CALL");
	log_print(LOGN_INFO, "INIT., A_CALL ProcCount[%d]", gACALLCnt);

	if( shm_init(S_SSHM_FLT_INFO, DEF_FLT_INFO_SIZE, (void**)&flt_info) < 0 ){
		log_print(LOGN_CRI, LH"FAILED IN shm_init(FLT_INFO)", LT);
		return -3;
	}

	/**<	INIT HASHO	**/
	if((*pstHASHOINFO = hasho_init(S_SSHM_RADIUS, DEF_HKEY_TRANS_SIZE, DEF_HKEY_TRANS_SIZE, DEF_HDATA_TRANS_SIZE, RADIUS_TRANS_CNT, 0)) == NULL) {
		log_print(LOGN_CRI, "[%s][%s.%d] hasho_init NULL", __FILE__, __FUNCTION__, __LINE__);
		return -4;
	}

	/**<	INIT TIMER **/
	if((*pstTIMERNINFO = timerN_init(RADIUS_TRANS_CNT, DEF_TDATA_TRANS_TIMER_SIZE)) == NULL) {
		log_print(LOGN_CRI, "[%s][%s.%d] timerN_init NULL", __FILE__, __FUNCTION__, __LINE__);
		return -5;
	}
	
	vRADIUSTimerReConstruct(*pstHASHOINFO, *pstTIMERNINFO);

	/* TRACE INFO */
	if( shm_init(S_SSHM_TRACE_INFO, st_TraceList_SIZE, (void**)&pstTRACE) < 0 ){
		log_print(LOGN_CRI, LH"FAILED IN shm_init(TRACE_INFO)", LT);
		return -6;
	}

	/* Read IP Pool for RADIUS Signal */
	dRet = dReadIPPool();
	if(dRet < 0)
	{
		log_print(LOGN_CRI, "[%s.%d] ERROR dReadIPPool dRet:%d",	__FUNCTION__, __LINE__, dRet);
		return -7;
	}

	return 0;
}
Beispiel #2
0
td_vbd_t*
tapdisk_vbd_create(uint16_t uuid)
{
    td_vbd_t *vbd;

    vbd = calloc(1, sizeof(td_vbd_t));
    if (!vbd) {
        EPRINTF("failed to allocate tapdisk state\n");
        return NULL;
    }

    shm_init(&vbd->rrd.shm);

    vbd->uuid        = uuid;
    vbd->req_timeout = TD_VBD_REQUEST_TIMEOUT;

    INIT_LIST_HEAD(&vbd->images);
    INIT_LIST_HEAD(&vbd->new_requests);
    INIT_LIST_HEAD(&vbd->pending_requests);
    INIT_LIST_HEAD(&vbd->failed_requests);
    INIT_LIST_HEAD(&vbd->completed_requests);
    INIT_LIST_HEAD(&vbd->next);
    INIT_LIST_HEAD(&vbd->rings);
    INIT_LIST_HEAD(&vbd->dead_rings);
    tapdisk_vbd_mark_progress(vbd);

    return vbd;
}
Beispiel #3
0
/**
 * ipc_init - initialise ipc subsystem
 *
 * The various sysv ipc resources (semaphores, messages and shared
 * memory) are initialised.
 *
 * A callback routine is registered into the memory hotplug notifier
 * chain: since msgmni scales to lowmem this callback routine will be
 * called upon successful memory add / remove to recompute msmgni.
 */
static int __init ipc_init(void)
{
	sem_init();
	msg_init();
	shm_init();
	return 0;
}
Beispiel #4
0
int
td_metrics_nbd_start(stats_t *nbd_stats, int minor)
{
    int err = 0;

    if(!td_metrics.path || nbd_stats->shm.path != NULL)
        goto out;

    shm_init(&nbd_stats->shm);

    err = asprintf(&nbd_stats->shm.path, TAPDISK_METRICS_NBD_PATHF, td_metrics.path, minor);
    if(unlikely(err == -1)){
        err = errno;
        EPRINTF("failed to allocate memory to store NBD metrics path: %s\n",strerror(err));
        nbd_stats->shm.path = NULL;
        goto out;
    }

    nbd_stats->shm.size = PAGE_SIZE;

    err = shm_create(&nbd_stats->shm);
    if (unlikely(err)) {
        err = errno;
        EPRINTF("failed to create NBD shm ring stats file: %s\n", strerror(err));
        goto out;
   }
    nbd_stats->stats = nbd_stats->shm.mem;
out:
    return err;
}
Beispiel #5
0
int
td_metrics_blktap_start(int minor, stats_t *blktap_stats)
{

    int err = 0;

    if(!td_metrics.path)
        goto out;

    shm_init(&blktap_stats->shm);

    err = asprintf(&blktap_stats->shm.path, TAPDISK_METRICS_BLKTAP_PATHF, td_metrics.path, minor);
    if(unlikely(err == -1)){
        err = errno;
        EPRINTF("failed to allocate memory to store blktap metrics path: %s\n",strerror(err));
        blktap_stats->shm.path = NULL;
        goto out;
    }

    blktap_stats->shm.size = PAGE_SIZE;

    err = shm_create(&blktap_stats->shm);
    if (unlikely(err)) {
        err = errno;
        EPRINTF("failed to create blktap shm ring stats file: %s\n", strerror(err));
        goto out;
    }
    blktap_stats->stats = blktap_stats->shm.mem;
out:
    return err;
}
Beispiel #6
0
int
td_metrics_vbd_start(int domain, int id, stats_t *vbd_stats)
{
    int err = 0;

    if(!td_metrics.path)
        goto out;

    shm_init(&vbd_stats->shm);

    err = asprintf(&vbd_stats->shm.path, TAPDISK_METRICS_VBD_PATHF,
            td_metrics.path, domain, id);
    if(unlikely(err == -1)){
        err = errno;
        EPRINTF("failed to allocate memory to store vbd metrics path: %s\n",
            strerror(err));
        vbd_stats->shm.path = NULL;
        goto out;
    }

    vbd_stats->shm.size = PAGE_SIZE;

    err = shm_create(&vbd_stats->shm);
    if (unlikely(err)) {
        err = errno;
        EPRINTF("failed to create shm ring stats file: %s\n", strerror(err));
        goto out;
   }
    vbd_stats->stats = vbd_stats->shm.mem;
out:
    return err;

}
Beispiel #7
0
//./a.out filename
int main(int argc, const char *argv[])
{
	int shm_id;
	int sem_id;
	char *pmsg;
	int create_flag = 0;

	if(argc < 2){
		fprintf(stderr,"Usage : %s <filename>\n",argv[0]);
		exit(EXIT_FAILURE);
	}
	
	shm_id = shm_init(argv[1],(char **)&pmsg);
	sem_id = init_sems(argv[1],2,&create_flag);

	while(1){
		P(sem_id,0);
		printf("%s\n",pmsg);
		V(sem_id,1);

		if(strncmp(pmsg,"quit",4) == 0){
			break;
		}
	}
	
	if(create_flag){
		usleep(500);
		delete_sems(sem_id);
	}

	
	return 0;
}
Beispiel #8
0
int main(int ac, char **av)
{
    int	i;
    struct head *h;
    struct list *l;

    if (shm_init(SHM_FILE, setup) < 0) {
	perror("shm_init");
	exit(1); }
    h = shm_global();
    if (!h) {
	perror("shm_global");
	exit(1); }
    for (i = 1; i < ac; i++) {
	if (!(l = shm_malloc(sizeof(struct list)))) {
	    perror("shm_malloc");
	    exit(1); }
	l->next = 0;
	if (!(l->data = shm_malloc(strlen(av[i]) + 1))) {
	    perror("shm_malloc");
	    exit(1); }
	strcpy(l->data, av[i]);
	*h->tail = l;
	h->tail = &l->next; }
    for (l = h->head; l; l = l->next) {
	printf("%s\n", l->data); }
    return 0;
}
Beispiel #9
0
int main(void) {
#else
int main(int argc, char **argv) {
#endif

#ifdef __patmos__
  // nothing special to initialize
#else /* __patmos__ */
  core_id = strtol(argv[1], NULL, 0);
  // initialize MPBs
  shm_init();
#endif /* __patmos__ */

  if (core_id == 0) {
    master();
  } else {
    slave();
  }

#ifdef __patmos__
  // nothing to clean up
#else /* __patmos__ */
  shm_clean();
#endif /* __patmos__ */

  return 0;

}
Beispiel #10
0
int main(void)
{
    volatile SAMPLE values[NR_CHANNELS];
    volatile uint16_t seqno = 0;
    volatile uint16_t count = 0;
    int idle, channel;

    ocp_init();
    shm_init();

    WR_MAGIC( 0x0ADCDA8A );

    WR_SEQNO( seqno );
    while (1)
    {
        // Read ADC data into values
        values[0] = adc_read( 0, 0, 0 );
        values[1] = adc_read1( 0, 0, 0 );
        values[2] = adc_read2( 0, 0, 0 );
        values[3] = adc_read3( 0, 0, 0 );

        // Write into shared memory
        for ( channel = 0; channel < NR_CHANNELS; ++channel ) {
            WR_DATA( seqno, channel, count, values[channel] );
        }

        // Increment and update sample counts
        count++;
        WR_COUNT( count );

        if ( count >= SAMPLES_PER_MSG ) {
            count = 0;
            WR_COUNT( count );

            seqno++;
            WR_SEQNO( seqno );

            // Signal to host that data is ready for reading
            for ( idle=0; idle < 2; ++idle ) {
                seqno = seqno;
            }
            generate_host_interrupt( PRU0_ARM_DONE_INTERRUPT + 16 );
        }

        // Idle some until time for the next sample
        //
        // We want a delay of abuot 100us (10kHz) between samples. Since
        // the PRU runs at 200MHz (5ns per op), we want 20000 ops for
        // an approximate delay of 100us. Since one iteration is
        // approximately 10 assembly instructions, counting up to 2000
        // for now.
        for ( idle=0; idle < 2000; ++idle ) {
            seqno = seqno;
        }
    }

    __halt();

    return 0;
}
Beispiel #11
0
/** D.1 * Definition of Functions **************************************************/
int dInitProc(void)
{
	int dRet;

	if((gpMEMSINFO = nifo_init_zone((U8*)"S_MNG", SEQ_PROC_S_MNG, FILE_NIFO_ZONE)) == NULL ){
        log_print(LOGN_CRI, LH"FAILED IN nifo_init_zone NULL", LT);
        return -1;
    }

    if((gpCIFO = gifo_init_group(FILE_CIFO_CONF, FILE_GIFO_CONF)) == NULL ){
        log_print(LOGN_CRI, LH"FAILED IN gifo_init_group, cifo=%s, gifo=%s",
            LT, FILE_CIFO_CONF, FILE_GIFO_CONF);
        return -2;
    }

	if( shm_init(S_SSHM_TRACE_INFO, sizeof(st_TraceList), (void**)&trace_tbl) < 0 ){
		log_print(LOGN_CRI, LH"FAILED IN shm_init(TRACE_TBL=%d)", LT, S_SSHM_TRACE_INFO);
		return -3;
	}

	if( shm_init(S_SSHM_KEEPALIVE, DEF_KEEPALIVE_TAF_SIZE, (void**)&keepalive) < 0 ){
		log_print(LOGN_CRI, LH"FAILED IN shm_init(KEEPALIVE=%d)", LT, S_SSHM_KEEPALIVE);
		return -4;
	}

	if( shm_init(S_SSHM_FLT_INFO, DEF_FLT_INFO_SIZE, (void**)&flt_info) < 0 ){
		log_print(LOGN_CRI, LH"FAILED IN shm_init(FLT_INFO=%d)", LT, S_SSHM_FLT_INFO);
		return -5;
	}

	/* timer setting */
	if( (dRet = dReadTimerFile(&flt_info->stTimerInfo)) < 0){
		log_print(LOGN_CRI, LH"ERROR IN dReadTimerFile() dRet[%d]", LT, dRet);
	}
	
	Init_Signal();

	if( (dRet = dInit_Info()) < 0) {
		log_print(LOGN_CRI, LH"ERROR IN dInit_Info() dRet[%d]", LT, dRet);
		return -6;
	}

	flt_info->stHdrLogShm.sHdrCapFlag	= HEADER_LOG_CAPTURE; /* TCP HDR Option Pre Setting*/
	return 0;
}
Beispiel #12
0
/**
Initializes this process.

@param first Whether shared resources should also be initialized.
@return 0 if successful and -1 otherwise.
**/
int init(const bool first) {
	/*
	Initializes the configuration.
	*/
	if (cfg_init_lib() == -1) {
		return -1;
	}

	/*
	Initializes the functions.
	*/
	if (lib_init() == -1) {
		return -1;
	}

	/*
	Initializes the save-quit-load emulation.
	*/
	if (cfg_emulate_sql) {
		if (asm_inject(&save_quit_load) == -1) {
			return -1;
		}
	}
	else {
		if (asm_inject(NULL) == -1) {
			return -1;
		}
	}

	/*
	Initializes the shared memory segment.
	*/
	if (first) {
		if (shm_init() == -1) {
			return -1;
		}
	}
	if (shm_attach() == -1) {
		return -1;
	}

	/*
	Sets variables that should be automatic.
	*/
	record.timestamp = cfg_timestamp;
	options.play_on = cfg_play_instantly;
	options.play_paused = FALSE;
	options.gui_menu = FALSE;
	options.gui_info = FALSE;
	options.gui_overlay = FALSE;
	options.gui_condensed = FALSE;
	options.gui_hidden = FALSE;
	options.roll_on = FALSE;
	options.roll_cataloged = FALSE;

	return 0;
}
Beispiel #13
0
/**
 *	Implement func.
 */
int Init_TraceShm( )
{
    int     dRet;
    if( (dRet = shm_init(S_SSHM_TRACE_INFO, st_TraceList_SIZE, (void**)&pstTRACE)) < 0) {
        log_print(LOGN_CRI, "FAILED IN shm_init(TRACE LIST=%d)", S_SSHM_TRACE_INFO);
        return -1;
    }
    return 0;
}
Beispiel #14
0
static int __init ipc_init(void)
{
	sem_init();
	msg_init();
	shm_init();
	register_hotmemory_notifier(&ipc_memory_nb);
	register_ipcns_notifier(&init_ipc_ns);
	return 0;
}
Beispiel #15
0
static int __init ipc_init(void)
{
	sem_init();
	msg_init();
	shm_init();
	hotplug_memory_notifier(ipc_memory_callback, IPC_CALLBACK_PRI);
	register_ipcns_notifier(&init_ipc_ns);
	return 0;
}
Beispiel #16
0
int attach_init() {
	char *buf, buf2[1024], *t2, *t3;
	int n;
	srand(time(0)*2+getpid());
	chdir(BBSHOME);
	printf("Content-Type: application/octet-stream \n");
	printf("Content-Disposition: attachment; filename=tshirt.csv \n\n", CHARSET);
	n=atoi(getsenv("CONTENT_LENGTH"));
	if(n>5000000) n=5000000;
	buf=calloc(n+1, 1);
	if(buf==0) http_fatal("memory overflow");
	fread(buf, 1, n, stdin);
	buf[n]=0;
	t2=strtok(buf, "&");
	while(t2) {
		t3=strchr(t2, '=');
		if(t3!=0) {
			t3[0]=0;
			t3++;
			__unhcode(t3);
			parm_add(trim(t2), t3);
		}
		t2=strtok(0, "&");
	}
	strsncpy(buf2, getsenv("QUERY_STRING"), 1024);
	t2=strtok(buf2, "&");
	while(t2) {
		t3=strchr(t2, '=');
		if(t3!=0) {
			t3[0]=0;
			t3++;
			__unhcode(t3);
			parm_add(trim(t2), t3);
		}
		t2=strtok(0, "&");
	}
	strsncpy(buf2, getsenv("HTTP_COOKIE"), 1024);
	t2=strtok(buf2, ";");
	while(t2) {
		t3=strchr(t2, '=');
		if(t3!=0) {
			t3[0]=0;
			t3++;
			parm_add(trim(t2), t3);
		}
		t2=strtok(0, ";");
	}
	strsncpy(fromhost, getsenv("REMOTE_ADDR"), 32);
	seteuid(BBSUID);
	if(geteuid()!=BBSUID) http_fatal("uid error.");
	shm_init();
	loginok=user_init(&currentuser, &u_info);
        if(u_info==0){
             u_info=&guest;
        }
  return;
}
Beispiel #17
0
void scanmain(void)
{
	struct portinfo *pi;
	int ports = 0, i;
	int childpid;

	pi = shm_init(sizeof(*pi)*(MAXPORT+2));
	pi[MAXPORT+1].active = 0; /* hold the average RTT */
	if (pi == NULL) {
		fprintf(stderr, "Unable to create the shared memory");
		shm_close(pi);
		exit(1);
	}
	for (i = 0; i <= MAXPORT; i++) {
		pi[i].active = 0;
		pi[i].retry = opt_scan_probes;
	}
	if (parse_ports(pi, opt_scanports)) {
		fprintf(stderr, "Ports syntax error for scan mode\n");
		shm_close(pi);
		exit(1);
	}
	for (i = 0; i <= MAXPORT; i++) {
		if (!pi[i].active)
			pi[i].retry = 0;
	}
	for (i = 0; i <= MAXPORT; i++)
		ports += pi[i].active;
	fprintf(stderr, "%d ports to scan, use -V to see all the replies\n", ports);
	fprintf(stderr, "+----+-----------+---------+---+-----+-----+-----+\n");
	fprintf(stderr, "|port| serv name |  flags  |ttl| id  | win | len |\n");
	fprintf(stderr, "+----+-----------+---------+---+-----+-----+-----+\n");

	/* We are ready to fork, the input and output parts
	 * are separated processes */
	if ((childpid = fork()) == -1) {
		perror("fork");
		shm_close(pi);
		exit(1);
	}
	/* The parent is the receiver, the child the sender.
	 * it's almost the same but this way is simpler
	 * to make it working in pipe with other commands like grep. */
	if (childpid) { /* parent */
		Signal(SIGCHLD, do_exit);
		Signal(SIGINT, do_exit);
		Signal(SIGTERM, do_exit);
		receiver(pi, childpid);
	} else {	/* child */
		Signal(SIGINT, do_exit);
		Signal(SIGTERM, do_exit);
		sender(pi);
	}
	/* UNREACHED */
}
Beispiel #18
0
int InitVersionShm(void)
{
    int	dRet;
    if( (dRet = shm_init(S_SSHM_VERSION, sizeof(st_Version), (void**)&version)) < 0 ) {
        fprintf(stderr,"%s.%d:%s FAILED IN shm_init(S_SSHM_VERSION[0x%04X], dRet=%d) errno=%d:%s\n",
                __FILE__,__LINE__,__FUNCTION__,S_SSHM_VERSION,dRet,errno,strerror(errno));
        return -1;
    }

    return 0;
}
Beispiel #19
0
int main (int argc, char ** argv) {
    w=windowcf_create(SPECTRUM_FFT_LENGTH);
    wchA = windowcf_create(TRACK_LENGTH);
    wchB = windowcf_create(TRACK_LENGTH);
    wchC = windowcf_create(TRACK_LENGTH);

    wchA_filtered = windowcf_create(TRACK_LENGTH);
    wchB_filtered = windowcf_create(TRACK_LENGTH);
    wchC_filtered = windowcf_create(TRACK_LENGTH);

    wmag_buffer = windowf_create(TRACK_LENGTH);

    nco = nco_crcf_create(LIQUID_NCO);
    std::cout << "hydromath daemon is beginning..." << std::endl;
    std::cout << "NOTE: if this is symhydromath you must pass in a matfile" << std::endl;

    std::cout << argv[1] << std::endl;
    shm_init();
    shm_getg(hydrophones_results_track, shm_results_track);
    shm_getg(hydrophones_results_spectrum, shm_results_spectrum);

    //shm_results_track.tracked_ping_count=0;
    shm_results_track.tracked_ping_time=0; 


    if (argc > 1) {
        udp_init(argv[1]);
    }
    else {
        udp_init("");
    }
    //std::thread track_thread(direction_loop);
    //
    //std::thread spectrum_thread(spectrum_loop);
    track_sample_idx = 0;  

    while (loop(&spt) == 0) {
        shm_getg(hydrophones_settings, shm_settings);
        for (int i = 0; i < 3*CHANNEL_DEPTH; i+=3) {
            windowcf_push(w,    std::complex<float>(spt.data[i+1],0)); //This uses channel B

            windowcf_push(wchA, std::complex<float>(spt.data[i],0));
            windowcf_push(wchB, std::complex<float>(spt.data[i+1],0));
            windowcf_push(wchC, std::complex<float>(spt.data[i+2],0));
        }
        current_sample_count+=CHANNEL_DEPTH;        
        do_spectrum();
        do_track();
    }

    printf("loop done %li =ci\n",current_sample_count/CHANNEL_DEPTH);
    return 0;
}
Beispiel #20
0
/**
 * ipc_init - initialise ipc subsystem
 *
 * The various sysv ipc resources (semaphores, messages and shared
 * memory) are initialised.
 *
 * A callback routine is registered into the memory hotplug notifier
 * chain: since msgmni scales to lowmem this callback routine will be
 * called upon successful memory add / remove to recompute msmgni.
 */
static int __init ipc_init(void)
{
	int err_sem, err_msg;

	err_sem = sem_init();
	WARN(err_sem, "ipc: sysv sem_init failed: %d\n", err_sem);
	err_msg = msg_init();
	WARN(err_msg, "ipc: sysv msg_init failed: %d\n", err_msg);
	shm_init();

	return err_msg ? err_msg : err_sem;
}
Beispiel #21
0
int
updatelastpost(char *board)
{
	struct boardmem *bptr;
	if (shm_bcache == NULL)
		shm_init();
	bptr = getbcache(board);
	if (bptr == NULL)
		return -1;
	return getlastpost(bptr->header.filename, &bptr->lastpost,
			   &bptr->total);
}
Beispiel #22
0
int dInit_IPC(void)
{
	int		dRet;

	/*
		trace_tbl의 shared memory가 새로 만들어질 경우, 이전 trace_tbl 내용을 파일로부터 읽어온다.
		 - Writer: Han-jin Park
		 - DAte: 2008.09.19
	*/
	if( (dRet = shm_init(S_SSHM_TRACE_INFO, sizeof(st_TraceList), (void**)&trace_tbl)) < 0)
	{
		log_print(LOGN_CRI, LH"ERROR IN Init_shm(S_SSHM_TRACE_INFO) dRet[%d]", LT, dRet);
		return -1;
	}
	else if(dRet == SHM_CREATE)
	{
		memset(trace_tbl, 0x00, sizeof(st_TraceList));
		if( (dRet = dGetTraceTblList(FILE_TRACE_TBL, trace_tbl)) < 0)
		{
			if(dRet == -1)
				log_print(LOGN_CRI, LH"FILE(%s) IS NOT FOUND", LT, FILE_TRACE_TBL);
			else
			{
				log_print(LOGN_CRI, LH"ERROR IN dGetTraceTblList(%s) dRet[%d]", LT, FILE_TRACE_TBL, dRet);
				return -10;
			}
		}
		else
			log_print(LOGN_DEBUG,LH"SUCCEED a dGetTraceTblList(%s)", LT, FILE_TRACE_TBL);
	}

	/* Model 관리 Hash1 Table */
    if( (pMODELINFO1 = hasho_init(S_SSHM_MODELHASH1, RPPISESS_KEY_SIZE, RPPISESS_KEY_SIZE, HDATA_MODEL_SIZE, HASH_MODELINFO_CNT, 0)) == NULL)
	{
        log_print(LOGN_CRI, LH"ERROR IN hasho_init(pMODELINFO1[%p])", LT, pMODELINFO1);
        return -11;
    }

	if( (pMODELINFO2 = hasho_init(S_SSHM_MODELHASH2, RPPISESS_KEY_SIZE, RPPISESS_KEY_SIZE, HDATA_MODEL_SIZE, HASH_MODELINFO_CNT, 0)) == NULL)
	{
        log_print(LOGN_CRI, LH"ERROR IN hasho_init(pMODELINFO2[%p])", LT, pMODELINFO2);
        return -12;
    }

	/* IRM 관리 Hash Table */
	if( (pIRMINFO = hasho_init(0, DEF_IMSIHASH_KEY_SIZE, DEF_IMSIHASH_KEY_SIZE, DEF_IMSIHASH_DATA_SIZE, DEF_IRMHASH_CNT, 0)) == NULL)
	{
		log_print(LOGN_CRI, LH"ERROR IN hasho_init(pIRMINFO[%p])", LT, pIRMINFO);
		return -13;
	}

	return 0;
} /* end of dInit_IPC */
Beispiel #23
0
int dacq_start(char *server, char *tracker, char *port, char *elopt,
	       char *elcam, char *swapxy, char *usbjs)
{
  int shmid, i;

  if ((shmid = shmget((key_t)SHMKEY, sizeof(DACQINFO), 0666 | IPC_CREAT)) < 0) {
    if (errno == EINVAL) {
      fprintf(stderr, "dacq_start: SHM buffer's changed size.\n");
      fprintf(stderr, "dacq_start: run pypekill and start again\n");
      return(0);
    } else {
      perror("shmget");
      fprintf(stderr, "dacq_start: kernel compiled with SHM/IPC?\n");
      return(0);
    }
  }

  if ((dacq_data = shmat(shmid, NULL, 0)) == NULL) {
    perror("shmat");
    fprintf(stderr, "dacq_start: kernel compiled with SHM/IPC?\n");
    return(0);
  }

  if ((semid = psem_init(SEMKEY)) < 0) {
    perror("psem_init");
    fprintf(stderr, "dacq_start: can't init semaphore\n");
    return(0);
  } else {
    /* start semaphore off at value of 1 */
    if (psem_set(semid, 1) < 0) {
      perror("psem_init");
      return(-1);
    }
  }

  shm_init();			/* initialize shm block */
  signal(SIGCHLD, dacq_sigchld_handler);
  if ((server_pid = fork()) == 0) {
    /* child becomes dac subsystem server */
    execlp(server, server, tracker, port, elopt, elcam, swapxy, usbjs, NULL);
    perror(server);
    exit(1);
  } else {
    /* parent waits for server to become ready */
    do {
      LOCK(semid);
      i = dacq_data->das_ready;
      UNLOCK(semid);
      usleep(100);
    } while (i == 0);
  }
  return(1);
}
static void
shm_process_commands(int do_monitor, int delay)
{
    SynapticsSHM *synshm = NULL;

    synshm = shm_init();
    if (!synshm)
        return;

    if (do_monitor)
        shm_monitor(synshm, delay);
}
Beispiel #25
0
/* Allocate and initialize walreceiver-related shared memory */
void
wal_recv_shm_init(void)
{
	bool found;

	WalRcv = (WalRcvData *) shm_init("Wal Receiver Ctl", WalRcvShmemSize(), &found);
	if (!found) {
		/* First time through, so initialize */
		pg_memset(WalRcv, 0, WalRcvShmemSize());
		WalRcv->walRcvState = WALRCV_STOPPED;
		spin_init(&WalRcv->mutex);
	}
}
Beispiel #26
0
//----------------------------------------------------------------------------------------------------//
//  @func - xilkernel_init
//! @desc
//!   Initialize the system - This function is called at the start of system.
//!   It initializes the system.
//!   - Initializes the process vector table.
//!   - Creates the Idle process (pid - 0).
//!   - Creates the static set of processes.
//! @return
//!   - Nothing.
//----------------------------------------------------------------------------------------------------//
void xilkernel_init(void)
{
    unsigned int i = 0 ;

    DBG_PRINT("XMK: Initializing Hardware.\r\n");
    hw_init();                                                  // Do hardware specific initialization

    DBG_PRINT("XMK: System initialization.\r\n");
    for( ; i < MAX_PROCESS_CONTEXTS; i++ ) {
        ptable[i].is_allocated = 0 ;
        ptable[i].pcontext.isrflag = 0;
    }

#ifdef MB_XILKERNEL
    kernel_sp = (void*)((unsigned int)&_stack + SSTACK_PTR_ADJUST);
#elif defined(PPC_XILKERNEL)
    kernel_sp = (void*)((unsigned int)&__stack + SSTACK_PTR_ADJUST);
#endif
    readyq_init();

#ifdef CONFIG_PTHREAD_SUPPORT
    pthread_init();
#endif
#ifdef CONFIG_SEMA
    sem_heap_init();
#endif
#ifdef CONFIG_MSGQ
    msgq_init();
#endif
#ifdef CONFIG_SHM
    shm_init();
#endif
#ifdef CONFIG_BUFMALLOC
    bufmalloc_init ();
#endif

    init_idle_task ();

#ifdef CONFIG_STATIC_ELF_PROCESS_SUPPORT
    se_process_init() ;                                           // Create statically specified separate executable processes
#endif

#ifdef CONFIG_STATIC_PTHREAD_SUPPORT
    kb_pthread_init ();                                           // Create statically specified kernel bundled threads
#endif

#ifdef CONFIG_TIME
    soft_tmr_init ();
#endif
}
Beispiel #27
0
int Init_GREEntry_Shm(void)
{
	UINT    uiShmSESSKey;

	uiShmSESSKey = S_SSHM_A11_GREENTRY0 + PROCNO;

	log_print( LOGN_CRI, "INIT A11_GREENTRY SHM KEY:%u PROCNO:%u", uiShmSESSKey, PROCNO );

	if( shm_init(uiShmSESSKey, sizeof(GREENTRY_TABLE), (void**)&greentry_tbl) < 0 ){
        log_print(LOGN_CRI, "FAILED IN shm_init(A11 SHM Key=%d)", uiShmSESSKey);
        return -1;
    }
	return 1;
}
Beispiel #28
0
int Init_A11_PSESS( )
{
	UINT	uiShmSESSKey;

	uiShmSESSKey = S_SSHM_A11_PSESS0 + PROCNO;

	log_print( LOGN_CRI, "INIT A11 SHM KEY:%u PROCNO:%u", uiShmSESSKey, PROCNO );

	if( shm_init(uiShmSESSKey, sizeof(SESS_TABLE), (void**)&psess_tbl) < 0 ){
        log_print(LOGN_CRI, "FAILED IN shm_init(A11 SHM Key=%d)", uiShmSESSKey);
        return -1;
    }

    return 1;
}
Beispiel #29
0
S32	dInitDIAMETERProc(stMEMSINFO **pstMEMS, stHASHOINFO **pstHASHO, stTIMERNINFO **pstTIMER)
{
    int 	dRet;

    SetUpSignal();

    if((*pstMEMS = nifo_init_zone((U8*)"A_DIAMETER", SEQ_PROC_A_DIAMETER, FILE_NIFO_ZONE)) == NULL) {
        log_print(LOGN_CRI, LH"FAILED IN nifo_init NULL", LT);
        return -1;
    }

    if((gpCIFO = gifo_init_group(FILE_CIFO_CONF, FILE_GIFO_CONF)) == NULL ) {
        log_print(LOGN_CRI, LH"FAILED IN gifo_init_group, cifo=%s, gifo=%s",
                  LT, FILE_CIFO_CONF, FILE_GIFO_CONF);
        return -2;
    }

    gACALLCnt = get_block_num(FILE_MC_INIT, "A_CALL");
    log_print(LOGN_INFO, "INIT., A_CALL ProcCount[%d]", gACALLCnt);

    if( shm_init(S_SSHM_FLT_INFO, DEF_FLT_INFO_SIZE, (void**)&flt_info) < 0 ) {
        log_print(LOGN_CRI, LH"FAILED IN shm_init(FLT_INFO)", LT);
        return -3;
    }


    /**<  INIT HASHO  **/
    if((*pstHASHO = hasho_init(S_SSHM_DIAMETER, DEF_HKEY_TRANS_SIZE, DEF_HKEY_TRANS_SIZE, DEF_HDATA_TRANS_SIZE, DIAMETER_TRANS_CNT, 0)) == NULL) {
        log_print(LOGN_CRI, "[%s][%s.%d] hasho_init NULL", __FILE__, __FUNCTION__, __LINE__);
        return -4;
    }

    /**<  INIT TIMER **/
    if((*pstTIMER = timerN_init(DIAMETER_TRANS_CNT, DEF_TDATA_TRANS_TIMER_SIZE)) == NULL) {
        log_print(LOGN_CRI, "[%s][%s.%d] timerN_init NULL", __FILE__, __FUNCTION__, __LINE__);
        return -5;
    }

    vDIATRANSTimerReConstruct(*pstHASHO, *pstTIMER);

    /* TRACE INFO */
    if( (dRet = Init_TraceShm()) < 0) {
        log_print( LOGN_CRI, "[%s.%d] ERROR IN Init_TraceShm dRet:%d", __FUNCTION__, __LINE__, dRet );
        return -6;
    }

    return 0;
}
PACL_LIST acl_init(){
	_SHM_LOCKDEF lockdef;
	ZeroMemory(&acl_shm,sizeof(acl_shm));
	acl_shm.len = 2048*sizeof(ACL_ENTRY)+sizeof(int);
	_tcscpy(acl_shm.filename,SHM_ACL_NAME);
	_tcscpy(lockdef.lockname,SHM_LOCK_NONE);
	_tcscpy(lockdef.eackname,SHM_LOCK_NONE);
	_tcscpy(lockdef.esndname,SHM_LOCK_NONE);
	if(FAILED(shm_init(&acl_shm,&lockdef))){
		DEBUG_PRINT_LASTERROR("[ACL]Fail to open shared memory: %s\n");
		return NULL;
	}
	PACL_LIST ret = (PACL_LIST)acl_shm.data;
	InitializeSRWLock(&ret->lock);
	return ret;
}