コード例 #1
0
ファイル: edpnet.c プロジェクト: konghan/edp.io
int edpnet_init(){
    edpnet_data_t	*ed = &__edpnet_data;

    if(eio_init(1) != 0){
	log_warn("init eio fail\n");
	return -1;
    }

    INIT_LIST_HEAD(&ed->ed_socks);
    INIT_LIST_HEAD(&ed->ed_servs);

    spi_spin_init(&ed->ed_lock);

    if(mcache_create(sizeof(edp_event_t), sizeof(int), MCACHE_FLAGS_NOWAIT,
		&ed->ed_evcache)){
	spi_spin_fini(&ed->ed_lock);
	eio_fini();

	return -1;
    }

    ed->ed_init = 1;

    return 0;
}
コード例 #2
0
ファイル: mcache.c プロジェクト: Algozjb/xnu
/*
 * Initialize the framework; this is currently called as part of BSD init.
 */
__private_extern__ void
mcache_init(void)
{
	mcache_bkttype_t *btp;
	unsigned int i;
	char name[32];

	ncpu = ml_get_max_cpus();

	mcache_llock_grp_attr = lck_grp_attr_alloc_init();
	mcache_llock_grp = lck_grp_alloc_init("mcache.list",
	    mcache_llock_grp_attr);
	mcache_llock_attr = lck_attr_alloc_init();
	mcache_llock = lck_mtx_alloc_init(mcache_llock_grp, mcache_llock_attr);

	mcache_zone = zinit(MCACHE_ALLOC_SIZE, 256 * MCACHE_ALLOC_SIZE,
	    PAGE_SIZE, "mcache");
	if (mcache_zone == NULL)
		panic("mcache_init: failed to allocate mcache zone\n");
	zone_change(mcache_zone, Z_CALLERACCT, FALSE);

	LIST_INIT(&mcache_head);

	for (i = 0; i < sizeof (mcache_bkttype) / sizeof (*btp); i++) {
		btp = &mcache_bkttype[i];
		(void) snprintf(name, sizeof (name), "bkt_%d",
		    btp->bt_bktsize);
		btp->bt_cache = mcache_create(name,
		    (btp->bt_bktsize + 1) * sizeof (void *), 0, 0, MCR_SLEEP);
	}

	PE_parse_boot_argn("mcache_flags", &mcache_flags, sizeof (mcache_flags));
	mcache_flags &= MCF_FLAGS_MASK;

	mcache_audit_cache = mcache_create("audit", sizeof (mcache_audit_t),
	    0, 0, MCR_SLEEP);

	mcache_reap_interval = 15 * hz;
	mcache_applyall(mcache_cache_bkt_enable);
	mcache_ready = 1;
}