2014年(4)
分类: 嵌入式
2014-04-23 22:22:56
void do_sys_times(struct tms *tms)
{
cputime_t tgutime, tgstime, cutime, cstime;spin_lock_irq(¤t->sighand->siglock);
thread_group_times(current, &tgutime, &tgstime);
cutime = current->signal->cutime;
cstime = current->signal->cstime;
spin_unlock_irq(¤t->sighand->siglock);
tms->tms_utime = cputime_to_clock_t(tgutime);
tms->tms_stime = cputime_to_clock_t(tgstime);
tms->tms_cutime = cputime_to_clock_t(cutime);
tms->tms_cstime = cputime_to_clock_t(cstime);
}
SYSCALL_DEFINE1(times, struct tms __user *, tbuf)
{
if (tbuf) {
struct tms tmp;do_sys_times(&tmp);
if (copy_to_user(tbuf, &tmp, sizeof(struct tms)))
return -EFAULT;
}
force_successful_syscall_return();
return (long) jiffies_64_to_clock_t(get_jiffies_64());
}
当参数为NULL时,此时if语句就不会进去,系统就不会对该进程的所有线程进行扫描,从而提高性能!如果不传NULL,也可以直接
将if语句屏蔽。