summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authordavidxu <davidxu@FreeBSD.org>2002-11-18 12:28:15 +0000
committerdavidxu <davidxu@FreeBSD.org>2002-11-18 12:28:15 +0000
commit22e8b195a0f0ceddb6258e0732751d3f2808a173 (patch)
tree8e26fc74cbbf9aaad968da78d6c14d5b83213b8e /sys
parent902d691151402f942930750bcc7fdd992840aa3e (diff)
downloadFreeBSD-src-22e8b195a0f0ceddb6258e0732751d3f2808a173.zip
FreeBSD-src-22e8b195a0f0ceddb6258e0732751d3f2808a173.tar.gz
Make sure only update wall clock at upcall time, slightly reformat
code in kse_relase().
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/kern_kse.c26
-rw-r--r--sys/kern/kern_thread.c26
2 files changed, 26 insertions, 26 deletions
diff --git a/sys/kern/kern_kse.c b/sys/kern/kern_kse.c
index 2672c43..6a92914 100644
--- a/sys/kern/kern_kse.c
+++ b/sys/kern/kern_kse.c
@@ -361,10 +361,7 @@ kse_release(struct thread *td, struct kse_release_args *uap)
PROC_LOCK(p);
mtx_lock_spin(&sched_lock);
/* prevent last thread from exiting */
- if (p->p_numthreads > 1) {
- thread_exit();
- /* NOTREACHED */
- } else {
+ if (p->p_numthreads == 1) {
mtx_unlock_spin(&sched_lock);
if (td->td_standin == NULL) {
PROC_UNLOCK(p);
@@ -376,8 +373,9 @@ kse_release(struct thread *td, struct kse_release_args *uap)
mtx_lock_spin(&sched_lock);
td->td_flags |= TDF_UNBOUND;
thread_schedule_upcall(td, td->td_kse);
- thread_exit();
}
+ thread_exit();
+ /* NOTREACHED */
}
return (EINVAL);
}
@@ -915,17 +913,12 @@ thread_update_uticks(void)
struct kse_thr_mailbox *tmbx;
caddr_t addr;
uint uticks, sticks;
- struct timespec ts;
KASSERT(!(td->td_flags & TDF_UNBOUND), ("thread not bound."));
if (ke->ke_mailbox == NULL)
return 0;
- nanotime(&ts);
- if (copyout(&ts, (caddr_t)&ke->ke_mailbox->km_timeofday, sizeof(ts)))
- goto bad;
-
uticks = ke->ke_uuticks;
ke->ke_uuticks = 0;
sticks = ke->ke_usticks;
@@ -1395,6 +1388,7 @@ thread_userret(struct thread *td, struct trapframe *frame)
struct ksegrp *kg;
struct thread *td2;
struct proc *p;
+ struct timespec ts;
error = 0;
@@ -1566,10 +1560,16 @@ thread_userret(struct thread *td, struct trapframe *frame)
offsetof(struct kse_mailbox, km_curthread), 0);
#else /* if user pointer arithmetic is ok in the kernel */
error = suword((caddr_t)&ke->ke_mailbox->km_curthread, 0);
- ke->ke_uuticks = ke->ke_usticks = 0;
#endif
- if (!error)
- return (0);
+ ke->ke_uuticks = ke->ke_usticks = 0;
+ if (!error) {
+ nanotime(&ts);
+ if (copyout(&ts, (caddr_t)&ke->ke_mailbox->km_timeofday,
+ sizeof(ts))) {
+ goto bad;
+ }
+ }
+ return (0);
bad:
/*
diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c
index 2672c43..6a92914 100644
--- a/sys/kern/kern_thread.c
+++ b/sys/kern/kern_thread.c
@@ -361,10 +361,7 @@ kse_release(struct thread *td, struct kse_release_args *uap)
PROC_LOCK(p);
mtx_lock_spin(&sched_lock);
/* prevent last thread from exiting */
- if (p->p_numthreads > 1) {
- thread_exit();
- /* NOTREACHED */
- } else {
+ if (p->p_numthreads == 1) {
mtx_unlock_spin(&sched_lock);
if (td->td_standin == NULL) {
PROC_UNLOCK(p);
@@ -376,8 +373,9 @@ kse_release(struct thread *td, struct kse_release_args *uap)
mtx_lock_spin(&sched_lock);
td->td_flags |= TDF_UNBOUND;
thread_schedule_upcall(td, td->td_kse);
- thread_exit();
}
+ thread_exit();
+ /* NOTREACHED */
}
return (EINVAL);
}
@@ -915,17 +913,12 @@ thread_update_uticks(void)
struct kse_thr_mailbox *tmbx;
caddr_t addr;
uint uticks, sticks;
- struct timespec ts;
KASSERT(!(td->td_flags & TDF_UNBOUND), ("thread not bound."));
if (ke->ke_mailbox == NULL)
return 0;
- nanotime(&ts);
- if (copyout(&ts, (caddr_t)&ke->ke_mailbox->km_timeofday, sizeof(ts)))
- goto bad;
-
uticks = ke->ke_uuticks;
ke->ke_uuticks = 0;
sticks = ke->ke_usticks;
@@ -1395,6 +1388,7 @@ thread_userret(struct thread *td, struct trapframe *frame)
struct ksegrp *kg;
struct thread *td2;
struct proc *p;
+ struct timespec ts;
error = 0;
@@ -1566,10 +1560,16 @@ thread_userret(struct thread *td, struct trapframe *frame)
offsetof(struct kse_mailbox, km_curthread), 0);
#else /* if user pointer arithmetic is ok in the kernel */
error = suword((caddr_t)&ke->ke_mailbox->km_curthread, 0);
- ke->ke_uuticks = ke->ke_usticks = 0;
#endif
- if (!error)
- return (0);
+ ke->ke_uuticks = ke->ke_usticks = 0;
+ if (!error) {
+ nanotime(&ts);
+ if (copyout(&ts, (caddr_t)&ke->ke_mailbox->km_timeofday,
+ sizeof(ts))) {
+ goto bad;
+ }
+ }
+ return (0);
bad:
/*
OpenPOWER on IntegriCloud