X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fkern%2Fproc.h;h=e1181747326224a6d4439cbf7298d5a4656a3601;hb=29730413e44784b377b92bd0f3a3ae0ca60f0e70;hp=c78735e89d2e54aa0c8e5c47fe4bfb33de28240d;hpb=2941141c8a74bbb22a87743ba9b56c5d2dfb17d8;p=bertos.git diff --git a/bertos/kern/proc.h b/bertos/kern/proc.h index c78735e8..e1181747 100644 --- a/bertos/kern/proc.h +++ b/bertos/kern/proc.h @@ -32,12 +32,11 @@ * * \brief BeRTOS Kernel core (Process scheduler). * - * \version $Id$ * \author Bernie Innocenti * * $WIZ$ module_name = "kernel" * $WIZ$ module_configuration = "bertos/cfg/cfg_proc.h" - * $WIZ$ module_depends = "switch_ctx", "mtask" + * $WIZ$ module_depends = "switch_ctx" * $WIZ$ module_supports = "not atmega103" */ @@ -51,10 +50,7 @@ #include // Node, PriNode #include - -#if CONFIG_KERN_PREEMPT - #include // ASSERT() -#endif +#include // ASSERT() #include // cpu_stack_t #include // CPU_SAVED_REGS_CNT @@ -142,16 +138,24 @@ struct Process *proc_new_with_name(const char *name, void (*entry)(void), iptr_t void proc_exit(void); /** - * Co-operative context switch. - * - * The process that calls this function will release the CPU before its cpu quantum - * expires, the scheduler will run to select the next process that will take control - * of the processor. - * \note This function is available only if CONFIG_KERN is enabled - * \sa cpu_relax(), which is the recommended method to release the cpu. + * Public scheduling class methods. */ void proc_yield(void); +#if CONFIG_KERN_PREEMPT +bool proc_needPreempt(void); +void proc_preempt(void); +#else +INLINE bool proc_needPreempt(void) +{ + return false; +} + +INLINE void proc_preempt(void) +{ +} +#endif + void proc_rename(struct Process *proc, const char *name); const char *proc_name(struct Process *proc); const char *proc_currentName(void); @@ -163,7 +167,11 @@ const char *proc_currentName(void); * the returned pointer to the correct type. * \return Pointer to the user data of the current process. */ -iptr_t proc_currentUserData(void); +INLINE iptr_t proc_currentUserData(void) +{ + extern struct Process *current_process; + return current_process->user_data; +} int proc_testSetup(void); int proc_testRun(void);