1. Count last time slice, this intends to fix

"calcru: runtime went backwards" bug for threaded process.
2. Add comment about possible logical problem with scheduler.

MFC after: 3 days
This commit is contained in:
David Xu 2006-03-14 04:00:21 +00:00
parent bb647cca85
commit e170bfda56
2 changed files with 18 additions and 14 deletions

View File

@ -110,7 +110,6 @@ sys_exit(struct thread *td, struct sys_exit_args *uap)
void
exit1(struct thread *td, int rv)
{
uint64_t new_switchtime;
struct proc *p, *nq, *q;
struct tty *tp;
struct vnode *ttyvp;
@ -557,19 +556,6 @@ retry:
p->p_state = PRS_ZOMBIE;
PROC_UNLOCK(p->p_pptr);
/* 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. */
ruadd(p->p_ru, &p->p_rux, &p->p_stats->p_cru, &p->p_crux);
sched_exit(p->p_pptr, td);
/*

View File

@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$");
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/resourcevar.h>
#include <sys/smp.h>
#include <sys/sysctl.h>
#include <sys/sched.h>
@ -454,6 +455,7 @@ thread_free(struct thread *td)
void
thread_exit(void)
{
uint64_t new_switchtime;
struct thread *td;
struct proc *p;
struct ksegrp *kg;
@ -494,9 +496,25 @@ thread_exit(void)
/*
* The thread is exiting. scheduler can release its stuff
* and collect stats etc.
* XXX this is not very right, since PROC_UNLOCK may still
* need scheduler stuff.
*/
sched_thread_exit(td);
/* 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. */
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