X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fkern%2Fproc.h;h=482fb7a39708f3a1193f1e0b2689322dded7bbbe;hb=780f975602d282f0d2599e6601d7fee29d493762;hp=d6109e35da4211e20c1387ff9ef04bb986518504;hpb=d62963b4a64efe8d2917f489fefaf586a9a99126;p=bertos.git diff --git a/bertos/kern/proc.h b/bertos/kern/proc.h index d6109e35..482fb7a3 100644 --- a/bertos/kern/proc.h +++ b/bertos/kern/proc.h @@ -26,21 +26,19 @@ * invalidate any other reasons why the executable file might be covered by * the GNU General Public License. * - * Copyright 2001,2004 Develer S.r.l. (http://www.develer.com/) - * Copyright 1999,2000,2001 Bernardo Innocenti - * + * Copyright 2001, 2004 Develer S.r.l. (http://www.develer.com/) + * Copyright 1999, 2000, 2001, 2008 Bernie Innocenti * --> * * \brief Process scheduler (public interface). * * \version $Id$ - * - * \author Bernardo Innocenti + * \author Bernie Innocenti */ #ifndef KERN_PROC_H #define KERN_PROC_H -#include +#include "cfg/cfg_kern.h" #include #include @@ -59,13 +57,18 @@ struct Process *proc_new_with_name(const char* name, void (*entry)(void), iptr_t #endif void proc_exit(void); -void proc_switch(void); -void proc_test(void); +void proc_yield(void); +#define proc_switch proc_yield /* OBSOLETE */ + +int proc_testSetup(void); +int proc_testRun(void); +int proc_testTearDown(void); + struct Process *proc_current(void); iptr_t proc_current_user_data(void); void proc_rename(struct Process *proc, const char* name); -#if CONFIG_KERN_PREEMPTIVE +#if CONFIG_KERN_PREEMPT void proc_forbid(void); void proc_permit(void); #else @@ -83,4 +86,59 @@ void proc_rename(struct Process *proc, const char* name); proc_permit(); \ } while(0) +#ifndef CONFIG_PROC_DEFSTACKSIZE + + #if (ARCH & ARCH_EMUL) + /* We need a large stack because system libraries are bloated */ + #define CONFIG_PROC_DEFSTACKSIZE 65536 + #else + /** + * Default stack size for each thread, in bytes. + * + * The goal here is to allow a minimal task to save all of its + * registers twice, plus push a maximum of 32 variables on the + * stack. + * + * The actual size computed by the default formula is: + * AVR: 102 + * i386: 156 + * ARM: 164 + * x86_64: 184 + * + * Note that on most 16bit architectures, interrupts will also + * run on the stack of the currently running process. Nested + * interrupts will greatly increases the amount of stack space + * required per process. Use irqmanager to minimize stack + * usage. + */ + #define CONFIG_PROC_DEFSTACKSIZE \ + (CPU_SAVED_REGS_CNT * 2 * sizeof(cpustack_t) \ + + 32 * sizeof(int)) + #endif +#endif + +/* Memory fill codes to help debugging */ +#if CONFIG_KERN_MONITOR + #include + #if (SIZEOF_CPUSTACK_T == 1) + /* 8bit cpustack_t */ + #define CONFIG_KERN_STACKFILLCODE 0xA5 + #define CONFIG_KERN_MEMFILLCODE 0xDB + #elif (SIZEOF_CPUSTACK_T == 2) + /* 16bit cpustack_t */ + #define CONFIG_KERN_STACKFILLCODE 0xA5A5 + #define CONFIG_KERN_MEMFILLCODE 0xDBDB + #elif (SIZEOF_CPUSTACK_T == 4) + /* 32bit cpustack_t */ + #define CONFIG_KERN_STACKFILLCODE 0xA5A5A5A5UL + #define CONFIG_KERN_MEMFILLCODE 0xDBDBDBDBUL + #elif (SIZEOF_CPUSTACK_T == 8) + /* 64bit cpustack_t */ + #define CONFIG_KERN_STACKFILLCODE 0xA5A5A5A5A5A5A5A5ULL + #define CONFIG_KERN_MEMFILLCODE 0xDBDBDBDBDBDBDBDBULL + #else + #error No cpustack_t size supported! + #endif +#endif + #endif /* KERN_PROC_H */