Linux Headquarters
[ Register ]
[ About us ] [ Home Page ]

Advertisement
[ Kernel ] [ Documentation ] [ Links ] [ Books ]

Advertisement

Kernel v2.4.20 /kernel/sched.c

Filename:/kernel/sched.c
Lines Added:27
Lines Deleted:12
Also changed in: (Previous) 2.4.20-rc4-ac1  2.4.20-rc4  2.4.20-rc3  2.4.20-rc2-ac3  2.4.20-rc2-ac2  2.4.20-rc2-ac1 
(Following) 2.4.20-ac1  2.4.20-ac2  2.4.21-pre3  2.4.21-pre3-ac1  2.4.21-pre3-ac2  2.4.21-pre3-ac3 

Location
[  2.4.20
  [  kernel
     o  sched.c

Patch

diff -urN linux-2.4.19/kernel/sched.c linux-2.4.20/kernel/sched.c
--- linux-2.4.19/kernel/sched.c   Fri Aug  2 17:39:46 2002
+++ linux-2.4.20/kernel/sched.c   Thu Nov 28 15:53:15 2002
@@ -318,13 +318,17 @@
 /*
  * Careful!
  *
- * This has to add the process to the _beginning_ of the
- * run-queue, not the end. See the comment about "This is
- * subtle" in the scheduler proper..
+ * This has to add the process to the _end_ of the 
+ * run-queue, not the beginning. The goodness value will
+ * determine whether this process will run next. This is
+ * important to get SCHED_FIFO and SCHED_RR right, where
+ * a process that is either pre-empted or its time slice
+ * has expired, should be moved to the tail of the run 
+ * queue for its priority - Bhavesh Davda
  */
 static inline void add_to_runqueue(struct task_struct * p)
 {
-   list_add(&p->run_list, &runqueue_head);
+   list_add_tail(&p->run_list, &runqueue_head);
    nr_running++;
 }
 
@@ -334,12 +338,6 @@
    list_add_tail(&p->run_list, &runqueue_head);
 }
 
-static inline void move_first_runqueue(struct task_struct * p)
-{
-   list_del(&p->run_list);
-   list_add(&p->run_list, &runqueue_head);
-}
-
 /*
  * Wake up a process. Put it on the run-queue if it's not
  * already there.  The "current" process is always on the
@@ -955,8 +953,6 @@
    retval = 0;
    p->policy = policy;
    p->rt_priority = lp.sched_priority;
-   if (task_on_runqueue(p))
-      move_first_runqueue(p);
 
    current->need_resched = 1;
 
@@ -1071,6 +1067,25 @@
    return 0;
 }
 
+/**
+ * yield - yield the current processor to other threads.
+ *
+ * this is a shortcut for kernel-space yielding - it marks the
+ * thread runnable and calls sys_sched_yield().
+ */
+void yield(void)
+{
+   set_current_state(TASK_RUNNING);
+   sys_sched_yield();
+   schedule();
+}
+
+void __cond_resched(void)
+{
+   set_current_state(TASK_RUNNING);
+   schedule();
+}
+
 asmlinkage long sys_sched_get_priority_max(int policy)
 {
    int ret = -EINVAL;


Comments: webmaster (at) linuxhq.com.
Advertising: banners (at) linuxhq.com.
Compilation ©1998-2008 Linux Headquarters, Inc.