diff options
author | attilio <attilio@FreeBSD.org> | 2007-06-09 18:56:11 +0000 |
---|---|---|
committer | attilio <attilio@FreeBSD.org> | 2007-06-09 18:56:11 +0000 |
commit | c105658c88a2c2055d81325040ae51c145564d21 (patch) | |
tree | 5f11084a1ca726fd09afccfce5eb4c0055b06e97 /sys/kern/kern_thread.c | |
parent | 35719cd36d18abec5f4a2477062825a4a0fe6ead (diff) | |
download | FreeBSD-src-c105658c88a2c2055d81325040ae51c145564d21.zip FreeBSD-src-c105658c88a2c2055d81325040ae51c145564d21.tar.gz |
The current rusage code show peculiar problems:
- Unsafeness on ruadd() in thread_exit()
- Unatomicity of thread_exiit() in the exit1() operations
This patch addresses these problems allocating p_fd as part of the
process and modifying the way it is accessed.
A small chunk of this patch, resolves a race about p_state in kern_wait(),
since we have to be sure about the zombif-ing process.
Submitted by: jeff
Approved by: jeff (mentor)
Diffstat (limited to 'sys/kern/kern_thread.c')
-rw-r--r-- | sys/kern/kern_thread.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c index 56de5c2..9c1c02d 100644 --- a/sys/kern/kern_thread.c +++ b/sys/kern/kern_thread.c @@ -391,9 +391,9 @@ thread_exit(void) PCPU_SET(switchtime, new_switchtime); PCPU_SET(switchticks, ticks); PCPU_INC(cnt.v_swtch); - /* Add the child usage to our own when the final thread exits. */ - if (p->p_numthreads == 1) - ruadd(p->p_ru, &p->p_rux, &p->p_stats->p_cru, &p->p_crux); + /* Save our resource usage in our process. */ + td->td_ru.ru_nvcsw++; + rucollect(&p->p_ru, &td->td_ru); /* * The last thread is left attached to the process * So that the whole bundle gets recycled. Skip @@ -411,9 +411,7 @@ thread_exit(void) thread_unlink(td); #endif thread_unlock(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); /* @@ -462,7 +460,7 @@ thread_exit(void) } PROC_UNLOCK(p); thread_lock(td); - /* Aggregate our tick statistics into our parents rux. */ + /* Save our tick information with both the thread and proc locked */ ruxagg(&p->p_rux, td); PROC_SUNLOCK(p); td->td_state = TDS_INACTIVE; |