亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? posix-cpu-timers.c

?? Kernel code of linux kernel
?? C
?? 第 1 頁 / 共 3 頁
字號:
/* * Implement CPU time clocks for the POSIX clock interface. */#include <linux/sched.h>#include <linux/posix-timers.h>#include <linux/errno.h>#include <linux/math64.h>#include <asm/uaccess.h>static int check_clock(const clockid_t which_clock){	int error = 0;	struct task_struct *p;	const pid_t pid = CPUCLOCK_PID(which_clock);	if (CPUCLOCK_WHICH(which_clock) >= CPUCLOCK_MAX)		return -EINVAL;	if (pid == 0)		return 0;	read_lock(&tasklist_lock);	p = find_task_by_vpid(pid);	if (!p || !(CPUCLOCK_PERTHREAD(which_clock) ?		   same_thread_group(p, current) : thread_group_leader(p))) {		error = -EINVAL;	}	read_unlock(&tasklist_lock);	return error;}static inline union cpu_time_counttimespec_to_sample(const clockid_t which_clock, const struct timespec *tp){	union cpu_time_count ret;	ret.sched = 0;		/* high half always zero when .cpu used */	if (CPUCLOCK_WHICH(which_clock) == CPUCLOCK_SCHED) {		ret.sched = (unsigned long long)tp->tv_sec * NSEC_PER_SEC + tp->tv_nsec;	} else {		ret.cpu = timespec_to_cputime(tp);	}	return ret;}static void sample_to_timespec(const clockid_t which_clock,			       union cpu_time_count cpu,			       struct timespec *tp){	if (CPUCLOCK_WHICH(which_clock) == CPUCLOCK_SCHED)		*tp = ns_to_timespec(cpu.sched);	else		cputime_to_timespec(cpu.cpu, tp);}static inline int cpu_time_before(const clockid_t which_clock,				  union cpu_time_count now,				  union cpu_time_count then){	if (CPUCLOCK_WHICH(which_clock) == CPUCLOCK_SCHED) {		return now.sched < then.sched;	}  else {		return cputime_lt(now.cpu, then.cpu);	}}static inline void cpu_time_add(const clockid_t which_clock,				union cpu_time_count *acc,			        union cpu_time_count val){	if (CPUCLOCK_WHICH(which_clock) == CPUCLOCK_SCHED) {		acc->sched += val.sched;	}  else {		acc->cpu = cputime_add(acc->cpu, val.cpu);	}}static inline union cpu_time_count cpu_time_sub(const clockid_t which_clock,						union cpu_time_count a,						union cpu_time_count b){	if (CPUCLOCK_WHICH(which_clock) == CPUCLOCK_SCHED) {		a.sched -= b.sched;	}  else {		a.cpu = cputime_sub(a.cpu, b.cpu);	}	return a;}/* * Divide and limit the result to res >= 1 * * This is necessary to prevent signal delivery starvation, when the result of * the division would be rounded down to 0. */static inline cputime_t cputime_div_non_zero(cputime_t time, unsigned long div){	cputime_t res = cputime_div(time, div);	return max_t(cputime_t, res, 1);}/* * Update expiry time from increment, and increase overrun count, * given the current clock sample. */static void bump_cpu_timer(struct k_itimer *timer,				  union cpu_time_count now){	int i;	if (timer->it.cpu.incr.sched == 0)		return;	if (CPUCLOCK_WHICH(timer->it_clock) == CPUCLOCK_SCHED) {		unsigned long long delta, incr;		if (now.sched < timer->it.cpu.expires.sched)			return;		incr = timer->it.cpu.incr.sched;		delta = now.sched + incr - timer->it.cpu.expires.sched;		/* Don't use (incr*2 < delta), incr*2 might overflow. */		for (i = 0; incr < delta - incr; i++)			incr = incr << 1;		for (; i >= 0; incr >>= 1, i--) {			if (delta < incr)				continue;			timer->it.cpu.expires.sched += incr;			timer->it_overrun += 1 << i;			delta -= incr;		}	} else {		cputime_t delta, incr;		if (cputime_lt(now.cpu, timer->it.cpu.expires.cpu))			return;		incr = timer->it.cpu.incr.cpu;		delta = cputime_sub(cputime_add(now.cpu, incr),				    timer->it.cpu.expires.cpu);		/* Don't use (incr*2 < delta), incr*2 might overflow. */		for (i = 0; cputime_lt(incr, cputime_sub(delta, incr)); i++)			     incr = cputime_add(incr, incr);		for (; i >= 0; incr = cputime_halve(incr), i--) {			if (cputime_lt(delta, incr))				continue;			timer->it.cpu.expires.cpu =				cputime_add(timer->it.cpu.expires.cpu, incr);			timer->it_overrun += 1 << i;			delta = cputime_sub(delta, incr);		}	}}static inline cputime_t prof_ticks(struct task_struct *p){	return cputime_add(p->utime, p->stime);}static inline cputime_t virt_ticks(struct task_struct *p){	return p->utime;}static inline unsigned long long sched_ns(struct task_struct *p){	return task_sched_runtime(p);}int posix_cpu_clock_getres(const clockid_t which_clock, struct timespec *tp){	int error = check_clock(which_clock);	if (!error) {		tp->tv_sec = 0;		tp->tv_nsec = ((NSEC_PER_SEC + HZ - 1) / HZ);		if (CPUCLOCK_WHICH(which_clock) == CPUCLOCK_SCHED) {			/*			 * If sched_clock is using a cycle counter, we			 * don't have any idea of its true resolution			 * exported, but it is much more than 1s/HZ.			 */			tp->tv_nsec = 1;		}	}	return error;}int posix_cpu_clock_set(const clockid_t which_clock, const struct timespec *tp){	/*	 * You can never reset a CPU clock, but we check for other errors	 * in the call before failing with EPERM.	 */	int error = check_clock(which_clock);	if (error == 0) {		error = -EPERM;	}	return error;}/* * Sample a per-thread clock for the given task. */static int cpu_clock_sample(const clockid_t which_clock, struct task_struct *p,			    union cpu_time_count *cpu){	switch (CPUCLOCK_WHICH(which_clock)) {	default:		return -EINVAL;	case CPUCLOCK_PROF:		cpu->cpu = prof_ticks(p);		break;	case CPUCLOCK_VIRT:		cpu->cpu = virt_ticks(p);		break;	case CPUCLOCK_SCHED:		cpu->sched = sched_ns(p);		break;	}	return 0;}/* * Sample a process (thread group) clock for the given group_leader task. * Must be called with tasklist_lock held for reading. * Must be called with tasklist_lock held for reading, and p->sighand->siglock. */static int cpu_clock_sample_group_locked(unsigned int clock_idx,					 struct task_struct *p,					 union cpu_time_count *cpu){	struct task_struct *t = p; 	switch (clock_idx) {	default:		return -EINVAL;	case CPUCLOCK_PROF:		cpu->cpu = cputime_add(p->signal->utime, p->signal->stime);		do {			cpu->cpu = cputime_add(cpu->cpu, prof_ticks(t));			t = next_thread(t);		} while (t != p);		break;	case CPUCLOCK_VIRT:		cpu->cpu = p->signal->utime;		do {			cpu->cpu = cputime_add(cpu->cpu, virt_ticks(t));			t = next_thread(t);		} while (t != p);		break;	case CPUCLOCK_SCHED:		cpu->sched = p->signal->sum_sched_runtime;		/* Add in each other live thread.  */		while ((t = next_thread(t)) != p) {			cpu->sched += t->se.sum_exec_runtime;		}		cpu->sched += sched_ns(p);		break;	}	return 0;}/* * Sample a process (thread group) clock for the given group_leader task. * Must be called with tasklist_lock held for reading. */static int cpu_clock_sample_group(const clockid_t which_clock,				  struct task_struct *p,				  union cpu_time_count *cpu){	int ret;	unsigned long flags;	spin_lock_irqsave(&p->sighand->siglock, flags);	ret = cpu_clock_sample_group_locked(CPUCLOCK_WHICH(which_clock), p,					    cpu);	spin_unlock_irqrestore(&p->sighand->siglock, flags);	return ret;}int posix_cpu_clock_get(const clockid_t which_clock, struct timespec *tp){	const pid_t pid = CPUCLOCK_PID(which_clock);	int error = -EINVAL;	union cpu_time_count rtn;	if (pid == 0) {		/*		 * Special case constant value for our own clocks.		 * We don't have to do any lookup to find ourselves.		 */		if (CPUCLOCK_PERTHREAD(which_clock)) {			/*			 * Sampling just ourselves we can do with no locking.			 */			error = cpu_clock_sample(which_clock,						 current, &rtn);		} else {			read_lock(&tasklist_lock);			error = cpu_clock_sample_group(which_clock,						       current, &rtn);			read_unlock(&tasklist_lock);		}	} else {		/*		 * Find the given PID, and validate that the caller		 * should be able to see it.		 */		struct task_struct *p;		rcu_read_lock();		p = find_task_by_vpid(pid);		if (p) {			if (CPUCLOCK_PERTHREAD(which_clock)) {				if (same_thread_group(p, current)) {					error = cpu_clock_sample(which_clock,								 p, &rtn);				}			} else {				read_lock(&tasklist_lock);				if (thread_group_leader(p) && p->signal) {					error =					    cpu_clock_sample_group(which_clock,							           p, &rtn);				}				read_unlock(&tasklist_lock);			}		}		rcu_read_unlock();	}	if (error)		return error;	sample_to_timespec(which_clock, rtn, tp);	return 0;}/* * Validate the clockid_t for a new CPU-clock timer, and initialize the timer. * This is called from sys_timer_create with the new timer already locked. */int posix_cpu_timer_create(struct k_itimer *new_timer){	int ret = 0;	const pid_t pid = CPUCLOCK_PID(new_timer->it_clock);	struct task_struct *p;	if (CPUCLOCK_WHICH(new_timer->it_clock) >= CPUCLOCK_MAX)		return -EINVAL;	INIT_LIST_HEAD(&new_timer->it.cpu.entry);	new_timer->it.cpu.incr.sched = 0;	new_timer->it.cpu.expires.sched = 0;	read_lock(&tasklist_lock);	if (CPUCLOCK_PERTHREAD(new_timer->it_clock)) {		if (pid == 0) {			p = current;		} else {			p = find_task_by_vpid(pid);			if (p && !same_thread_group(p, current))				p = NULL;		}	} else {		if (pid == 0) {			p = current->group_leader;		} else {			p = find_task_by_vpid(pid);			if (p && !thread_group_leader(p))				p = NULL;		}	}	new_timer->it.cpu.task = p;	if (p) {		get_task_struct(p);	} else {		ret = -EINVAL;	}	read_unlock(&tasklist_lock);	return ret;}/* * Clean up a CPU-clock timer that is about to be destroyed. * This is called from timer deletion with the timer already locked. * If we return TIMER_RETRY, it's necessary to release the timer's lock * and try again.  (This happens when the timer is in the middle of firing.) */int posix_cpu_timer_del(struct k_itimer *timer){	struct task_struct *p = timer->it.cpu.task;	int ret = 0;	if (likely(p != NULL)) {		read_lock(&tasklist_lock);		if (unlikely(p->signal == NULL)) {			/*			 * We raced with the reaping of the task.			 * The deletion should have cleared us off the list.			 */			BUG_ON(!list_empty(&timer->it.cpu.entry));		} else {			spin_lock(&p->sighand->siglock);			if (timer->it.cpu.firing)				ret = TIMER_RETRY;			else				list_del(&timer->it.cpu.entry);			spin_unlock(&p->sighand->siglock);		}		read_unlock(&tasklist_lock);		if (!ret)			put_task_struct(p);	}	return ret;}/* * Clean out CPU timers still ticking when a thread exited.  The task * pointer is cleared, and the expiry time is replaced with the residual * time for later timer_gettime calls to return. * This must be called with the siglock held. */static void cleanup_timers(struct list_head *head,			   cputime_t utime, cputime_t stime,			   unsigned long long sum_exec_runtime){	struct cpu_timer_list *timer, *next;	cputime_t ptime = cputime_add(utime, stime);	list_for_each_entry_safe(timer, next, head, entry) {		list_del_init(&timer->entry);		if (cputime_lt(timer->expires.cpu, ptime)) {			timer->expires.cpu = cputime_zero;		} else {			timer->expires.cpu = cputime_sub(timer->expires.cpu,							 ptime);		}	}	++head;	list_for_each_entry_safe(timer, next, head, entry) {		list_del_init(&timer->entry);		if (cputime_lt(timer->expires.cpu, utime)) {			timer->expires.cpu = cputime_zero;		} else {			timer->expires.cpu = cputime_sub(timer->expires.cpu,							 utime);		}	}	++head;	list_for_each_entry_safe(timer, next, head, entry) {		list_del_init(&timer->entry);		if (timer->expires.sched < sum_exec_runtime) {			timer->expires.sched = 0;		} else {			timer->expires.sched -= sum_exec_runtime;		}	}}/* * These are both called with the siglock held, when the current thread * is being reaped.  When the final (leader) thread in the group is reaped, * posix_cpu_timers_exit_group will be called after posix_cpu_timers_exit. */void posix_cpu_timers_exit(struct task_struct *tsk){	cleanup_timers(tsk->cpu_timers,		       tsk->utime, tsk->stime, tsk->se.sum_exec_runtime);}void posix_cpu_timers_exit_group(struct task_struct *tsk){	cleanup_timers(tsk->signal->cpu_timers,		       cputime_add(tsk->utime, tsk->signal->utime),		       cputime_add(tsk->stime, tsk->signal->stime),		     tsk->se.sum_exec_runtime + tsk->signal->sum_sched_runtime);}/* * Set the expiry times of all the threads in the process so one of them * will go off before the process cumulative expiry total is reached. */static void process_timer_rebalance(struct task_struct *p,				    unsigned int clock_idx,				    union cpu_time_count expires,				    union cpu_time_count val){	cputime_t ticks, left;	unsigned long long ns, nsleft; 	struct task_struct *t = p;	unsigned int nthreads = atomic_read(&p->signal->live);	if (!nthreads)		return;	switch (clock_idx) {	default:		BUG();		break;	case CPUCLOCK_PROF:		left = cputime_div_non_zero(cputime_sub(expires.cpu, val.cpu),				       nthreads);		do {			if (likely(!(t->flags & PF_EXITING))) {				ticks = cputime_add(prof_ticks(t), left);				if (cputime_eq(t->it_prof_expires,					       cputime_zero) ||				    cputime_gt(t->it_prof_expires, ticks)) {					t->it_prof_expires = ticks;				}			}			t = next_thread(t);		} while (t != p);		break;	case CPUCLOCK_VIRT:		left = cputime_div_non_zero(cputime_sub(expires.cpu, val.cpu),				       nthreads);		do {			if (likely(!(t->flags & PF_EXITING))) {				ticks = cputime_add(virt_ticks(t), left);				if (cputime_eq(t->it_virt_expires,					       cputime_zero) ||				    cputime_gt(t->it_virt_expires, ticks)) {					t->it_virt_expires = ticks;				}			}			t = next_thread(t);		} while (t != p);		break;	case CPUCLOCK_SCHED:		nsleft = expires.sched - val.sched;		do_div(nsleft, nthreads);		nsleft = max_t(unsigned long long, nsleft, 1);		do {			if (likely(!(t->flags & PF_EXITING))) {				ns = t->se.sum_exec_runtime + nsleft;				if (t->it_sched_expires == 0 ||				    t->it_sched_expires > ns) {					t->it_sched_expires = ns;				}			}			t = next_thread(t);		} while (t != p);		break;	}}static void clear_dead_task(struct k_itimer *timer, union cpu_time_count now){	/*	 * That's all for this thread or process.	 * We leave our residual in expires to be reported.

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲成人av电影在线| 中文字幕中文字幕一区| 日韩高清不卡在线| 91精品视频网| 国产一区在线精品| 久久精品一级爱片| 成人av小说网| 亚洲图片欧美综合| 欧美成人福利视频| 国产成人精品免费| 亚洲色图视频免费播放| 欧美情侣在线播放| 黑人巨大精品欧美一区| 国产精品久久久久久亚洲毛片 | 91国产免费看| 婷婷国产v国产偷v亚洲高清| 日韩一区二区中文字幕| 成人精品一区二区三区四区| 一区二区三区在线高清| 日韩欧美国产三级电影视频| 国产精品亚洲第一区在线暖暖韩国| 亚洲天堂成人网| 日韩欧美一级特黄在线播放| 成人午夜电影网站| 香港成人在线视频| 国产精品污www在线观看| 欧洲国内综合视频| 国产一区二区三区日韩| 一区二区三区四区在线播放| 日韩欧美亚洲国产精品字幕久久久| 成熟亚洲日本毛茸茸凸凹| 香蕉乱码成人久久天堂爱免费| 久久久国产午夜精品| 欧美日韩午夜在线| 99在线视频精品| 青青国产91久久久久久| 亚洲免费高清视频在线| 精品成人a区在线观看| 色老综合老女人久久久| 精品一区二区日韩| 亚洲国产wwwccc36天堂| 中文字幕电影一区| 日韩欧美一级精品久久| 在线观看亚洲专区| 成人精品免费看| 日韩中文欧美在线| 一二三四区精品视频| 国产精品乱码一区二三区小蝌蚪| 欧美挠脚心视频网站| 97精品国产露脸对白| 精东粉嫩av免费一区二区三区| 亚洲自拍另类综合| 国产欧美1区2区3区| 欧美一级欧美三级| 91久久精品一区二区三区| 国产成人精品免费网站| 极品少妇xxxx精品少妇| 日本vs亚洲vs韩国一区三区二区 | 精品国产免费一区二区三区四区| 色综合天天性综合| www.亚洲色图| 盗摄精品av一区二区三区| 国内精品国产成人| 免费精品视频在线| 蜜臀av性久久久久av蜜臀妖精| 性久久久久久久久| 亚洲成va人在线观看| 亚洲一区免费在线观看| 亚洲乱码中文字幕综合| 综合久久久久久| 亚洲日本va午夜在线电影| 中文字幕亚洲电影| 中文字幕在线不卡| 136国产福利精品导航| 椎名由奈av一区二区三区| 中文字幕永久在线不卡| 亚洲色图色小说| 亚洲精品高清在线观看| 亚洲综合999| 日韩电影在线免费观看| 免费美女久久99| 久久精品av麻豆的观看方式| 蜜臀久久久久久久| 国产精品一区二区你懂的| 国产在线国偷精品产拍免费yy | 国产成人免费在线视频| 国产凹凸在线观看一区二区| 国产 欧美在线| 一本色道久久综合亚洲91| 日本韩国精品一区二区在线观看| 色狠狠av一区二区三区| 欧美视频在线一区| 日韩视频一区在线观看| 久久影院视频免费| 成人欧美一区二区三区在线播放| 亚洲人成影院在线观看| 日韩专区中文字幕一区二区| 麻豆精品一区二区av白丝在线| 国产麻豆精品视频| 99国产精品一区| 欧美日韩大陆在线| 欧美精品一区二区三区久久久| 久久久国产一区二区三区四区小说| 亚洲国产精品成人综合| 亚洲一区二区三区视频在线| 奇米综合一区二区三区精品视频| 国产九色sp调教91| 色999日韩国产欧美一区二区| 69堂亚洲精品首页| 久久久久久久综合| 亚洲综合色成人| 国产在线精品一区二区| 色综合激情久久| 日韩限制级电影在线观看| 国产日韩欧美一区二区三区乱码| 亚洲欧美韩国综合色| 美女国产一区二区三区| 91丨porny丨最新| 日韩视频一区二区| 一区二区三区小说| 国模一区二区三区白浆| 一本一本大道香蕉久在线精品| 日韩精品一区二区三区在线播放| 国产精品福利av| 蜜臀国产一区二区三区在线播放| 成人精品亚洲人成在线| 日韩欧美色电影| 亚洲精品国产一区二区三区四区在线 | 日韩免费看的电影| 一区二区三区四区av| 国产麻豆视频一区| 日韩一区二区视频| 亚洲一本大道在线| 国产成人精品一区二| 欧美一级在线视频| 亚洲一区二区三区四区在线观看| 国产成人午夜片在线观看高清观看| 欧美片在线播放| 亚洲在线中文字幕| 99精品国产一区二区三区不卡| 日韩美一区二区三区| 亚洲综合免费观看高清完整版| 成人国产精品视频| 2023国产精品视频| 三级欧美在线一区| 欧美在线观看视频在线| 国产精品久久久久三级| 国产精品一二三在| 欧美刺激午夜性久久久久久久 | 美女高潮久久久| 欧美高清精品3d| 一区二区三区 在线观看视频 | 欧美一级精品在线| 亚洲自拍与偷拍| 91丨九色丨尤物| 亚洲欧洲日韩女同| 成人毛片视频在线观看| 久久伊人蜜桃av一区二区| 免费的成人av| 日韩一级大片在线| 美女在线视频一区| 欧美成人一区二区三区在线观看 | 欧美精品一区二区久久久| 日韩国产精品久久久| 欧美美女黄视频| 亚洲成av人综合在线观看| 欧美日韩午夜影院| 天天综合天天综合色| 91精品综合久久久久久| 美国一区二区三区在线播放| 日韩三级在线观看| 国产乱妇无码大片在线观看| 精品88久久久久88久久久| 激情深爱一区二区| 国产日韩欧美麻豆| 成人av电影免费观看| 亚洲欧洲综合另类| 欧美日韩一级二级| 麻豆精品久久久| 26uuu国产在线精品一区二区| 国内精品伊人久久久久av一坑| 国产欧美一区二区精品性| www.av亚洲| 亚洲第一成年网| 精品国产免费视频| 99久久国产免费看| 亚洲午夜电影在线观看| 日韩一区二区电影在线| 国产一区二区成人久久免费影院 | 一区二区三区国产豹纹内裤在线 | 欧美成人欧美edvon| 国产成人免费网站| 亚洲欧美一区二区三区久本道91| 欧美最新大片在线看| 日本视频一区二区三区| 国产三级精品视频| 91高清在线观看| 青青草原综合久久大伊人精品 | 91麻豆视频网站| 日本视频一区二区|