X-Git-Url: https://codewiz.org/gitweb?p=bertos.git;a=blobdiff_plain;f=bertos%2Fkern%2Fcoop.c;h=078724b42a8e38095fb93e3c6e226d2e2b5e2d70;hp=c5cab0ed2e4475ab1d192f897921edd139d4e1b0;hb=f35b6066ecdeffcc8998dd566b5246bdcf43c548;hpb=2c8af54b2053cae5a6b5ff073cfd94606b21920a diff --git a/bertos/kern/coop.c b/bertos/kern/coop.c index c5cab0ed..078724b4 100644 --- a/bertos/kern/coop.c +++ b/bertos/kern/coop.c @@ -26,86 +26,7 @@ * 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 - * --> - * - * \brief Simple cooperative multitasking scheduler. - * - * \version $Id$ - * \author Bernie Innocenti - * \author Stefano Fedrigo - */ - -#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 - -#include -#include -#include -#include - -/** - * 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; -}