summaryrefslogtreecommitdiff
path: root/sys/kern/kern_thread.c
diff options
context:
space:
mode:
authorJeff Roberson <jeff@FreeBSD.org>2007-06-01 01:12:45 +0000
committerJeff Roberson <jeff@FreeBSD.org>2007-06-01 01:12:45 +0000
commit1c4bcd050a4f7163d68f608db860aef5fad81d6c (patch)
tree9c09dcc76185c3dc30b048a5f2eb972f3bb8a849 /sys/kern/kern_thread.c
parent9163fee71f130ea1488b39a785bf5d08075936f5 (diff)
Notes
Diffstat (limited to 'sys/kern/kern_thread.c')
-rw-r--r--sys/kern/kern_thread.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c
index e83bf7e8c363..dcb00b770954 100644
--- a/sys/kern/kern_thread.c
+++ b/sys/kern/kern_thread.c
@@ -352,6 +352,7 @@ thread_exit(void)
{
uint64_t new_switchtime;
struct thread *td;
+ struct thread *td2;
struct proc *p;
td = curthread;
@@ -402,17 +403,17 @@ thread_exit(void)
/* Do the same timestamp bookkeeping that mi_switch() would do. */
new_switchtime = cpu_ticks();
p->p_rux.rux_runtime += (new_switchtime - PCPU_GET(switchtime));
- p->p_rux.rux_uticks += td->td_uticks;
- p->p_rux.rux_sticks += td->td_sticks;
- p->p_rux.rux_iticks += td->td_iticks;
PCPU_SET(switchtime, new_switchtime);
PCPU_SET(switchticks, ticks);
cnt.v_swtch++;
-
- /* Add our usage into the usage of all our children. */
+ /*
+ * Aggregate this thread's tick stats in the parent so they are not
+ * lost. Also add the child usage to our own when the final thread
+ * exits.
+ */
+ ruxagg(&p->p_rux, td);
if (p->p_numthreads == 1)
ruadd(p->p_ru, &p->p_rux, &p->p_stats->p_cru, &p->p_crux);
-
/*
* The last thread is left attached to the process
* So that the whole bundle gets recycled. Skip
@@ -424,8 +425,10 @@ thread_exit(void)
if (p->p_flag & P_HADTHREADS) {
if (p->p_numthreads > 1) {
thread_unlink(td);
-
- sched_exit_thread(FIRST_THREAD_IN_PROC(p), td);
+ /* Impart our resource usage on another thread */
+ td2 = FIRST_THREAD_IN_PROC(p);
+ rucollect(&td2->td_ru, &td->td_ru);
+ sched_exit_thread(td2, td);
/*
* The test below is NOT true if we are the