From 71a6c66a90295a0016eb8dd533100977453b39dc Mon Sep 17 00:00:00 2001 From: Sascha Wildner Date: Sat, 5 Jan 2013 04:32:05 +0100 Subject: [PATCH] kernel/posix scheduling: Style, indentation, etc. --- sys/kern/kern_sched.c | 101 ++++++++++++++++++++---------------------- 1 file changed, 48 insertions(+), 53 deletions(-) diff --git a/sys/kern/kern_sched.c b/sys/kern/kern_sched.c index 98e1786d57..b7989e7e00 100644 --- a/sys/kern/kern_sched.c +++ b/sys/kern/kern_sched.c @@ -30,10 +30,10 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/posix4/ksched.c,v 1.7.2.1 2000/05/16 06:58:13 dillon Exp $ - * $DragonFly: src/sys/kern/kern_sched.c,v 1.10 2008/04/21 15:24:46 dillon Exp $ */ -/* ksched: Soft real time scheduling based on "rtprio". +/* + * ksched: Soft real time scheduling based on "rtprio". */ #include @@ -52,7 +52,8 @@ struct ksched { struct timespec rr_interval; }; -int ksched_attach(struct ksched **p) +int +ksched_attach(struct ksched **p) { struct ksched *ksched= p31b_malloc(sizeof(*ksched)); @@ -63,7 +64,8 @@ int ksched_attach(struct ksched **p) return 0; } -int ksched_detach(struct ksched *p) +int +ksched_detach(struct ksched *p) { p31b_free(p); @@ -77,7 +79,7 @@ int ksched_detach(struct ksched *p) * higher priority. It also permits sched_setparam to be * implementation defined for SCHED_OTHER. I don't like * the notion of inverted priorites for normal processes when - * you can use "setpriority" for that. + * you can use "setpriority" for that. * * I'm rejecting sched_setparam for SCHED_OTHER with EINVAL. */ @@ -89,7 +91,8 @@ int ksched_detach(struct ksched *p) #define p4prio_to_rtpprio(P) (RTP_PRIO_MAX - (P)) #define rtpprio_to_p4prio(P) (RTP_PRIO_MAX - (P)) -/* These improve readability a bit for me: +/* + * These improve readability a bit for me: */ #define P1B_PRIO_MIN rtpprio_to_p4prio(RTP_PRIO_MAX) #define P1B_PRIO_MAX rtpprio_to_p4prio(RTP_PRIO_MIN) @@ -99,17 +102,14 @@ getscheduler(register_t *ret, struct ksched *ksched, struct lwp *lp) { int e = 0; - switch (lp->lwp_rtprio.type) - { - case RTP_PRIO_FIFO: + switch (lp->lwp_rtprio.type) { + case RTP_PRIO_FIFO: *ret = SCHED_FIFO; break; - - case RTP_PRIO_REALTIME: + case RTP_PRIO_REALTIME: *ret = SCHED_RR; break; - - default: + default: *ret = SCHED_OTHER; break; } @@ -117,16 +117,16 @@ getscheduler(register_t *ret, struct ksched *ksched, struct lwp *lp) return e; } -int ksched_setparam(register_t *ret, struct ksched *ksched, - struct lwp *lp, const struct sched_param *param) +int +ksched_setparam(register_t *ret, struct ksched *ksched, + struct lwp *lp, const struct sched_param *param) { register_t policy; int e; e = getscheduler(&policy, ksched, lp); - if (e == 0) - { + if (e == 0) { if (policy == SCHED_OTHER) e = EINVAL; else @@ -136,8 +136,9 @@ int ksched_setparam(register_t *ret, struct ksched *ksched, return e; } -int ksched_getparam(register_t *ret, struct ksched *ksched, - struct lwp *lp, struct sched_param *param) +int +ksched_getparam(register_t *ret, struct ksched *ksched, + struct lwp *lp, struct sched_param *param) { if (RTP_PRIO_IS_REALTIME(lp->lwp_rtprio.type)) param->sched_priority = rtpprio_to_p4prio(lp->lwp_rtprio.prio); @@ -152,54 +153,49 @@ int ksched_getparam(register_t *ret, struct ksched *ksched, * The permissions to modify process p were checked in "p31b_proc()". * */ -int ksched_setscheduler(register_t *ret, struct ksched *ksched, - struct lwp *lp, int policy, const struct sched_param *param) +int +ksched_setscheduler(register_t *ret, struct ksched *ksched, + struct lwp *lp, int policy, const struct sched_param *param) { int e = 0; struct rtprio rtp; - switch(policy) - { - case SCHED_RR: - case SCHED_FIFO: - + switch(policy) { + case SCHED_RR: + case SCHED_FIFO: if (param->sched_priority >= P1B_PRIO_MIN && - param->sched_priority <= P1B_PRIO_MAX) - { + param->sched_priority <= P1B_PRIO_MAX) { rtp.prio = p4prio_to_rtpprio(param->sched_priority); - rtp.type = (policy == SCHED_FIFO) - ? RTP_PRIO_FIFO : RTP_PRIO_REALTIME; + rtp.type = (policy == SCHED_FIFO) ? + RTP_PRIO_FIFO : RTP_PRIO_REALTIME; lp->lwp_rtprio = rtp; need_user_resched(); - } - else + } else { e = EPERM; - - - break; - - case SCHED_OTHER: - { - rtp.type = RTP_PRIO_NORMAL; - rtp.prio = p4prio_to_rtpprio(param->sched_priority); - lp->lwp_rtprio = rtp; - - /* XXX Simply revert to whatever we had for last - * normal scheduler priorities. - * This puts a requirement - * on the scheduling code: You must leave the - * scheduling info alone. - */ - need_user_resched(); } break; + case SCHED_OTHER: + rtp.type = RTP_PRIO_NORMAL; + rtp.prio = p4prio_to_rtpprio(param->sched_priority); + lp->lwp_rtprio = rtp; + + /* + * XXX Simply revert to whatever we had for last + * normal scheduler priorities. + * This puts a requirement + * on the scheduling code: You must leave the + * scheduling info alone. + */ + need_user_resched(); + break; } return e; } -int ksched_getscheduler(register_t *ret, struct ksched *ksched, struct lwp *lp) +int +ksched_getscheduler(register_t *ret, struct ksched *ksched, struct lwp *lp) { return getscheduler(ret, ksched, lp); } @@ -214,9 +210,8 @@ ksched_yield(register_t *ret, struct ksched *ksched) { struct lwp *lp; - if ((lp = curthread->td_lwp) != NULL) { + if ((lp = curthread->td_lwp) != NULL) lp->lwp_proc->p_usched->yield(lp); - } return 0; } @@ -272,7 +267,7 @@ ksched_get_priority_min(register_t *ret, struct ksched *ksched, int policy) */ int ksched_rr_get_interval(register_t *ret, struct ksched *ksched, - struct lwp *lp, struct timespec *timespec) + struct lwp *lp, struct timespec *timespec) { *timespec = ksched->rr_interval; -- 2.41.0