svn commit: r278033 - user/dchagin/lemul/sys/kern
Dmitry Chagin
dchagin at FreeBSD.org
Sun Feb 1 19:07:43 UTC 2015
Author: dchagin
Date: Sun Feb 1 19:07:42 2015
New Revision: 278033
URL: https://svnweb.freebsd.org/changeset/base/278033
Log:
Reduce diff with #lemul Phabricator.
Thanks to abi at abinet dot ru.
Modified:
user/dchagin/lemul/sys/kern/p1003_1b.c
Modified: user/dchagin/lemul/sys/kern/p1003_1b.c
==============================================================================
--- user/dchagin/lemul/sys/kern/p1003_1b.c Sun Feb 1 18:21:16 2015 (r278032)
+++ user/dchagin/lemul/sys/kern/p1003_1b.c Sun Feb 1 19:07:42 2015 (r278033)
@@ -130,7 +130,9 @@ sys_sched_setparam(struct thread *td, st
targettd = FIRST_THREAD_IN_PROC(targetp);
}
- return (kern_sched_setparam(td, targettd, &sched_param));
+ e = kern_sched_setparam(td, targettd, &sched_param);
+ PROC_UNLOCK(targetp);
+ return (e);
}
int
@@ -145,8 +147,8 @@ kern_sched_setparam(struct thread *td, s
error = p_cansched(td, targetp);
if (error == 0)
- error = ksched_setparam(ksched, targettd, param);
- PROC_UNLOCK(targetp);
+ error = ksched_setparam(ksched, targettd,
+ (const struct sched_param *)param);
return (error);
}
@@ -170,7 +172,8 @@ sys_sched_getparam(struct thread *td, st
targettd = FIRST_THREAD_IN_PROC(targetp);
}
- e = ksched_getparam(ksched, targettd, &sched_param);
+ e = kern_sched_getparam(td, targettd, &sched_param);
+ PROC_UNLOCK(targetp);
if (e == 0)
e = copyout(&sched_param, uap->param, sizeof(sched_param));
return (e);
@@ -189,7 +192,6 @@ kern_sched_getparam(struct thread *td, s
error = p_cansee(td, targetp);
if (error == 0)
error = ksched_getparam(ksched, targettd, param);
- PROC_UNLOCK(targetp);
return (error);
}
@@ -216,8 +218,10 @@ sys_sched_setscheduler(struct thread *td
targettd = FIRST_THREAD_IN_PROC(targetp);
}
- return (kern_sched_setscheduler(td, targettd, uap->policy,
- &sched_param));
+ e = kern_sched_setscheduler(td, targettd, uap->policy,
+ &sched_param);
+ PROC_UNLOCK(targetp);
+ return (e);
}
int
@@ -232,16 +236,13 @@ kern_sched_setscheduler(struct thread *t
/* Don't allow non root user to set a scheduler policy. */
error = priv_check(td, PRIV_SCHED_SET);
- if (error) {
- PROC_UNLOCK(targetp);
+ if (error)
return (error);
- }
error = p_cansched(td, targetp);
if (error == 0)
error = ksched_setscheduler(ksched, targettd, policy,
- param);
- PROC_UNLOCK(targetp);
+ (const struct sched_param *)param);
return (error);
}
@@ -263,7 +264,8 @@ sys_sched_getscheduler(struct thread *td
targettd = FIRST_THREAD_IN_PROC(targetp);
}
- e = ksched_getscheduler(ksched, targettd, &policy);
+ e = kern_sched_getscheduler(td, targettd, &policy);
+ PROC_UNLOCK(targetp);
if (e == 0)
td->td_retval[0] = policy;
@@ -283,8 +285,6 @@ kern_sched_getscheduler(struct thread *t
error = p_cansee(td, targetp);
if (error == 0)
error = ksched_getscheduler(ksched, targettd, policy);
- PROC_UNLOCK(targetp);
-
return (error);
}
@@ -323,44 +323,53 @@ sys_sched_rr_get_interval(struct thread
struct sched_rr_get_interval_args *uap)
{
struct timespec timespec;
- struct thread *targettd;
- struct proc *p;
int error;
- if (uap->pid == 0) {
+ 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 proc *targetp;
+
+ if (pid == 0) {
targettd = td;
- p = td->td_proc;
- PROC_LOCK(p);
+ targetp = td->td_proc;
+ PROC_LOCK(targetp);
} else {
- p = pfind(uap->pid);
- if (p == NULL)
+ targetp = pfind(pid);
+ if (targetp == NULL)
return (ESRCH);
- targettd = FIRST_THREAD_IN_PROC(p);
+ targettd = FIRST_THREAD_IN_PROC(targetp);
}
- error = kern_sched_rr_get_interval_td(td, targettd, ×pec);
- if (error == 0)
- error = copyout(×pec, uap->interval, sizeof(timespec));
- return (error);
+ e = kern_sched_rr_get_interval_td(td, targettd, ts);
+ PROC_UNLOCK(targetp);
+ return (e);
}
int
kern_sched_rr_get_interval_td(struct thread *td, struct thread *targettd,
struct timespec *ts)
{
- struct proc *targetp;
+ struct proc *p;
int error;
- targetp = targettd->td_proc;
- PROC_LOCK_ASSERT(targetp, MA_OWNED);
+ p = targettd->td_proc;
+ PROC_LOCK_ASSERT(p, MA_OWNED);
- error = p_cansee(td, targetp);
+ error = p_cansee(td, p);
if (error == 0)
error = ksched_rr_get_interval(ksched, targettd, ts);
- PROC_UNLOCK(targetp);
return (error);
}
-
#endif
static void
More information about the svn-src-user
mailing list