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


C++ down_timeout函数代码示例

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


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

示例1: wait

/*****************************************************************************
 Function   : VOS_SmP
 Description: Lock the resource for synchronization, if the resource is none
              then block, otherwise the number of the resource --
 Input      : ulSmID             -- the ID of the resource to lock
              ulTimeOutInMillSec -- the time to wait(0 for ever)
 Return     : VOS_OK on success and errno on failure
 *****************************************************************************/
VOS_UINT32 VOS_SmP( VOS_SEM Sm_ID, VOS_UINT32 ulTimeOutInMillSec )
{
    SEM_CONTROL_BLOCK  *temp_Ptr;
    VOS_INT32           timeintick;
    VOS_INT             lRetValue;

    temp_Ptr = (SEM_CONTROL_BLOCK *)Sm_ID;

    if ( temp_Ptr != temp_Ptr->SemId )
    {
        VOS_SetErrorNo(VOS_ERRNO_SEMA4_P_IDERR);
        return (VOS_ERRNO_SEMA4_P_IDERR);
    }

    if (VOS_SEM_CTRL_BLK_IDLE == temp_Ptr->Flag)
    {
        VOS_SetErrorNo(VOS_ERRNO_SEMA4_P_NOTACTIVE);
        return(VOS_ERRNO_SEMA4_P_NOTACTIVE);
    }

    if (ulTimeOutInMillSec == 0)
    {
        down(&(temp_Ptr->sem));

        return VOS_OK;
    }

    timeintick = ((ulTimeOutInMillSec*HZ)/1000);

    lRetValue = down_timeout(&(temp_Ptr->sem), timeintick);

    if ( VOS_OK == lRetValue )
    {
        return VOS_OK;
    }
    else if ( -ETIME == lRetValue )
    {
        VOS_SetErrorNo(VOS_ERRNO_SEMA4_P_TIMEOUT);
        return VOS_ERRNO_SEMA4_P_TIMEOUT;
    }
    else
    {
    }

    VOS_SetErrorNo (VOS_ERRNO_SEMA4_P_CANOTP);
    return VOS_ERRNO_SEMA4_P_CANOTP;

}
开发者ID:XePeleato,项目名称:android_kernel_huawei_venus,代码行数:56,代码来源:linux_sem.c

示例2: hwSimIsDone

int hwSimIsDone(int timeout)
{
	long jeffies;

	if(timeout == -1)
	{
	if(down_interruptible(&hwSimInfo.simIsDone) == 0)
		return DV_OK;
	else
		return DV_ERROR;
	}

	jeffies = msecs_to_jiffies(timeout);
	if(down_timeout(&hwSimInfo.simIsDone, jeffies) == 0)
		return DV_OK;
	else
		return DV_ERROR;
}
开发者ID:abgoyal,项目名称:alcatel_ot_4020D_kernel,代码行数:18,代码来源:hw_sim.c

示例3: ath6kl_sdio_init_msm

void ath6kl_sdio_init_msm(void)
{
	int ret;

	sema_init(&wifi_control_sem, 1);
	down(&wifi_control_sem);

	ret = platform_driver_register(&ath6kl_sdio_device);

	/* Waiting callback after platform_driver_register */
	if (down_timeout(&wifi_control_sem,  msecs_to_jiffies(5000)) != 0) {
		ret = -EINVAL;
		printk(KERN_INFO "platform_driver_register timeout\n");
		return;
	}

	return;
}
开发者ID:ShawnOfMisfit,项目名称:ambarella,代码行数:18,代码来源:msm.c

示例4: connection_read_data

size_t connection_read_data(struct connection *conn, void *buffer, uint32_t len,
			    int32_t timeout)
{
	size_t ret = 0;

	MCDRV_ASSERT(buffer != NULL);
	MCDRV_ASSERT(conn->socket_descriptor != NULL);

	MCDRV_DBG_VERBOSE(mc_kapi, "read data len = %u for PID = %u",
			  len, conn->sequence_magic);
	do {
		/*
		 * Wait until data is available or timeout
		 * msecs_to_jiffies(-1) -> wait forever for the sem
		 */
		if (down_timeout(&(conn->data_available_sem),
				 msecs_to_jiffies(timeout))) {
			MCDRV_DBG_VERBOSE(mc_kapi,
					  "Timeout reading the data sem");
			ret = -2;
			break;
		}

		if (mutex_lock_interruptible(&(conn->data_lock))) {
			MCDRV_DBG_ERROR(mc_kapi,
					"interrupted reading the data sem");
			ret = -1;
			break;
		}

		/* Have data, use it */
		if (conn->data_len > 0)
			ret = connection_read_data_msg(conn, buffer, len);

		mutex_unlock(&(conn->data_lock));

		/* There is still some data left */
		if (conn->data_len > 0)
			up(&conn->data_available_sem);

	} while (0);

	return ret;
}
开发者ID:CobraJet93,项目名称:kernel-3.10.54,代码行数:44,代码来源:connection.c

示例5: KREE_ServSemaphoreDownTimeout

TZ_RESULT KREE_ServSemaphoreDownTimeout(u32 op, u8 param[REE_SERVICE_BUFFER_SIZE])
{
	struct semaphore *sema;
	u32 *in;
	long jiffies;
	int *out;
	int ret;

	in = (u32 *) &param[0];
	sema = (struct semaphore *)in[0];
	jiffies = (long)in[1];

	ret = down_timeout(sema, jiffies);

	out = (int *)&param[0];
	*out = ret;

	return TZ_RESULT_SUCCESS;
}
开发者ID:Scorpio92,项目名称:mediatek,代码行数:19,代码来源:tz_sys_ipc.c

示例6: wl_android_wifictrl_func_add

int wl_android_wifictrl_func_add(void)
{
	int ret = 0;
	sema_init(&wifi_control_sem, 0);

	ret = wifi_add_dev();
	if (ret) {
		DHD_ERROR(("%s: platform_driver_register failed\n", __FUNCTION__));
		return ret;
	}
	g_wifidev_registered = 1;

	
	if (down_timeout(&wifi_control_sem,  msecs_to_jiffies(1000)) != 0) {
		ret = -EINVAL;
		DHD_ERROR(("%s: platform_driver_register timeout\n", __FUNCTION__));
	}

	return ret;
}
开发者ID:DirtyDroidX,项目名称:android_kernel_htc_m8ul,代码行数:20,代码来源:wl_android.c

示例7: rtw_android_wifictrl_func_add

int rtw_android_wifictrl_func_add(void)
{
	int ret = 0;
	sema_init(&wifi_control_sem, 0);

	ret = wifi_add_dev();
	if (ret) {
		DBG_871X("%s: platform_driver_register failed\n", __FUNCTION__);
		return ret;
	}
	g_wifidev_registered = 1;

	/* Waiting callback after platform_driver_register is done or exit with error */
	if (down_timeout(&wifi_control_sem,  msecs_to_jiffies(1000)) != 0) {
		ret = -EINVAL;
		DBG_871X("%s: platform_driver_register timeout\n", __FUNCTION__);
	}

	return ret;
}
开发者ID:Whiteha,项目名称:rtl8812au,代码行数:20,代码来源:rtw_android.c

示例8: tmsi_release

static int tmsi_release(struct inode *inode, struct file *file) {
    struct tmsi_data* dev;
    int retval = 0;
    info("Tmsi Release\n");
    dev = (struct tmsi_data*) file->private_data;
    if (!dev)
        return -ENODEV;
    dev->releasing = 1;
    if (dev->fei)
    {
        //We have front end info, so just to be sure, we send a stop message
        info("Sending stop request\n");
        retval = tmsi_write_data(dev, dev->fei, dev->fei_size);
        //We are waiting for stop confirmation, for a while....
        down_timeout(dev->release_sem, HZ);
        //It will be deallocated in write callback
        dev->fei=NULL;
    }
    tmsi_release_dev(dev);
    return retval;
}
开发者ID:niklasrogers,项目名称:openbci,代码行数:21,代码来源:tmsi.c

示例9: ve_spc_read_sys_cfg

static int ve_spc_read_sys_cfg(int func, int offset, uint32_t *data)
{
	int ret;

	if (down_timeout(&info->sem, usecs_to_jiffies(TIMEOUT_US)))
		return -ETIME;

	init_completion(&info->done);
	info->cur_rsp_mask = RESPONSE_MASK(SPC_SYS_CFG);

	/* Set the control value */
	writel(SYSCFG_START | func | offset >> 2, info->baseaddr + COMMS);
	ret = ve_spc_waitforcompletion(SPC_SYS_CFG);

	if (ret == 0)
		*data = readl(info->baseaddr + SYSCFG_RDATA);

	info->cur_rsp_mask = 0;
	up(&info->sem);

	return ret;
}
开发者ID:BinVul,项目名称:linux2.6.32,代码行数:22,代码来源:spc.c

示例10: tmsi_read

static ssize_t tmsi_read(struct file *file, char *buffer, size_t count, loff_t *ppos) {
    struct tmsi_data* dev;
    char* temp_buffer = NULL;
    int retval = 0;
    size_t true_count;
    dev = (struct tmsi_data*) file->private_data;
    if (down_timeout(dev->fifo_sem, HZ / 2) != 0)
        return -ETIME;
    while (down_trylock(dev->fifo_sem) == 0);

    temp_buffer = kmalloc(count, GFP_KERNEL);

    if (!temp_buffer) {
        retval = -ENOMEM;
        goto exit;
    }


#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,35)
    true_count = kfifo_out_spinlocked(dev->packet_buffer, temp_buffer, count, &dev->buffer_lock);
#elif LINUX_VERSION_CODE > KERNEL_VERSION(2,6,32)
    true_count = kfifo_out_locked(dev->packet_buffer, temp_buffer, count, &dev->buffer_lock);
#else
    true_count = kfifo_get(dev->packet_buffer, temp_buffer, count);
#endif


    /* if the read was successful, copy the data to userspace */
    if (copy_to_user(buffer, temp_buffer, true_count))
        retval = -EFAULT;
    else
        retval = true_count;

    kfree(temp_buffer);
exit:
    if (kfifo_len(dev->packet_buffer) > 0)
        up(dev->fifo_sem);
    return retval;
}
开发者ID:niklasrogers,项目名称:openbci,代码行数:39,代码来源:tmsi.c

示例11: ttyio_in

static unsigned char ttyio_in(int timeout)
{
	struct spk_ldisc_data *ldisc_data = speakup_tty->disc_data;
	char rv;

	if (down_timeout(&ldisc_data->sem, usecs_to_jiffies(timeout)) == -ETIME) {
		if (timeout)
			pr_warn("spk_ttyio: timeout (%d)  while waiting for input\n",
				timeout);
		return 0xff;
	}

	rv = ldisc_data->buf;
	/* Make sure we have read buf before we set buf_free to let
	 * the producer overwrite it */
	mb();
	ldisc_data->buf_free = true;
	/* Let TTY push more characters */
	tty_schedule_flip(speakup_tty->port);

	return rv;
}
开发者ID:mkrufky,项目名称:linux,代码行数:22,代码来源:spk_ttyio.c

示例12: acpi_os_wait_semaphore

/*
 * TODO: Support for units > 1?
 */
acpi_status acpi_os_wait_semaphore(acpi_handle handle, u32 units, u16 timeout)
{
	acpi_status status = AE_OK;
	struct semaphore *sem = (struct semaphore *)handle;
	long jiffies;
	int ret = 0;

	if (!sem || (units < 1))
		return AE_BAD_PARAMETER;

	if (units > 1)
		return AE_SUPPORT;

	ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Waiting for semaphore[%p|%d|%d]\n",
			  handle, units, timeout));

	if (timeout == ACPI_WAIT_FOREVER)
		jiffies = MAX_SCHEDULE_TIMEOUT;
	else
		jiffies = msecs_to_jiffies(timeout);
	
	ret = down_timeout(sem, jiffies);
	if (ret)
		status = AE_TIME;

	if (ACPI_FAILURE(status)) {
		ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
				  "Failed to acquire semaphore[%p|%d|%d], %s",
				  handle, units, timeout,
				  acpi_format_exception(status)));
	} else {
		ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
				  "Acquired semaphore[%p|%d|%d]", handle,
				  units, timeout));
	}

	return status;
}
开发者ID:AiWinters,项目名称:linux,代码行数:41,代码来源:osl.c

示例13: spin_lock_irqsave

static struct sk_buff *dequeue_rx_queue(struct rx_queue *q, long timeout) {
   unsigned long flags;
   struct sk_buff *skb = NULL;
   if (timeout == 0) {
      if (0==down_interruptible(&q->rx_sem)) {
         spin_lock_irqsave(&q->spin, flags);
         skb = q->skb;
         q->skb = NULL;
         while(!down_trylock(&q->rx_sem));
         spin_unlock_irqrestore(&q->spin, flags);
      }
   } else if (0==down_timeout(&q->rx_sem, msecs_to_jiffies(timeout))) {
      spin_lock_irqsave(&q->spin, flags);
      skb = q->skb;
      q->skb = NULL;
      while(!down_trylock(&q->rx_sem)){
    	  printk(KERN_ERR "Spinning\n");
      }
      spin_unlock_irqrestore(&q->spin, flags);
   }

   return skb;
}
开发者ID:dantard,项目名称:unizar-rt-wmp-ros-pkg,代码行数:23,代码来源:rt_wmp.c

示例14: WILC_SemaphoreAcquire

WILC_ErrNo WILC_SemaphoreAcquire(WILC_SemaphoreHandle* pHandle,
	tstrWILC_SemaphoreAttrs* pstrAttrs)
{
	WILC_ErrNo s32RetStatus = WILC_SUCCESS;

	#ifndef CONFIG_WILC_SEMAPHORE_TIMEOUT
	while(down_interruptible(pHandle)); //jude

	#else
	if(pstrAttrs == WILC_NULL)
	{
		down(pHandle);
	}
	else
	{
		
		s32RetStatus = down_timeout(pHandle, msecs_to_jiffies(pstrAttrs->u32TimeOut));
	}
	#endif

	if(s32RetStatus == 0)
	{
		return WILC_SUCCESS;
	}
	else if (s32RetStatus == -ETIME)
	{
		return WILC_TIMEOUT;
	}
	else
	{
		return WILC_FAIL;
	}
	
	return WILC_SUCCESS;
	
}
开发者ID:demo4sc,项目名称:patch,代码行数:36,代码来源:wilc_semaphore.c

示例15: validate_lbr

void validate_lbr(void) {
#ifdef ARMOR_JIT
    uint8_t hash[DIGEST_LENGTH];
    int i;
    struct lbr_t lbr;
    struct timeval time;
    unsigned long jit_start_j, jit_stop_j, jit_delta_j;
    printk("total validate lbr state %ld\n",total_count++); 

    get_cpu();
    get_lbr(&lbr);
    dump_lbr(&lbr);
    put_cpu();

    if (disable_jit) {
        printk("[validation] -- WARNING -- JIT disabled!\n");
        return;
    }

    printdj(true,"[validation] JIT: Acquiring lock...\n");
    mutex_lock(&validation_lock);

    printdj(true,"[validation] JIT: Lookup\n");
    ARMOR_STAT_INC(jit_lookups);
    
    /* Compute a hash of the lbr and look it up in the cache. */
    hash_lbr(hash,&lbr);
    for (i = 0; i < jit_cache.hashes; i++) {
        if (memcmp(jit_cache.hash[i], hash, DIGEST_LENGTH) == 0) { 
            ARMOR_STAT_INC(jit_cache_hits);
#ifdef ARMOR_DEBUG_JIT
            printk("[validation] LBR state is valid (found in JIT cache)\n");
#endif
            mutex_unlock(&validation_lock);
            return;
        }
    }

    /* Not found in cache. Let's ask Dennis. Using Enes' semaphore design. */
    ARMOR_STAT_INC(jit_requests);
    jit_work = &lbr;

    printdj(true, "[validation] JIT: Request\n");

    /* Start the timers. */
    jit_start_j = jiffies;
    up(&jit_work_cond);

    printdj(true, "[validation] JIT: Waiting\n");
    if (down_timeout(&jit_result_cond, jit_waittime) < 0) {
        printk("[validation] JIT: Timeout\n");
        ARMOR_STAT_INC(jit_timeouts);
        disable_jit = 1;
        mutex_unlock(&validation_lock);
        return;
    }

    /* Stop the timers. */
    jit_stop_j = jiffies;
    jit_delta_j = jit_stop_j - jit_start_j;

    /* JIT may be faster than we can measure jiffies. If this happens, assume a
     * half jiffie was used.
     * http://stackoverflow.com/questions/10392735/am-i-too-fast-to-count-jiffies
     */
    if (jit_delta_j == 0) jit_delta_j = stats.jit_lookups % 2;
    printdj(true, "That took us %lu jiffies\n",     jit_delta_j);

            
    jiffies_to_timeval(jit_delta_j, &time);
    ARMOR_STAT_ADD(jit_sec, time.tv_sec);
    ARMOR_STAT_ADD(jit_usec, time.tv_usec);

    printdj(true, "[validation] JIT: Processing result\n");
    if (jit_result == 0) {
        printk("[validation] -- WARNING -- LBR state rendered *INVALID* by jit-analyzer\n");
        ARMOR_STAT_INC(jit_misses);
//      kill_pid(task_pid(current), SIGKILL, 1);
 
        printk("[validation] -- WARNING -- ASSUMING VALID\n");
        goto assume_valid;
    }
    if (jit_result == 2) {
        printk("[validation] -- WARNING -- LBR state not validated due to uninstrumentable function\n");
        ARMOR_STAT_INC(jit_unsupported);

        printk("[validation] -- WARNING -- ASSUMING VALID\n");
        goto assume_valid;
    }
    if (jit_result == 1) {
        ARMOR_STAT_INC(jit_hits);

assume_valid:
        /* Dennis' says it is ok. Let's add it to the - circular - cache so he
         * can take some time off next time. */
        /* TODO, this should probably be a sorted linked list so that we can do a binary search? */
        memcpy(jit_cache.hash[jit_cache.hashes], hash, DIGEST_LENGTH);
        jit_cache.hashes = (jit_cache.hashes + 1) % JIT_CACHE_SIZE;

#ifdef ARMOR_DEBUG_JIT
//.........这里部分代码省略.........
开发者ID:aiaxun,项目名称:KernelModule,代码行数:101,代码来源:lbr.c


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