kernel: preemptive and cooperative scheduler refactoring.
[bertos.git] / bertos / kern / coop.c
index c5cab0ed2e4475ab1d192f897921edd139d4e1b0..078724b42a8e38095fb93e3c6e226d2e2b5e2d70 100644 (file)
  * invalidate any other reasons why the executable file might be covered by
  * the GNU General Public License.
  *
- * Copyright 2001, 2004, 2008 Develer S.r.l. (http://www.develer.com/)
- * Copyright 1999, 2000, 2001, 2008 Bernie Innocenti <bernie@codewiz.org>
- * -->
- *
- * \brief Simple cooperative multitasking scheduler.
- *
- * \version $Id$
- * \author Bernie Innocenti <bernie@codewiz.org>
- * \author Stefano Fedrigo <aleph@develer.com>
- */
-
-#include "proc_p.h"
-#include "proc.h"
-
-// Log settings for cfg/log.h.
-#define LOG_LEVEL   KERN_LOG_LEVEL
-#define LOG_FORMAT  KERN_LOG_FORMAT
-#include <cfg/log.h>
-
-#include <cpu/irq.h>
-#include <cpu/types.h>
-#include <cpu/attr.h>
-#include <cpu/frame.h>
-
-/**
- * Define function prototypes exported outside.
- *
- * Required to silent gcc "no previous prototype" warnings.
- */
-void coop_yield(void);
-void coop_switch(void);
-void coop_wakeup(Process *proc);
-
-static void coop_switchTo(Process *proc)
-{
-       Process *old_process = current_process;
-
-       SCHED_ENQUEUE(current_process);
-       current_process = proc;
-       proc_switchTo(current_process, old_process);
-}
-
-/**
- * Give the control of the CPU to another process.
- *
- * \note Assume the current process has been already added to a wait queue.
+ * \note This file is deprecated and kept only for backward compatibility.
  *
- * \warning This should be considered an internal kernel function, even if it
- * is allowed, usage from application code is strongly discouraged.
- */
-void coop_switch(void)
-{
-       ATOMIC(proc_schedule());
-}
-
-/**
- * Immediately wakeup a process, dispatching it to the CPU.
- */
-void coop_wakeup(Process *proc)
-{
-       ASSERT(proc_preemptAllowed());
-       ASSERT(current_process);
-       IRQ_ASSERT_DISABLED();
-
-       if (prio_proc(proc) >= prio_curr())
-               coop_switchTo(proc);
-       else
-               SCHED_ENQUEUE_HEAD(proc);
-}
-
-/**
- * Co-operative context switch
+ * -->
  */
-void coop_yield(void)
-{
-       Process *proc;
-
-       IRQ_DISABLE;
-       proc = (struct Process *)list_remHead(&proc_ready_list);
-       if (proc)
-               coop_switchTo(proc);
-       IRQ_ENABLE;
-}