summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_trap.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2002-09-30 21:13:54 +0000
committerjhb <jhb@FreeBSD.org>2002-09-30 21:13:54 +0000
commitf350519764aa2a5ac7d6daaee05afd36a81279c5 (patch)
tree7decfe1c15133add5e1c3fa81470e85d400fc06a /sys/kern/subr_trap.c
parentf72526c16f332fb7d82318bc526cdafaa25f5b62 (diff)
downloadFreeBSD-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.c14
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;
OpenPOWER on IntegriCloud