From 76cb101294622496d32b4a3b91c71aa3fb9e5e01 Mon Sep 17 00:00:00 2001 From: jhb Date: Thu, 31 Mar 2005 22:54:48 +0000 Subject: Actually commit the code for kern_sched_get_rr_interval(). --- sys/posix4/p1003_1b.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) (limited to 'sys/posix4') diff --git a/sys/posix4/p1003_1b.c b/sys/posix4/p1003_1b.c index 35d1bca..7f366f1 100644 --- a/sys/posix4/p1003_1b.c +++ b/sys/posix4/p1003_1b.c @@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -305,35 +306,41 @@ int sched_get_priority_min(struct thread *td, int sched_rr_get_interval(struct thread *td, struct sched_rr_get_interval_args *uap) { + struct timespec timespec; + int error; + + error = kern_sched_rr_get_interval(td, uap->pid, ×pec); + if (error == 0) + error = copyout(×pec, uap->interval, sizeof(timespec)); + return (error); +} + +int kern_sched_rr_get_interval(struct thread *td, pid_t pid, + struct timespec *ts) +{ int e; struct thread *targettd; - struct timespec timespec; struct proc *targetp; mtx_lock(&Giant); - if (uap->pid == 0) { + if (pid == 0) { targettd = td; targetp = td->td_proc; PROC_LOCK(targetp); } else { - targetp = pfind(uap->pid); + targetp = pfind(pid); if (targetp == NULL) { - e = ESRCH; - goto done2; + mtx_unlock(&Giant); + return (ESRCH); } targettd = FIRST_THREAD_IN_PROC(targetp); /* XXXKSE */ } e = p_cansee(td, targetp); - PROC_UNLOCK(targetp); - if (e == 0) { + if (e == 0) e = ksched_rr_get_interval(&td->td_retval[0], ksched, targettd, - ×pec); - if (e == 0) - e = copyout(×pec, uap->interval, - sizeof(timespec)); - } -done2: + ts); + PROC_UNLOCK(targetp); mtx_unlock(&Giant); return (e); } -- cgit v1.1