From: Tomas Hruby Date: Sat, 10 Apr 2010 15:19:25 +0000 (+0000) Subject: A simpler test whether to use kernel's default scheduling X-Git-Tag: v3.1.7~160 X-Git-Url: http://zhaoyanbai.com/repos/Bv9ARM.ch01.html?a=commitdiff_plain;h=9fdb773cdbdc08b6a53a3feef803f8ef9cf036d5;p=minix.git A simpler test whether to use kernel's default scheduling - this is a small addition to the userspace scheduling. proc_kernel_scheduler() tests whether to use the default scheduling policy in kernel. It is true if the process' scheduler is NULL _or_ self. Currently none of the tests was complete. --- diff --git a/kernel/proc.c b/kernel/proc.c index 7c828d46c..0053e2774 100644 --- a/kernel/proc.c +++ b/kernel/proc.c @@ -129,7 +129,7 @@ not_runnable_pick_new: * If this process is scheduled by the kernel, we renew it's quantum * and remove it's RTS_NO_QUANTUM flag. */ - if (proc_no_quantum(proc_ptr) && (proc_ptr->p_scheduler == NULL)) { + if (proc_no_quantum(proc_ptr) && proc_kernel_scheduler(proc_ptr)) { /* give new quantum */ proc_ptr->p_ticks_left = proc_ptr->p_quantum_size; RTS_UNSET(proc_ptr, RTS_NO_QUANTUM); @@ -1355,14 +1355,14 @@ PRIVATE void notify_scheduler(struct proc *p) * quantum. This is done by sending a message to the scheduler * on the process's behalf */ - if (p->p_scheduler == p) { + if (proc_kernel_scheduler(p)) { /* - * If a scheduler is scheduling itself, and runs out of - * quantum, we don't send a message. The RTS_NO_QUANTUM - * flag will be removed by schedcheck in proc.c. + * If a scheduler is scheduling itself or has no scheduler, and + * runs out of quantum, we don't send a message. The + * RTS_NO_QUANTUM flag will be removed by schedcheck in proc.c. */ } - else if (p->p_scheduler != NULL) { + else { message m_no_quantum; int err; diff --git a/kernel/proc.h b/kernel/proc.h index a059ecf70..99e3ec3b7 100644 --- a/kernel/proc.h +++ b/kernel/proc.h @@ -148,6 +148,10 @@ struct proc { #define proc_no_quantum(p) ((p)->p_rts_flags & RTS_NO_QUANTUM) #define proc_ptr_ok(p) ((p)->p_magic == PMAGIC) +/* test whether the process is scheduled by the kernel's default policy */ +#define proc_kernel_scheduler(p) ((p)->p_scheduler == NULL || \ + (p)->p_scheduler == (p)) + /* Macro to return: on which process is a certain process blocked? * return endpoint number (can be ANY) or NONE. It's important to * check RTS_SENDING first, and then RTS_RECEIVING, as they could