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

C++ secs_to_cputime函数代码示例

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

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



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

示例1: posix_cpu_timers_init_group

/*
 * Initialize POSIX timer handling for a thread group.
 */
static void posix_cpu_timers_init_group(struct signal_struct *sig)
{
	/* Thread group counters. */
	thread_group_cputime_init(sig);

	/* Expiration times and increments. */
	sig->it[CPUCLOCK_PROF].expires = cputime_zero;
	sig->it[CPUCLOCK_PROF].incr = cputime_zero;
	sig->it[CPUCLOCK_VIRT].expires = cputime_zero;
	sig->it[CPUCLOCK_VIRT].incr = cputime_zero;

	/* Cached expiration times. */
	sig->cputime_expires.prof_exp = cputime_zero;
	sig->cputime_expires.virt_exp = cputime_zero;
	sig->cputime_expires.sched_exp = 0;

	if (sig->rlim[RLIMIT_CPU].rlim_cur != RLIM_INFINITY) {
		sig->cputime_expires.prof_exp =
			secs_to_cputime(sig->rlim[RLIMIT_CPU].rlim_cur);
		sig->cputimer.running = 1;
	}

	/* The timer lists. */
	INIT_LIST_HEAD(&sig->cpu_timers[0]);
	INIT_LIST_HEAD(&sig->cpu_timers[1]);
	INIT_LIST_HEAD(&sig->cpu_timers[2]);
}
开发者ID:genua,项目名称:anoubis_os,代码行数:30,代码来源:fork.c


示例2: update_rlimit_cpu

/*
 * Called after updating RLIMIT_CPU to run cpu timer and update
 * tsk->signal->cputime_expires expiration cache if necessary. Needs
 * siglock protection since other code may update expiration cache as
 * well.
 */
void update_rlimit_cpu(struct task_struct *task, unsigned long rlim_new)
{
	cputime_t cputime = secs_to_cputime(rlim_new);

	spin_lock_irq(&task->sighand->siglock);
	set_process_cpu_timer(task, CPUCLOCK_PROF, &cputime, NULL);
	spin_unlock_irq(&task->sighand->siglock);
}
开发者ID:Ayokunle,项目名称:linux,代码行数:14,代码来源:posix-cpu-timers.c


示例3: update_rlimit_cpu

/*
 * Called after updating RLIMIT_CPU to set timer expiration if necessary.
 */
void update_rlimit_cpu(unsigned long rlim_new)
{
	cputime_t cputime;

	cputime = secs_to_cputime(rlim_new);
	if (cputime_eq(current->signal->it_prof_expires, cputime_zero) ||
	    cputime_gt(current->signal->it_prof_expires, cputime)) {
		spin_lock_irq(&current->sighand->siglock);
		set_process_cpu_timer(current, CPUCLOCK_PROF, &cputime, NULL);
		spin_unlock_irq(&current->sighand->siglock);
	}
}
开发者ID:midyer,项目名称:linux-legacy,代码行数:15,代码来源:posix-cpu-timers.c


示例4: posix_cpu_timers_init_group

/*
 * Initialize POSIX timer handling for a thread group.
 */
static void posix_cpu_timers_init_group(struct signal_struct *sig)
{
	unsigned long cpu_limit;

	cpu_limit = READ_ONCE(sig->rlim[RLIMIT_CPU].rlim_cur);
	if (cpu_limit != RLIM_INFINITY) {
		sig->cputime_expires.prof_exp = secs_to_cputime(cpu_limit);
		sig->cputimer.running = 1;
	}

	/* The timer lists. */
	INIT_LIST_HEAD(&sig->cpu_timers[0]);
	INIT_LIST_HEAD(&sig->cpu_timers[1]);
	INIT_LIST_HEAD(&sig->cpu_timers[2]);
}
开发者ID:lovejavaee,项目名称:linux-2,代码行数:18,代码来源:fork.c


示例5: cs_wfo_mac_table_init

void cs_wfo_mac_table_init(void)
{
    memset((void*)(&mac_table_802_3[0]), 0, sizeof(struct wfo_mac_table_entry)*WFO_MAC_ENTRY_SIZE);
    memset((void*)(&mac_table_802_11[0]), 0, sizeof(struct wfo_mac_table_entry)*WFO_MAC_ENTRY_SIZE);

    spin_lock_init(&table_802_3_lock);
    spin_lock_init(&table_802_11_lock);

    //aging may not be needed right now, low priority
    init_timer(&wfo_mac_timer);

    wfo_mac_timer.expires = jiffies + secs_to_cputime(WFO_MAC_ENTRY_TIMER_PERIOD);
    wfo_mac_timer.function = &cs_wfo_mac_table_timer_func;
    return;
}
开发者ID:xtra72,项目名称:s805,代码行数:15,代码来源:cs75xx_wfo.c


示例6: sys_setrlimit

asmlinkage long sys_setrlimit(unsigned int resource, struct rlimit __user *rlim)
{
    struct rlimit new_rlim, *old_rlim;
    int retval;

    if (resource >= RLIM_NLIMITS)
        return -EINVAL;
    if(copy_from_user(&new_rlim, rlim, sizeof(*rlim)))
        return -EFAULT;
    if (new_rlim.rlim_cur > new_rlim.rlim_max)
        return -EINVAL;
    old_rlim = current->signal->rlim + resource;
    if ((new_rlim.rlim_max > old_rlim->rlim_max) &&
            !capable(CAP_SYS_RESOURCE))
        return -EPERM;
    if (resource == RLIMIT_NOFILE && new_rlim.rlim_max > NR_OPEN)
        return -EPERM;

    retval = security_task_setrlimit(resource, &new_rlim);
    if (retval)
        return retval;

    task_lock(current->group_leader);
    *old_rlim = new_rlim;
    task_unlock(current->group_leader);

    if (resource == RLIMIT_CPU && new_rlim.rlim_cur != RLIM_INFINITY &&
            (cputime_eq(current->signal->it_prof_expires, cputime_zero) ||
             new_rlim.rlim_cur <= cputime_to_secs(
                 current->signal->it_prof_expires))) {
        cputime_t cputime = secs_to_cputime(new_rlim.rlim_cur);
        read_lock(&tasklist_lock);
        spin_lock_irq(&current->sighand->siglock);
        set_process_cpu_timer(current, CPUCLOCK_PROF,
                              &cputime, NULL);
        spin_unlock_irq(&current->sighand->siglock);
        read_unlock(&tasklist_lock);
    }

    return 0;
}
开发者ID:BackupTheBerlios,项目名称:tew632-brp-svn,代码行数:41,代码来源:sys.c


示例7: cs_wfo_mac_table_timer_func

void cs_wfo_mac_table_timer_func(unsigned long data)
{
    int i;
    int resched = 0;

    //age 802.3 MACs
    spin_lock(&table_802_3_lock);
    for(i = 0; i < WFO_MAC_ENTRY_SIZE; i++) {
        if(mac_table_802_3[i].status == WFO_MAC_ENTRY_VALID) {
            if(mac_table_802_3[i].timeout++ > WFO_MAX_MAC_AGING_COUNT)
               memset(&mac_table_802_3[i], 0, sizeof(struct wfo_mac_table_entry));
            else
                resched = 1;
        }
    }
    spin_unlock(&table_802_3_lock);

    //age 802.11 MACs
    spin_lock(&table_802_11_lock);
    for(i = 0; i < WFO_MAC_ENTRY_SIZE; i++) {
        if(mac_table_802_11[i].status == WFO_MAC_ENTRY_VALID) {
            if(mac_table_802_11[i].timeout++ > WFO_MAX_MAC_AGING_COUNT)
                memset(&mac_table_802_11[i], 0, sizeof(struct wfo_mac_table_entry));
            else
               resched = 1;
        }
    }
    spin_unlock(&table_802_11_lock);

#if 0
    if (resched)
        mod_timer(&wfo_mac_timer, jiffies + secs_to_cputime(WFO_MAC_ENTRY_TIMER_PERIOD));
#endif

    return;
}
开发者ID:xtra72,项目名称:s805,代码行数:36,代码来源:cs75xx_wfo.c


示例8: sys_setrlimit

asmlinkage long sys_setrlimit(unsigned int resource, struct rlimit __user *rlim)
{
	struct rlimit new_rlim, *old_rlim;
	unsigned long it_prof_secs;
	int retval;

	if (resource >= RLIM_NLIMITS)
		return -EINVAL;
	if (copy_from_user(&new_rlim, rlim, sizeof(*rlim)))
		return -EFAULT;
	if (new_rlim.rlim_cur > new_rlim.rlim_max)
		return -EINVAL;
	old_rlim = current->signal->rlim + resource;
	if ((new_rlim.rlim_max > old_rlim->rlim_max) &&
	    !capable(CAP_SYS_RESOURCE))
		return -EPERM;
	if (resource == RLIMIT_NOFILE && new_rlim.rlim_max > sysctl_nr_open)
		return -EPERM;

	retval = security_task_setrlimit(resource, &new_rlim);
	if (retval)
		return retval;

	if (resource == RLIMIT_CPU && new_rlim.rlim_cur == 0) {
		/*
		 * The caller is asking for an immediate RLIMIT_CPU
		 * expiry.  But we use the zero value to mean "it was
		 * never set".  So let's cheat and make it one second
		 * instead
		 */
		new_rlim.rlim_cur = 1;
	}

	task_lock(current->group_leader);
	*old_rlim = new_rlim;
	task_unlock(current->group_leader);

	if (resource != RLIMIT_CPU)
		goto out;

	/*
	 * RLIMIT_CPU handling.   Note that the kernel fails to return an error
	 * code if it rejected the user's attempt to set RLIMIT_CPU.  This is a
	 * very long-standing error, and fixing it now risks breakage of
	 * applications, so we live with it
	 */
	if (new_rlim.rlim_cur == RLIM_INFINITY)
		goto out;

	it_prof_secs = cputime_to_secs(current->signal->it_prof_expires);
	if (it_prof_secs == 0 || new_rlim.rlim_cur <= it_prof_secs) {
		unsigned long rlim_cur = new_rlim.rlim_cur;
		cputime_t cputime;

		cputime = secs_to_cputime(rlim_cur);
		read_lock(&tasklist_lock);
		spin_lock_irq(&current->sighand->siglock);
		set_process_cpu_timer(current, CPUCLOCK_PROF, &cputime, NULL);
		spin_unlock_irq(&current->sighand->siglock);
		read_unlock(&tasklist_lock);
	}
out:
	return 0;
}
开发者ID:maraz,项目名称:linux-2.6,代码行数:64,代码来源:sys.c


示例9: copy_signal

static inline int copy_signal(unsigned long clone_flags, struct task_struct * tsk)
{
	struct signal_struct *sig;
	int ret;

	if (clone_flags & CLONE_THREAD) {
		atomic_inc(&current->signal->count);
		atomic_inc(&current->signal->live);
		return 0;
	}
	sig = kmem_cache_alloc(signal_cachep, GFP_KERNEL);
	tsk->signal = sig;
	if (!sig)
		return -ENOMEM;

	ret = copy_thread_group_keys(tsk);
	if (ret < 0) {
		kmem_cache_free(signal_cachep, sig);
		return ret;
	}

	atomic_set(&sig->count, 1);
	atomic_set(&sig->live, 1);
	init_waitqueue_head(&sig->wait_chldexit);
	sig->flags = 0;
	sig->group_exit_code = 0;
	sig->group_exit_task = NULL;
	sig->group_stop_count = 0;
	sig->curr_target = NULL;
	init_sigpending(&sig->shared_pending);
	INIT_LIST_HEAD(&sig->posix_timers);

	sig->it_real_value = sig->it_real_incr = 0;
	sig->real_timer.function = it_real_fn;
	sig->real_timer.data = (unsigned long) tsk;
	init_timer(&sig->real_timer);

	sig->it_virt_expires = cputime_zero;
	sig->it_virt_incr = cputime_zero;
	sig->it_prof_expires = cputime_zero;
	sig->it_prof_incr = cputime_zero;

	sig->tty = current->signal->tty;
	sig->pgrp = process_group(current);
	sig->session = current->signal->session;
	sig->leader = 0;	/* session leadership doesn't inherit */
	sig->tty_old_pgrp = 0;

	sig->utime = sig->stime = sig->cutime = sig->cstime = cputime_zero;
	sig->nvcsw = sig->nivcsw = sig->cnvcsw = sig->cnivcsw = 0;
	sig->min_flt = sig->maj_flt = sig->cmin_flt = sig->cmaj_flt = 0;
	sig->sched_time = 0;
	INIT_LIST_HEAD(&sig->cpu_timers[0]);
	INIT_LIST_HEAD(&sig->cpu_timers[1]);
	INIT_LIST_HEAD(&sig->cpu_timers[2]);

	task_lock(current->group_leader);
	memcpy(sig->rlim, current->signal->rlim, sizeof sig->rlim);
	task_unlock(current->group_leader);

	if (sig->rlim[RLIMIT_CPU].rlim_cur != RLIM_INFINITY) {
		/*
		 * New sole thread in the process gets an expiry time
		 * of the whole CPU time limit.
		 */
		tsk->it_prof_expires =
			secs_to_cputime(sig->rlim[RLIMIT_CPU].rlim_cur);
	}

	return 0;
}
开发者ID:Pating,项目名称:linux-2.6.12-rc2,代码行数:71,代码来源:fork.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ section函数代码示例发布时间:2022-05-30
下一篇:
C++ secsToTimeString函数代码示例发布时间: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