From 485a037563527117840f92ecf3215c1663814398 Mon Sep 17 00:00:00 2001 From: Tomas Hruby Date: Sat, 10 Apr 2010 15:17:09 +0000 Subject: [PATCH] do_schedule() cleanup - it is not neccessary to test whether the scheduler is a system process as the process already head permissions to make this call. - it is better to test whether the scheduler has permission to make changes to this process before testing whether the values are valid. --- kernel/system/do_schedule.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/kernel/system/do_schedule.c b/kernel/system/do_schedule.c index f9c37e4db..7e75bf8da 100644 --- a/kernel/system/do_schedule.c +++ b/kernel/system/do_schedule.c @@ -12,19 +12,15 @@ PUBLIC int do_schedule(struct proc * caller, message * m_ptr) p = proc_addr(_ENDPOINT_P(m_ptr->SCHEDULING_ENDPOINT)); + /* Only this process' scheduler can schedule it */ + if (caller != p->p_scheduler) + return(EPERM); + /* Make sure the priority number given is within the allowed range.*/ if (m_ptr->SCHEDULING_PRIORITY < TASK_Q || m_ptr->SCHEDULING_PRIORITY > NR_SCHED_QUEUES) return(EINVAL); - /* Only system processes can schedule processes */ - if (! (priv(caller)->s_flags & SYS_PROC)) - return(EPERM); - - /* Only this process' scheduler can schedule it */ - if (caller != p->p_scheduler) - return(EPERM); - /* In some cases, we might be rescheduling a runnable process. In such * a case (i.e. if we are updating the priority) we set the NO_QUANTUM * flag before the generic unset to dequeue/enqueue the process -- 2.44.0