svn commit: r247181 - in user/dchagin/lemul/sys: kern sys
Dmitry Chagin
dchagin at FreeBSD.org
Sat Feb 23 09:06:53 UTC 2013
Author: dchagin
Date: Sat Feb 23 09:06:52 2013
New Revision: 247181
URL: http://svnweb.freebsd.org/changeset/base/247181
Log:
In preparation for switching linuxulator to the use the native 1:1 threads
split sys_sched_getparam(), sys_sched_setparam(), sys_sched_getscheduler(),
sys_sched_setscheduler() to their kern_* counterparts and add the targettd
parameter to allow specify the target thread directly by callee.
Modified:
user/dchagin/lemul/sys/kern/p1003_1b.c
user/dchagin/lemul/sys/sys/syscallsubr.h
Modified: user/dchagin/lemul/sys/kern/p1003_1b.c
==============================================================================
--- user/dchagin/lemul/sys/kern/p1003_1b.c Sat Feb 23 09:06:36 2013 (r247180)
+++ user/dchagin/lemul/sys/kern/p1003_1b.c Sat Feb 23 09:06:52 2013 (r247181)
@@ -130,13 +130,24 @@ sys_sched_setparam(struct thread *td, st
targettd = FIRST_THREAD_IN_PROC(targetp);
}
- e = p_cansched(td, targetp);
- if (e == 0) {
- e = ksched_setparam(ksched, targettd,
- (const struct sched_param *)&sched_param);
- }
+ return (kern_sched_setparam(td, targettd, &sched_param));
+}
+
+int
+kern_sched_setparam(struct thread *td, struct thread *targettd,
+ struct sched_param *param)
+{
+ struct proc *targetp;
+ int error;
+
+ targetp = targettd->td_proc;
+ PROC_LOCK_ASSERT(targetp, MA_OWNED);
+
+ error = p_cansched(td, targetp);
+ if (error == 0)
+ error = ksched_setparam(ksched, targettd, param);
PROC_UNLOCK(targetp);
- return (e);
+ return (error);
}
int
@@ -159,17 +170,30 @@ sys_sched_getparam(struct thread *td, st
targettd = FIRST_THREAD_IN_PROC(targetp);
}
- e = p_cansee(td, targetp);
- if (e == 0) {
- e = ksched_getparam(ksched, targettd, &sched_param);
- }
- PROC_UNLOCK(targetp);
+ e = ksched_getparam(ksched, targettd, &sched_param);
if (e == 0)
e = copyout(&sched_param, uap->param, sizeof(sched_param));
return (e);
}
int
+kern_sched_getparam(struct thread *td, struct thread *targettd,
+ struct sched_param *param)
+{
+ struct proc *targetp;
+ int error;
+
+ targetp = targettd->td_proc;
+ PROC_LOCK_ASSERT(targetp, MA_OWNED);
+
+ error = p_cansee(td, targetp);
+ if (error == 0)
+ error = ksched_getparam(ksched, targettd, param);
+ PROC_UNLOCK(targetp);
+ return (error);
+}
+
+int
sys_sched_setscheduler(struct thread *td, struct sched_setscheduler_args *uap)
{
int e;
@@ -177,11 +201,6 @@ sys_sched_setscheduler(struct thread *td
struct thread *targettd;
struct proc *targetp;
- /* Don't allow non root user to set a scheduler policy. */
- e = priv_check(td, PRIV_SCHED_SET);
- if (e)
- return (e);
-
e = copyin(uap->param, &sched_param, sizeof(sched_param));
if (e)
return (e);
@@ -197,13 +216,33 @@ sys_sched_setscheduler(struct thread *td
targettd = FIRST_THREAD_IN_PROC(targetp);
}
- e = p_cansched(td, targetp);
- if (e == 0) {
- e = ksched_setscheduler(ksched, targettd,
- uap->policy, (const struct sched_param *)&sched_param);
+ return (kern_sched_setscheduler(td, targettd, uap->policy,
+ &sched_param));
+}
+
+int
+kern_sched_setscheduler(struct thread *td, struct thread *targettd,
+ int policy, struct sched_param *param)
+{
+ struct proc *targetp;
+ int error;
+
+ targetp = targettd->td_proc;
+ PROC_LOCK_ASSERT(targetp, MA_OWNED);
+
+ /* Don't allow non root user to set a scheduler policy. */
+ error = priv_check(td, PRIV_SCHED_SET);
+ if (error) {
+ PROC_UNLOCK(targetp);
+ return (error);
}
+
+ error = p_cansched(td, targetp);
+ if (error == 0)
+ error = ksched_setscheduler(ksched, targettd, policy,
+ param);
PROC_UNLOCK(targetp);
- return (e);
+ return (error);
}
int
@@ -224,17 +263,32 @@ sys_sched_getscheduler(struct thread *td
targettd = FIRST_THREAD_IN_PROC(targetp);
}
- e = p_cansee(td, targetp);
- if (e == 0) {
- e = ksched_getscheduler(ksched, targettd, &policy);
+ e = ksched_getscheduler(ksched, targettd, &policy);
+ if (e == 0)
td->td_retval[0] = policy;
- }
- PROC_UNLOCK(targetp);
return (e);
}
int
+kern_sched_getscheduler(struct thread *td, struct thread *targettd,
+ int *policy)
+{
+ struct proc *targetp;
+ int error;
+
+ targetp = td->td_proc;
+ PROC_LOCK_ASSERT(targetp, MA_OWNED);
+
+ error = p_cansee(td, targetp);
+ if (error == 0)
+ error = ksched_getscheduler(ksched, targettd, policy);
+ PROC_UNLOCK(targetp);
+
+ return (error);
+}
+
+int
sys_sched_yield(struct thread *td, struct sched_yield_args *uap)
{
Modified: user/dchagin/lemul/sys/sys/syscallsubr.h
==============================================================================
--- user/dchagin/lemul/sys/sys/syscallsubr.h Sat Feb 23 09:06:36 2013 (r247180)
+++ user/dchagin/lemul/sys/sys/syscallsubr.h Sat Feb 23 09:06:52 2013 (r247181)
@@ -54,6 +54,7 @@ struct sendfile_args;
struct sockaddr;
struct stat;
struct thr_param;
+struct sched_param;
struct __wrusage;
int kern___getcwd(struct thread *td, u_char *buf, enum uio_seg bufseg,
@@ -180,6 +181,14 @@ int kern_renameat(struct thread *td, int
int kern_rmdir(struct thread *td, char *path, enum uio_seg pathseg);
int kern_rmdirat(struct thread *td, int fd, char *path,
enum uio_seg pathseg);
+int kern_sched_getparam(struct thread *td, struct thread *targettd,
+ struct sched_param *param);
+int kern_sched_getscheduler(struct thread *td, struct thread *targettd,
+ int *policy);
+int kern_sched_setparam(struct thread *td, struct thread *targettd,
+ struct sched_param *param);
+int kern_sched_setscheduler(struct thread *td, struct thread *targettd,
+ int policy, struct sched_param *param);
int kern_sched_rr_get_interval(struct thread *td, struct thread *targettd,
struct timespec *ts);
int kern_semctl(struct thread *td, int semid, int semnum, int cmd,
More information about the svn-src-user
mailing list