• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ spinlock_init函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中spinlock_init函数的典型用法代码示例。如果您正苦于以下问题:C++ spinlock_init函数的具体用法?C++ spinlock_init怎么用?C++ spinlock_init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了spinlock_init函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: spinlock_init

/*
 * udp_instance_alloc()
 */
struct udp_instance *udp_instance_alloc(struct ip_instance *ii)
{
	struct udp_instance *ui;
	struct ip_client *ic;

	ui = (struct udp_instance *)membuf_alloc(sizeof(struct udp_instance), NULL);
	ui->ui_client_attach = udp_client_attach;
	ui->ui_client_detach = udp_client_detach;
	ui->ui_client_list = NULL;
	spinlock_init(&ui->ui_lock, 0x24);

	/*
	 * Attach this protocol handler to the IP stack.
	 */
	ic = ip_client_alloc();
	ic->ic_protocol = 0x11;
	ic->ic_recv = udp_recv_netbuf;
	ic->ic_recv_icmp = NULL;
	ic->ic_instance = ui;
	udp_instance_ref(ui);
	
	ui->ui_server = ii->ii_ip_client_attach(ii, ic);
	ip_client_deref(ic);
	
	return ui;
}
开发者ID:Numeromancer,项目名称:liquorice,代码行数:29,代码来源:udp.c


示例2: sem_create

struct semaphore *
sem_create(const char *name, int initial_count)
{
    struct semaphore *sem;

    KASSERT(initial_count >= 0);

    sem = kmalloc(sizeof(struct semaphore));
    if (sem == NULL) {
        return NULL;
    }

    sem->sem_name = kstrdup(name);
    if (sem->sem_name == NULL) {
        kfree(sem);
        return NULL;
    }

    sem->sem_wchan = wchan_create(sem->sem_name);
    if (sem->sem_wchan == NULL) {
        kfree(sem->sem_name);
        kfree(sem);
        return NULL;
    }

    spinlock_init(&sem->sem_lock);
    sem->sem_count = initial_count;

    return sem;
}
开发者ID:shaon0000,项目名称:massive-wookie,代码行数:30,代码来源:synch.c


示例3: vn_initialize

struct vnode *
vn_initialize(
	struct inode	*inode)
{
	struct vnode	*vp = LINVFS_GET_VP(inode);

	XFS_STATS_INC(vn_active);
	XFS_STATS_INC(vn_alloc);

	vp->v_flag = VMODIFIED;
	spinlock_init(&vp->v_lock, "v_lock");

	spin_lock(&vnumber_lock);
	if (!++vn_generation)	/* v_number shouldn't be zero */
		vn_generation++;
	vp->v_number = vn_generation;
	spin_unlock(&vnumber_lock);

	ASSERT(VN_CACHED(vp) == 0);

	/* Initialize the first behavior and the behavior chain head. */
	vn_bhv_head_init(VN_BHV_HEAD(vp), "vnode");

#ifdef	XFS_VNODE_TRACE
	vp->v_trace = ktrace_alloc(VNODE_TRACE_SIZE, KM_SLEEP);
#endif	/* XFS_VNODE_TRACE */

	vn_trace_exit(vp, "vn_initialize", (inst_t *)__return_address);
	return vp;
}
开发者ID:OpenHMR,项目名称:Open-HMR600,代码行数:30,代码来源:xfs_vnode.c


示例4: tprintf_init

void tprintf_init(void)
{
	spinlock_init(&buffer_lock);

	setvbuf(stdout, NULL, _IONBF, 0);
	setvbuf(stderr, NULL, _IONBF, 0);
}
开发者ID:hhatto,项目名称:netsniff-ng,代码行数:7,代码来源:tprintf.c


示例5: lock_create

struct lock *
lock_create(const char *name)
{
    struct lock *lock;

    lock = kmalloc(sizeof(struct lock));
    if (lock == NULL) {
        return NULL;
    }

    lock->lk_name = kstrdup(name);
    if (lock->lk_name == NULL) {
        kfree(lock);
        return NULL;
    }
#if OPT_A1
    lock->lock_wchan = wchan_create(lock->lk_name);
    if (lock->lock_wchan == NULL) {
        kfree(lock->lk_name);
        kfree(lock);
    }

    spinlock_init(&lock->lk_spinlock);
    lock->available = true;
#endif
    return lock;
}
开发者ID:shaon0000,项目名称:massive-wookie,代码行数:27,代码来源:synch.c


示例6: ModuleInit

/**
 * The module initialisation routine, called when the module
 * is first loaded.
 */
void
ModuleInit()
{
    MXS_NOTICE("Initialise debug CLI router module %s.", version_str);
    spinlock_init(&instlock);
    instances = NULL;
}
开发者ID:DBMSRmutl,项目名称:MaxScale,代码行数:11,代码来源:debugcli.c


示例7: id_gen_test

int id_gen_test(int nargs, char **args){
	sem_numthread = sem_create("sem_testidgen",0);
	struct spinlock splock;
	spinlock_init(&splock);
	idgen = idgen_create(0);

	KASSERT(idgen != NULL);

	(void)nargs;
	(void)args;

	const int NUMTHREAD = 3;

	int i = 0;
	for (; i < NUMTHREAD; i++){
		kprintf ("MAKING THREAD %d\n", i);
		thread_fork("id_gen_test", NULL, test_generator, NULL, i);
	}

	for (int j = 0; j < NUMTHREAD; j++,i++){
		kprintf ("MAKING THREAD %d\n", i);
		thread_fork("id_gen_test", NULL, test_generator2, NULL, i);
	}

	for (int j = 0; j < 2*NUMTHREAD; j++){
		P(sem_numthread);
	}

	idgen_destroy(idgen);
	sem_destroy(sem_numthread);
	return 0;
}
开发者ID:achankf,项目名称:CS350-OS161,代码行数:32,代码来源:id_gen_test.c


示例8: service_alloc

/**
 * Allocate a new service for the gateway to support
 *
 *
 * @param servname	The service name
 * @param router	Name of the router module this service uses
 *
 * @return		The newly created service or NULL if an error occured
 */
SERVICE *
service_alloc(char *servname, char *router)
{
SERVICE 	*service;

	if ((service = (SERVICE *)malloc(sizeof(SERVICE))) == NULL)
		return NULL;
	if ((service->router = load_module(router, MODULE_ROUTER)) == NULL)
	{
		free(service);
		return NULL;
	}
	service->name = strdup(servname);
	service->routerModule = strdup(router);
	memset(&service->stats, 0, sizeof(SERVICE_STATS));
	service->ports = NULL;
	service->stats.started = time(0);
	service->state = SERVICE_STATE_ALLOC;
	service->credentials.name = NULL;
	service->credentials.authdata = NULL;
	service->users = users_alloc();
	service->enable_root = 0;
	service->routerOptions = NULL;
	service->databases = NULL;
	spinlock_init(&service->spin);

	spinlock_acquire(&service_spin);
	service->next = allServices;
	allServices = service;
	spinlock_release(&service_spin);

	return service;
}
开发者ID:huangzhiyong,项目名称:MaxScale,代码行数:42,代码来源:service.c


示例9: cv_create

struct cv *
cv_create(const char *name)
{
	struct cv *cv;

	cv = kmalloc(sizeof(*cv));
	if (cv == NULL) {
		return NULL;
	}

	cv->cv_name = kstrdup(name);
	if (cv->cv_name==NULL) {
		kfree(cv);
		return NULL;
	}

	cv->cv_wchan = wchan_create(cv->cv_name);
	if (cv->cv_wchan == NULL) {
		kfree(cv->cv_name);
		kfree(cv);
		return NULL;
	}

	spinlock_init(&cv->cv_spinlock);
	// add stuff here as needed

	return cv;
}
开发者ID:srikk595,项目名称:Operating-Systems-OS161,代码行数:28,代码来源:synch.c


示例10: prepare_for_sleep

u32
prepare_for_sleep (u32 firmware_waking_vector)
{
	u8 *p;
	int wakeup_entry_len;

	/* Get the suspend-lock to make other processors stopping or staying
	   in the guest mode. */
	get_suspend_lock ();

	/* Now the VMM is executed by the current processor only.
	   Call suspend functions. */
	call_initfunc ("suspend");

	/* Initialize variables used by wakeup functions */
	wakeup_cpucount = 0;
	spinlock_init (&wakeup_cpucount_lock);
	waking_vector = firmware_waking_vector;
	wakeup_prepare ();

	/* Copy the wakeup_entry code. */
	wakeup_entry_len = wakeup_entry_end - wakeup_entry_start;
	p = mapmem_hphys (wakeup_entry_addr, wakeup_entry_len, MAPMEM_WRITE);
	memcpy (p, wakeup_entry_start, wakeup_entry_len);
	unmapmem (p, wakeup_entry_len);
	return wakeup_entry_addr;
}
开发者ID:crazycoderx2,项目名称:bitvisor,代码行数:27,代码来源:wakeup.c


示例11: lock_create

struct lock *
lock_create(const char *name)
{
	struct lock *lock;

	lock = kmalloc(sizeof(*lock));
	if (lock == NULL) {
		return NULL;
	}

	lock->lk_name = kstrdup(name);
	if (lock->lk_name == NULL) {
		kfree(lock);
		return NULL;
	}

	lock->lk_wchan = wchan_create(lock->lk_name);
	if (lock->lk_wchan == NULL) {
		kfree(lock->lk_name);
		kfree(lock);
		return NULL;
	}

	spinlock_init(&lock->lk_spinlock);
	lock->lk_isheld = false;
	lock->lk_curthread = NULL;
	// add stuff here as needed

	return lock;
}
开发者ID:srikk595,项目名称:Operating-Systems-OS161,代码行数:30,代码来源:synch.c


示例12: lock_create

struct lock *
lock_create(const char *name)
{
        struct lock *lock;

        lock = kmalloc(sizeof(struct lock));
        if (lock == NULL) {
                return NULL;
        }

        lock->lk_name = kstrdup(name);
        if (lock->lk_name == NULL) {
                kfree(lock);
                return NULL;
        }

        // add stuff here as needed
		//Peng 2.19.2016		
        lock->lock_wchan = wchan_create(lock->lk_name);
        if (lock->lock_wchan == NULL) {
        kfree(lock->lk_name);
        kfree(lock);
        return NULL;
        }
        spinlock_init(&lock->lock_splk);
        lock->held=false;
        lock->holder=NULL;
		//Peng

        return lock;
}
开发者ID:patricksu,项目名称:repo3,代码行数:31,代码来源:synch_Lock.c


示例13: hubspc_init

/*
 * hubspc_init
 * Registration of the hubspc devices with the hub manager
 */
void
hubspc_init(void)
{
        /*
         * Register with the hub manager
         */

        /* The reference counters */
        hubdev_register(mem_refcnt_attach);

	/* Prom space */
	hubdev_register(cpuprom_attach);

#if defined(CONFIG_SERIAL_SGI_L1_PROTOCOL)
	/* L1 system controller link */
	if ( !IS_RUNNING_ON_SIMULATOR() ) {
		/* initialize the L1 link */
		void l1_cons_init( l1sc_t *sc );
		elsc_t *get_elsc(void);

		l1_cons_init((l1sc_t *)get_elsc());
	}
#endif

#ifdef	HUBSPC_DEBUG
	printf("hubspc_init: Completed\n");
#endif	/* HUBSPC_DEBUG */
	/* Initialize spinlocks */
	spinlock_init(&cpuprom_spinlock, "promlist");
}
开发者ID:dot-Sean,项目名称:linux_kernels,代码行数:34,代码来源:hubspc.c


示例14: pro100_new

// 新しいデバイスの発見
void pro100_new(struct pci_device *dev)
{
	PRO100_CTX *ctx = SeZeroMalloc(sizeof(PRO100_CTX));

	debugprint ("pro100_new\n");

#ifdef VTD_TRANS
        if (iommu_detected) {
                add_remap(dev->address.bus_no ,dev->address.device_no ,dev->address.func_no,
                          vmm_start_inf() >> 12, (vmm_term_inf()-vmm_start_inf()) >> 12, PERM_DMA_RW) ;
        }
#endif // of VTD_TRANS

	ctx->dev = dev;
	spinlock_init (&ctx->lock);
	dev->host = ctx;
	dev->driver->options.use_base_address_mask_emulation = 1;

	pro100_alloc_recv_buffer(ctx);

	if (pro100_ctx == NULL)
	{
		pro100_ctx = ctx;
	}
	else
	{
		debugprint("Error: Two or more pro100 devices found.\n");
		pro100_beep(1234, 5000);
	}
}
开发者ID:anbangr,项目名称:bitvisor-dev,代码行数:31,代码来源:vpn_pro100.c


示例15: hashtable_alloc

/**
 * Allocate a new hash table
 *
 * @param size		The size of the hash table
 * @param hashfn	The user supplied hash function
 * @param cmpfn		The user supplied key comparison function
 * @return The hashtable table
 */
HASHTABLE *
hashtable_alloc(int size, int (*hashfn)(), int (*cmpfn)())
{
HASHTABLE 	*rval;

	if ((rval = malloc(sizeof(HASHTABLE))) == NULL)
		return NULL;

#if defined(SS_DEBUG)
        rval->ht_chk_top = CHK_NUM_HASHTABLE;
        rval->ht_chk_tail = CHK_NUM_HASHTABLE;
#endif
	rval->hashsize = size;
	rval->hashfn = hashfn;
	rval->cmpfn = cmpfn;
	rval->kcopyfn = nullfn;
	rval->vcopyfn = nullfn;
	rval->kfreefn = nullfn;
	rval->vfreefn = nullfn;
	rval->n_readers = 0;
	rval->writelock = 0;
	spinlock_init(&rval->spin);
	if ((rval->entries = (HASHENTRIES **)calloc(size, sizeof(HASHENTRIES *))) == NULL)
	{
		free(rval);
		return NULL;
	}
	memset(rval->entries, 0, size * sizeof(HASHENTRIES *));

	return rval;
}
开发者ID:abiratsis,项目名称:MaxScale,代码行数:39,代码来源:hashtable.c


示例16: alloc_ata_channel

static struct ata_channel *ata_new_channel(struct ata_host* host)
{
	struct ata_channel *channel;
	struct atapi_device *atapi_device;

	channel = alloc_ata_channel();
	memset(channel, 0, sizeof(*channel));
	spinlock_init (&channel->locked_lock);
	channel->locked = false;
	channel->waiting = 0;
	channel->hd[ATA_ID_CMD] = -1;
	channel->hd[ATA_ID_CTL] = -1;
	channel->hd[ATA_ID_BM] = -1;
	ata_init_ata_device(&channel->device[0]);
	ata_init_ata_device(&channel->device[1]);
	channel->host = host;
	channel->state = ATA_STATE_READY;
	ata_init_prd(channel);
	ata_init_pio_buf (channel);
	host_id++; device_id = 0;

	/* atapi device */
	atapi_device = alloc_atapi_device();
	memset(atapi_device, 0, sizeof(*atapi_device));
	channel->atapi_device = atapi_device;
	channel->atapi_device->atapi_flag = 0;
	channel->atapi_device->dma_state = ATA_STATE_DMA_THROUGH;

	return channel;
}
开发者ID:anbangr,项目名称:bitvisor-dev,代码行数:30,代码来源:ata_init.c


示例17: list_init

/* Initialize a driver list. */
static void list_init(driver_list_t *dl, const char *name)
{
  spinlock_init(&dl->mutex);
  dl->n = 0;
  dl->drivers = 0;
  dl->name = name;
}
开发者ID:pcercuei,项目名称:dcplaya,代码行数:8,代码来源:driver_list.c


示例18: mfs_mount

/*设备挂载响应函数*/
int mfs_mount(struct inode *pi,struct itemdata *proot,void ** mntprivate)
{
	if (NULL==pi||NULL==mntprivate) return INVALID;
	if (ITYPE_BLK_DEV!=pi->i_data.i_attrib.i_type) return INVALID;
	if (MFS_NEED_MIN_SCTS>pi->i_data.i_attrib.i_size) return INVALID;

	struct mfs_super_blk sblk={0},*psblk;
	int result = mfsr_superblk(&(pi->i_data),&sblk);
	if (INVALID==result) return INVALID;
	if (MFS_MAGIC!=sblk.mfs_magic) return INVALID;

	psblk = kmalloc(sizeof(struct mfs_super_blk));
	if (NULL==psblk) return INVALID;

	memcpy(psblk,&sblk,sizeof(struct mfs_super_blk));
	spinlock_init(psblk->lck_cmap);	/*必须要初始化这个成员*/

	* mntprivate = psblk;

	struct mfs_core *pc = cmfs_cache_alloc();
	if (NULL==pc) goto faile;

	pc->i_fat[0] = sblk.clst_root;
	pc->m_cluster = sblk.clst_root;
	pc->m_itm = &(proot->i_attrib);
	pc->m_itm->i_type = ITYPE_DIR;

	proot->i_private = pc;
faile:
	kfree(psblk);
	return VALID;
}
开发者ID:bedreamer,项目名称:fool,代码行数:33,代码来源:mfs.c


示例19: driver_lists_init

/** Init everything for the driver manager. */
int driver_lists_init(void)
{
  int i, err = 0;
  const int n = sizeof(registered_lists) / sizeof(*registered_lists);

  spinlock_init(&driver_lists_mutex);
  driver_lists = 0;
  for (i=0; i<n; ++i) {
    driver_list_reg_t * reg = registered_lists + i;

    if (driver_lists_add(reg) < 0) {
      SDERROR("[%s] : [%s,%08x] registration failed.\n",
	      __FUNCTION__, reg->name, reg->type);
      ++ err;
    } else {
      /* $$$ ben : careful ! driver list will not been initiliazed if
	 the registration failed. This couls be dangerous since we used
	 extern driver list. This could be ok as soon as these extern be
	 removed.
      */
      list_init(reg->list, reg->name);
      SDDEBUG("[%s] : [%s,%08x] initialized.\n",
	      __FUNCTION__, reg->name, reg->type);
    }
  }
  return -err;
}
开发者ID:pcercuei,项目名称:dcplaya,代码行数:28,代码来源:driver_list.c


示例20: lock_create

struct lock *
lock_create(const char *name)
{
        struct lock *lock;

        lock = kmalloc(sizeof(struct lock));
        if (lock == NULL) {
                return NULL;
        }

        lock->lk_name = kstrdup(name);
        if (lock->lk_name == NULL) {
                kfree(lock);
                return NULL;
        }
        // add stuff here as needed

        lock->lk_wchan = wchan_create(lock->lk_name);
		  if (lock->lk_wchan == NULL){
			  kfree(lock->lk_name);
			  kfree(lock);
			  return NULL;
		  }

		  spinlock_init(&lock->lk_spinlock);
		  lock->lk_owner = NULL;
        
        return lock;
}
开发者ID:simnic31,项目名称:OS,代码行数:29,代码来源:synch.c



注:本文中的spinlock_init函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ spinlock_release函数代码示例发布时间:2022-05-30
下一篇:
C++ spin_unlock_irqrestore函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap