X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fkern%2Fproc.h;h=d4284ffd7210cb5af71451c61e3b2be6a872c228;hb=e5cf108988c4259d52872a9cc17728a97fdb1201;hp=e1181747326224a6d4439cbf7298d5a4656a3601;hpb=267d9764c1305cf310b41d9429015c664eba3cd7;p=bertos.git diff --git a/bertos/kern/proc.h b/bertos/kern/proc.h index e1181747..d4284ffd 100644 --- a/bertos/kern/proc.h +++ b/bertos/kern/proc.h @@ -30,8 +30,59 @@ * Copyright 1999, 2000, 2001, 2008 Bernie Innocenti * --> * + * \defgroup kern Kernel facilities + * \{ + * + * \defgroup kern_proc Process (Threads) management + * \{ + * * \brief BeRTOS Kernel core (Process scheduler). * + * This is the core kernel module. It allows you to create new processes + * (which are called \b threads in other systems) and set the priority of + * each process. + * + * A process needs a work area (called \b stack) to run. To create a process, + * you need to declare a stack area, then create the process. + * You may also pass NULL for the stack area, if you have enabled kernel heap: + * in this case the stack will be automatically allocated. + * + * Example: + * \code + * PROC_DEFINE_STACK(stack1, 200); + * + * void NORETURN proc1_run(void) + * { + * while (1) + * { + * LOG_INFO("I'm alive!\n"); + * timer_delay(1000); + * } + * } + * + * + * int main() + * { + * Process *p1 = proc_new(proc1_run, NULL, stack1, sizeof(stack1)); + * // here the process is already running + * proc_setPri(p1, 2); + * // ... + * } + * \endcode + * + * The Process struct must be regarded as an opaque data type, do not access + * any of its members directly. + * + * The entry point function should be declared as NORETURN, because it will + * remove a warning and enable compiler optimizations. + * + * You can temporarily disable preemption calling proc_forbid(); remember + * to enable it again calling proc_permit(). + * + * \note You should hardly need to manually release the CPU; however you + * can do it using the cpu_relax() function. It is illegal to release + * the CPU with preemption disabled. + * * \author Bernie Innocenti * * $WIZ$ module_name = "kernel" @@ -137,7 +188,7 @@ struct Process *proc_new_with_name(const char *name, void (*entry)(void), iptr_t */ void proc_exit(void); -/** +/* * Public scheduling class methods. */ void proc_yield(void); @@ -396,5 +447,7 @@ INLINE struct Process *proc_current(void) #error No cpu_stack_t size supported! #endif #endif +/** \} */ //defgroup kern_proc +/** \} */ //defgroup kern #endif /* KERN_PROC_H */