当前位置: 首页>>代码示例>>C++>>正文


C++ cv_signal函数代码示例

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


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

示例1: fips140_actions

/* ARGSUSED */
static int
fips140_actions(dev_t dev, caddr_t arg, int mode, int *rval, int cmd)
{
	crypto_fips140_t fips140_info;
	uint32_t rv = CRYPTO_SUCCESS;
	int error = 0;

	if (copyin(arg, &fips140_info, sizeof (crypto_fips140_t)) != 0)
		return (EFAULT);

	switch (cmd) {
	case CRYPTO_FIPS140_STATUS:
		fips140_info.fips140_status = global_fips140_mode;
		break;
	case CRYPTO_FIPS140_SET:
		/* If the mode has been determined, there is nothing to set */
		mutex_enter(&fips140_mode_lock);

		if (fips140_info.fips140_op == FIPS140_ENABLE &&
		    global_fips140_mode == FIPS140_MODE_UNSET) {
			/*
			 * If FIPS 140 is enabled, all approriate modules
			 * must be loaded and validated.  This can be done in
			 * the background as the rest of the OS comes up.
			 */
			global_fips140_mode = FIPS140_MODE_VALIDATING;
			(void) thread_create(NULL, 0, kcf_fips140_validate,
			    NULL, 0, &p0, TS_RUN, MAXCLSYSPRI);
			cv_signal(&cv_fips140);

		} else if (fips140_info.fips140_op == FIPS140_DISABLE &&
		    global_fips140_mode == FIPS140_MODE_UNSET) {
			/*
			 * If FIPS 140 is not enabled, any modules that are
			 * waiting for validation must be released so they
			 * can be verified.
			 */
			global_fips140_mode = FIPS140_MODE_DISABLED;
			kcf_activate();
			cv_signal(&cv_fips140);

		} else if (fips140_info.fips140_op != FIPS140_DISABLE &&
		    fips140_info.fips140_op != FIPS140_ENABLE) {
			rv = CRYPTO_ARGUMENTS_BAD;
		}

		mutex_exit(&fips140_mode_lock);
		break;

	default:
		rv = CRYPTO_ARGUMENTS_BAD;
	}

	fips140_info.fips140_return_value = rv;

	if (copyout(&fips140_info, arg, sizeof (crypto_fips140_t)) != 0)
		error = EFAULT;

	return (error);
}
开发者ID:MatiasNAmendola,项目名称:AuroraUX-SunOS,代码行数:61,代码来源:cryptoadm.c

示例2: female

void
female(void *p, unsigned long which)
{
	struct semaphore * whalematingMenuSemaphore = (struct semaphore *)p;
  (void)which;

  female_start();
	// Implement this function
   lock_acquire(whaleLock);
  // Implement this function
  if (wchan_isempty(maleCv->cv_wchan) || wchan_isempty(matchMakerCv->cv_wchan))
  {
      cv_wait(femaleCv,whaleLock);
  }else{
       cv_signal(maleCv,whaleLock);
       cv_signal(matchMakerCv,whaleLock);
  }
  lock_release(whaleLock);
  female_end();

  // 08 Feb 2012 : GWA : Please do not change this code. This is so that your
  // whalemating driver can return to the menu cleanly.
  V(whalematingMenuSemaphore);
  return;
}
开发者ID:SimplyRamya24,项目名称:Kernel-Development,代码行数:25,代码来源:problems.c

示例3: ipmi_complete_request

/*ARGSUSED*/
void
ipmi_complete_request(struct ipmi_softc *sc, struct ipmi_request *req)
{
	struct ipmi_device *dev;

	IPMI_LOCK_ASSERT(sc);

	if (req->ir_status == IRS_CANCELED) {
		ASSERT(req->ir_owner == NULL);
		ipmi_free_request(req);
		return;
	}

	req->ir_status = IRS_COMPLETED;

	/*
	 * Anonymous requests (from inside the driver) always have a
	 * waiter that we awaken.
	 */
	if (req->ir_owner == NULL) {
		cv_signal(&req->ir_cv);
	} else {
		dev = req->ir_owner;
		TAILQ_INSERT_TAIL(&dev->ipmi_completed_requests, req, ir_link);
		pollwakeup(dev->ipmi_pollhead, POLLIN | POLLRDNORM);

		dev->ipmi_status &= ~IPMI_BUSY;
		if (dev->ipmi_status & IPMI_CLOSING)
			cv_signal(&dev->ipmi_cv);
	}
}
开发者ID:apprisi,项目名称:illumos-gate,代码行数:32,代码来源:ipmi.c

示例4: male

static
void
male(void *p, unsigned long which)
{

    (void)p;
    kprintf("male whale #%ld starting\n", which);
    lock_acquire(lk_male);

    no_males++;


    if(no_females==0 || no_mm ==0 ) {
        ismwaiting=1;
        cv_wait(cv_male,lk_male);
        ismwaiting=0;
    }

    if(isfwaiting==0)
        cv_signal(cv_female,lk_female);
    if(ismmwaiting==0)
        cv_signal(cv_mm,lk_mm);


    kprintf("male whale #%ld ending\n", which);
    lock_release(lk_male);


}
开发者ID:chellaram29,项目名称:os-161,代码行数:29,代码来源:whalemating.c

示例5: matchmaker

void
matchmaker(void *p, unsigned long which)
{
  struct semaphore * whalematingMenuSemaphore = (struct semaphore *)p;
  (void)which;
  
  matchmaker_start();
  lock_acquire(wm_lock);
  while(1)
  {
    cv_wait(wm_mmcv,wm_lock);
    lock_acquire(wm_lock);
    if(males > 0 && females > 0)
    {
      kprintf("Ready to match!");
      break;
    }
  }
  cv_signal(wm_mcv,wm_lock);
  cv_signal(wm_fcv,wm_lock);
  males--;
  females--;
  lock_release(wm_lock);
  matchmaker_end();
  
  // 08 Feb 2012 : GWA : Please do not change this code. This is so that your
  // whalemating driver can return to the menu cleanly.
  V(whalematingMenuSemaphore);
  return;
}
开发者ID:smflorentino,项目名称:os161,代码行数:30,代码来源:problems.c

示例6: bcm2835_audio_callback

static void
bcm2835_audio_callback(void *param, const VCHI_CALLBACK_REASON_T reason, void *msg_handle)
{
	struct bcm2835_audio_info *sc = (struct bcm2835_audio_info *)param;
	int32_t status;
	uint32_t msg_len;
	VC_AUDIO_MSG_T m;

	if (reason != VCHI_CALLBACK_MSG_AVAILABLE)
		return;

	status = vchi_msg_dequeue(sc->vchi_handle,
	    &m, sizeof m, &msg_len, VCHI_FLAGS_NONE);
	if (m.type == VC_AUDIO_MSG_TYPE_RESULT) {
		sc->msg_result = m.u.result.success;
		cv_signal(&sc->msg_avail_cv);
	} else if (m.type == VC_AUDIO_MSG_TYPE_COMPLETE) {
		struct bcm2835_audio_chinfo *ch = m.u.complete.cookie;

		int count = m.u.complete.count & 0xffff;
		int perr = (m.u.complete.count & (1U << 30)) != 0;

		ch->complete_pos = (ch->complete_pos + count) % sndbuf_getsize(ch->buffer);
		ch->free_buffer += count;

		if (perr || ch->free_buffer >= VCHIQ_AUDIO_PACKET_SIZE) {
			chn_intr(ch->channel);
			cv_signal(&sc->data_cv);
		}
	} else
		printf("%s: unknown m.type: %d\n", __func__, m.type);
}
开发者ID:fengsi,项目名称:freebsd,代码行数:32,代码来源:bcm2835_audio.c

示例7: ip_squeue_clean_ring

/*
 * sanitize the squeue etc. Some of the processing
 * needs to be done from inside the perimeter.
 */
void
ip_squeue_clean_ring(ill_t *ill, ill_rx_ring_t *rx_ring)
{
	squeue_t *sqp;

	ASSERT(ILL_MAC_PERIM_HELD(ill));
	ASSERT(rx_ring != NULL);

	/* Just clean one squeue */
	mutex_enter(&ill->ill_lock);
	if (rx_ring->rr_ring_state == RR_FREE) {
		mutex_exit(&ill->ill_lock);
		return;
	}
	rx_ring->rr_ring_state = RR_FREE_INPROG;
	sqp = rx_ring->rr_sqp;

	mutex_enter(&sqp->sq_lock);
	sqp->sq_state |= SQS_POLL_CLEANUP;
	cv_signal(&sqp->sq_worker_cv);
	mutex_exit(&ill->ill_lock);
	while (!(sqp->sq_state & SQS_POLL_CLEANUP_DONE))
		cv_wait(&sqp->sq_ctrlop_done_cv, &sqp->sq_lock);
	sqp->sq_state &= ~SQS_POLL_CLEANUP_DONE;

	ASSERT(!(sqp->sq_state & (SQS_POLL_THR_CONTROL |
	    SQS_WORKER_THR_CONTROL | SQS_POLL_QUIESCE_DONE |
	    SQS_POLL_THR_QUIESCED)));

	cv_signal(&sqp->sq_worker_cv);
	mutex_exit(&sqp->sq_lock);

	/*
	 * Move the squeue to sqset_global_list[0] which holds the set of
	 * squeues not bound to any cpu. Note that the squeue is still
	 * considered bound to an ill as long as SQS_ILL_BOUND is set.
	 */
	mutex_enter(&sqset_lock);
	ip_squeue_set_move(sqp, sqset_global_list[0]);
	mutex_exit(&sqset_lock);

	/*
	 * CPU going offline can also trigger a move of the squeue to the
	 * unbound set sqset_global_list[0]. However the squeue won't be
	 * recycled for the next use as long as the SQS_ILL_BOUND flag
	 * is set. Hence we clear the SQS_ILL_BOUND flag only towards the
	 * end after the move.
	 */
	mutex_enter(&sqp->sq_lock);
	sqp->sq_state &= ~SQS_ILL_BOUND;
	mutex_exit(&sqp->sq_lock);

	mutex_enter(&ill->ill_lock);
	rx_ring->rr_ring_state = RR_FREE;
	mutex_exit(&ill->ill_lock);
}
开发者ID:MatiasNAmendola,项目名称:AuroraUX-SunOS,代码行数:60,代码来源:ip_squeue.c

示例8: catlock

static
void
catlock(void * unusedpointer, 
        unsigned long catnumber)
{
	int i;
	for (i = 0; i < TIMES_EATING; i++)
	{
	lock_acquire(openbowl_lock);
		while (bowl1->who != FREE && bowl2->who != FREE) {
			cv_wait(free_bowl, openbowl_lock);
		}	
		while (bowl1->who == MOUSE || bowl2->who == MOUSE) {
			cv_wait(free_bowl, openbowl_lock);
		}

		if (bowl1->who == FREE) { 
		//[lock bowl 1, eat from bowl 1], release bowl1_lock, release openbowl_lock, cv_signal(free_bowl, openbowl_lock), increment cats[catnumber];
			
			lock_acquire(bowl_1);
			bowl1->who = CAT;
			lock_release(openbowl_lock);
			lock_eat("cat", catnumber, 1, i);
			bowl1->who = FREE;
			cv_signal(free_bowl, openbowl_lock);
			lock_release(bowl_1);
			
			

		} else if (bowl2 ->who == FREE) {
		//[lock bowl 2, eat from bowl 2], change who==null, release bowl2_lock, release openbowl_lock, cv_signal(free_bowl, openbowl_lock), increment cats[catnumber];

			lock_acquire(bowl_2);	
			bowl2->who = CAT;
			lock_release(openbowl_lock);
			lock_eat("cat", catnumber, 2, i);
			bowl2->who = FREE;
			cv_signal(free_bowl, openbowl_lock);
			lock_release(bowl_2);


		}
		else {
			i--;
			//error shouldn't have made it here!
		}
		// check to see if everyone's eaten the same number of times. If I am more, cv_wait(fair_share), else cv_broadcast(fair_share)
	}
        /*
         * Avoid unused variable warnings.
         */

        (void) unusedpointer;
        (void) catnumber;
}
开发者ID:filklimowski,项目名称:Harvard-OS161-Operating-System,代码行数:55,代码来源:catlock.c

示例9: _sx_xunlock

void
_sx_xunlock(struct sx *sx, const char *file, int line)
{

	_sx_assert(sx, SX_XLOCKED, file, line);
	mtx_lock(sx->sx_lock);
	MPASS(sx->sx_cnt == -1);

	WITNESS_UNLOCK(&sx->sx_object, LOP_EXCLUSIVE, file, line);

	/* Release. */
	sx->sx_cnt++;
	sx->sx_xholder = NULL;

	/*
	 * Wake up waiters if there are any.  Give precedence to slock waiters.
	 */
	if (sx->sx_shrd_wcnt > 0)
		cv_broadcast(&sx->sx_shrd_cv);
	else if (sx->sx_excl_wcnt > 0)
		cv_signal(&sx->sx_excl_cv);

	LOCK_LOG_LOCK("XUNLOCK", &sx->sx_object, 0, 0, file, line);

	mtx_unlock(sx->sx_lock);
}
开发者ID:MarginC,项目名称:kame,代码行数:26,代码来源:kern_sx.c

示例10: male

void
male(void *p, unsigned long which)
{
	struct semaphore * whalematingMenuSemaphore = (struct semaphore *)p;
  //(void)which;

  male_start();
	// Implement this function
    //extern int male_tail, female_head, female_tail;
    //extern unsigned long male_pop[];
    //extern struct lock *pop_lock;
    //extern struct cv *maker_cv;

    lock_acquire(pop_lock);
    male_pop[male_tail++] = which;

    if(female_head != female_tail)
        cv_signal(maker_cv, pop_lock);
    lock_release(pop_lock);

  male_end();

  // 08 Feb 2012 : GWA : Please do not change this code. This is so that your
  // whalemating driver can return to the menu cleanly.
  V(whalematingMenuSemaphore);
  return;
}
开发者ID:dazzaphobus,项目名称:os161,代码行数:27,代码来源:problems.c

示例11: top_issue_sync

/*
 * issue a empty sync op to help empty the delta/log map or the log
 */
static void
top_issue_sync(void *arg)
{
	ufsvfs_t *ufsvfsp = (ufsvfs_t *)arg;
	ml_unit_t *ul = (ml_unit_t *)ufsvfsp->vfs_log;
	mt_map_t *mtm = ul->un_logmap;
	int	error = 0;

	if ((curthread->t_flag & T_DONTBLOCK) == 0)
		curthread->t_flag |= T_DONTBLOCK;
	top_begin_sync(ufsvfsp, TOP_COMMIT_ASYNC, 0, &error);
	if (!error) {
		top_end_sync(ufsvfsp, &error, TOP_COMMIT_ASYNC, 0);
	}

	/*
	 * If we are a taskq thread, decrement mtm_taskq_sync_count and
	 * wake up the thread waiting on the mtm_cv if the mtm_taskq_sync_count
	 * hits zero.
	 */

	if (taskq_member(system_taskq, curthread)) {
		mutex_enter(&mtm->mtm_lock);
		mtm->mtm_taskq_sync_count--;
		if (mtm->mtm_taskq_sync_count == 0) {
			cv_signal(&mtm->mtm_cv);
		}
		mutex_exit(&mtm->mtm_lock);
	}
}
开发者ID:andreiw,项目名称:polaris,代码行数:33,代码来源:lufs_top.c

示例12: sys_ksem_post

int
sys_ksem_post(struct thread *td, struct ksem_post_args *uap)
{
	struct file *fp;
	struct ksem *ks;
	int error;

	error = ksem_get(td, uap->id, CAP_SEM_POST, &fp);
	if (error)
		return (error);
	ks = fp->f_data;

	mtx_lock(&sem_lock);
#ifdef MAC
	error = mac_posixsem_check_post(td->td_ucred, fp->f_cred, ks);
	if (error)
		goto err;
#endif
	if (ks->ks_value == SEM_VALUE_MAX) {
		error = EOVERFLOW;
		goto err;
	}
	++ks->ks_value;
	if (ks->ks_waiters > 0)
		cv_signal(&ks->ks_cv);
	error = 0;
	vfs_timestamp(&ks->ks_ctime);
err:
	mtx_unlock(&sem_lock);
	fdrop(fp, td);
	return (error);
}
开发者ID:rchander,项目名称:freebsd,代码行数:32,代码来源:uipc_sem.c

示例13: sf_ext_free_nocache

/*
 * Same as above, but forces the page to be detached from the object
 * and go into free pool.
 */
void
sf_ext_free_nocache(void *arg1, void *arg2)
{
	struct sf_buf *sf = arg1;
	struct sendfile_sync *sfs = arg2;
	vm_page_t pg = sf_buf_page(sf);

	sf_buf_free(sf);

	vm_page_lock(pg);
	if (vm_page_unwire(pg, PQ_NONE)) {
		vm_object_t obj;

		/* Try to free the page, but only if it is cheap to. */
		if ((obj = pg->object) == NULL)
			vm_page_free(pg);
		else if (!vm_page_xbusied(pg) && VM_OBJECT_TRYWLOCK(obj)) {
			vm_page_free(pg);
			VM_OBJECT_WUNLOCK(obj);
		} else
			vm_page_deactivate(pg);
	}
	vm_page_unlock(pg);

	if (sfs != NULL) {
		mtx_lock(&sfs->mtx);
		KASSERT(sfs->count > 0, ("Sendfile sync botchup count == 0"));
		if (--sfs->count == 0)
			cv_signal(&sfs->cv);
		mtx_unlock(&sfs->mtx);
	}
}
开发者ID:2asoft,项目名称:freebsd,代码行数:36,代码来源:kern_sendfile.c

示例14: trim_thread

static void
trim_thread(void *arg)
{
	spa_t *spa = arg;
	zio_t *zio;

	for (;;) {
		mutex_enter(&spa->spa_trim_lock);
		if (spa->spa_trim_thread == NULL) {
			spa->spa_trim_thread = curthread;
			cv_signal(&spa->spa_trim_cv);
			mutex_exit(&spa->spa_trim_lock);
			thread_exit();
		}
		cv_wait(&spa->spa_trim_cv, &spa->spa_trim_lock);
		mutex_exit(&spa->spa_trim_lock);

		zio = zio_root(spa, NULL, NULL, ZIO_FLAG_CANFAIL);

		spa_config_enter(spa, SCL_STATE, FTAG, RW_READER);
		trim_map_commit(spa, zio, spa->spa_root_vdev);
		(void) zio_wait(zio);
		trim_map_commit_done(spa, spa->spa_root_vdev);
		spa_config_exit(spa, SCL_STATE, FTAG);
	}
}
开发者ID:vkhromov,项目名称:freebsd,代码行数:26,代码来源:trim_map.c

示例15: ipmi_detach

static int
ipmi_detach(dev_info_t *dip, ddi_detach_cmd_t cmd)
{
	if (cmd != DDI_DETACH)
		return (DDI_FAILURE);

	if (ipmi_found == B_FALSE)
		return (DDI_SUCCESS);

	if (!list_is_empty(&dev_list))
		return (DDI_FAILURE);

	/* poke the taskq so that it can terminate */
	sc->ipmi_detaching = 1;
	cv_signal(&sc->ipmi_request_added);

	ddi_remove_minor_node(dip, NULL);
	ipmi_dip = NULL;

	taskq_destroy(sc->ipmi_kthread);
	list_destroy(&dev_list);
	id_space_destroy(minor_ids);

	ipmi_attached = B_FALSE;
	return (DDI_SUCCESS);
}
开发者ID:mcarpenter,项目名称:illumos-gate,代码行数:26,代码来源:ipmi_main.c


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