diff options
| author | Roland McGrath <roland@redhat.com> | 2005-03-07 18:17:29 -0800 | 
|---|---|---|
| committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-03-07 18:17:29 -0800 | 
| commit | d80d30ff8b9122aa51135e942e35566904f32ee5 (patch) | |
| tree | 3c285ba3ebe248e77f76321bcc82ac21d589b59f /kernel/sched.c | |
| parent | c1dcd6c2d9b7478baf876725bd356f1b19eeaa65 (diff) | |
[PATCH] make ITIMER_PROF, ITIMER_VIRTUAL per-process
POSIX requires that setitimer, getitimer, and alarm work on a per-process
basis.  Currently, Linux implements these for individual threads.  This patch
fixes these semantics for the ITIMER_PROF timer (which generates SIGPROF) and
the ITIMER_VIRTUAL timer (which generates SIGVTALRM), making them shared by
all threads in a process (thread group).  This patch should be applied after
the one that fixes ITIMER_REAL.
The essential machinery for these timers is tied into the new posix-timers
code for process CPU clocks and timers.  This patch requires the cputimers
patch and its dependencies.
Signed-off-by: Roland McGrath <roland@redhat.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel/sched.c')
| -rw-r--r-- | kernel/sched.c | 47 | 
1 files changed, 2 insertions, 45 deletions
diff --git a/kernel/sched.c b/kernel/sched.c index 8176366cfd8f..a0fd3d36923c 100644 --- a/kernel/sched.c +++ b/kernel/sched.c @@ -2284,46 +2284,6 @@ unsigned long long current_sched_time(const task_t *tsk)  			((rq)->curr->static_prio > (rq)->best_expired_prio))  /* - * Do the virtual cpu time signal calculations. - * @p: the process that the cpu time gets accounted to - * @cputime: the cpu time spent in user space since the last update - */ -static inline void account_it_virt(struct task_struct * p, cputime_t cputime) -{ -	cputime_t it_virt = p->it_virt_value; - -	if (cputime_gt(it_virt, cputime_zero) && -	    cputime_gt(cputime, cputime_zero)) { -		if (cputime_ge(cputime, it_virt)) { -			it_virt = cputime_add(it_virt, p->it_virt_incr); -			send_sig(SIGVTALRM, p, 1); -		} -		it_virt = cputime_sub(it_virt, cputime); -		p->it_virt_value = it_virt; -	} -} - -/* - * Do the virtual profiling signal calculations. - * @p: the process that the cpu time gets accounted to - * @cputime: the cpu time spent in user and kernel space since the last update - */ -static void account_it_prof(struct task_struct *p, cputime_t cputime) -{ -	cputime_t it_prof = p->it_prof_value; - -	if (cputime_gt(it_prof, cputime_zero) && -	    cputime_gt(cputime, cputime_zero)) { -		if (cputime_ge(cputime, it_prof)) { -			it_prof = cputime_add(it_prof, p->it_prof_incr); -			send_sig(SIGPROF, p, 1); -		} -		it_prof = cputime_sub(it_prof, cputime); -		p->it_prof_value = it_prof; -	} -} - -/*   * Check if the process went over its cputime resource limit after   * some cpu time got added to utime/stime.   * @p: the process that the cpu time gets accounted to @@ -2360,10 +2320,8 @@ void account_user_time(struct task_struct *p, cputime_t cputime)  	p->utime = cputime_add(p->utime, cputime); -	/* Check for signals (SIGVTALRM, SIGPROF, SIGXCPU & SIGKILL). */ +	/* Check for signals (SIGXCPU & SIGKILL). */  	check_rlimit(p, cputime); -	account_it_virt(p, cputime); -	account_it_prof(p, cputime);  	/* Add user time to cpustat. */  	tmp = cputime_to_cputime64(cputime); @@ -2388,10 +2346,9 @@ void account_system_time(struct task_struct *p, int hardirq_offset,  	p->stime = cputime_add(p->stime, cputime); -	/* Check for signals (SIGPROF, SIGXCPU & SIGKILL). */ +	/* Check for signals (SIGXCPU & SIGKILL). */  	if (likely(p->signal && p->exit_state < EXIT_ZOMBIE)) {  		check_rlimit(p, cputime); -		account_it_prof(p, cputime);  	}  	/* Add system time to cpustat. */  | 
