X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fkern%2Fproc.h;h=9b4fe140efc8cb9312aec235012545330a1ae156;hb=f35b6066ecdeffcc8998dd566b5246bdcf43c548;hp=8570d801edf39d017ee985ceb2f20187b2a0b6ab;hpb=32d1445272120a254d77ce8d1af1f527da7a2c17;p=bertos.git diff --git a/bertos/kern/proc.h b/bertos/kern/proc.h index 8570d801..9b4fe140 100644 --- a/bertos/kern/proc.h +++ b/bertos/kern/proc.h @@ -37,7 +37,7 @@ * * $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 +51,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 +139,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 +168,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); @@ -363,7 +372,7 @@ INLINE struct Process *proc_current(void) */ #define PROC_DEFINE_STACK(name, size) \ cpu_stack_t name[((size) + sizeof(cpu_stack_t) - 1) / sizeof(cpu_stack_t)]; \ - STATIC_ASSERT((size) >= KERN_MINSTACKSIZE) + STATIC_ASSERT((size) >= KERN_MINSTACKSIZE); /* Memory fill codes to help debugging */ #if CONFIG_KERN_MONITOR