diff options
author | jhb <jhb@FreeBSD.org> | 2002-09-30 21:13:54 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2002-09-30 21:13:54 +0000 |
commit | f350519764aa2a5ac7d6daaee05afd36a81279c5 (patch) | |
tree | 7decfe1c15133add5e1c3fa81470e85d400fc06a /sys/kern/subr_trap.c | |
parent | f72526c16f332fb7d82318bc526cdafaa25f5b62 (diff) | |
download | FreeBSD-src-f350519764aa2a5ac7d6daaee05afd36a81279c5.zip FreeBSD-src-f350519764aa2a5ac7d6daaee05afd36a81279c5.tar.gz |
- Add a new per-process flag PS_XCPU to indicate that at least one thread
has exceeded its CPU time limit.
- In mi_switch(), set PS_XCPU when the CPU time limit is exceeded.
- Perform actual CPU time limit exceeded work in ast() when PS_XCPU is set.
Requested by: many
Diffstat (limited to 'sys/kern/subr_trap.c')
-rw-r--r-- | sys/kern/subr_trap.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/sys/kern/subr_trap.c b/sys/kern/subr_trap.c index 0a165e9..3220732 100644 --- a/sys/kern/subr_trap.c +++ b/sys/kern/subr_trap.c @@ -153,6 +153,7 @@ ast(struct trapframe *framep) struct proc *p = td->td_proc; struct kse *ke; struct ksegrp *kg = td->td_ksegrp; + struct rlimit *rlim; u_int prticks, sticks; int sflag; int flags; @@ -224,6 +225,19 @@ ast(struct trapframe *framep) psignal(p, SIGPROF); PROC_UNLOCK(p); } + if (sflag & PS_XCPU) { + PROC_LOCK(p); + rlim = &p->p_rlimit[RLIMIT_CPU]; + if (p->p_runtime.sec >= rlim->rlim_max) + killproc(p, "exceeded maximum CPU limit"); + else { + psignal(p, SIGXCPU); + if (rlim->rlim_cur < rlim->rlim_max) + /* XXX: we should make a private copy */ + rlim->rlim_cur += 5; + } + PROC_UNLOCK(p); + } if (flags & KEF_NEEDRESCHED) { mtx_lock_spin(&sched_lock); td->td_priority = kg->kg_user_pri; |