X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;ds=sidebyside;f=bertos%2Fkern%2Fproc.h;h=db269398ab8462aa54c8ee515ad6e1b22d81ab64;hb=cf5af2b25de263a964bf29a7465cdfe536d32e59;hp=56b5f5aa45cc6544af526dcaee3e272f60b3adc6;hpb=04188ad75e2fb6ec7d681649c1b4a171d7c9f5a3;p=bertos.git diff --git a/bertos/kern/proc.h b/bertos/kern/proc.h index 56b5f5aa..db269398 100644 --- a/bertos/kern/proc.h +++ b/bertos/kern/proc.h @@ -110,33 +110,28 @@ typedef struct Process */ void proc_init(void); -/** - * Create a new named process and schedules it for execution. - * - * When defining the stacksize take into account that you may want at least: - * \li save all the registers for each nested function call; - * \li have memory for the struct Process, which is positioned at the bottom - * of the stack; - * \li have some memory for temporary variables inside called functions. - * - * The value given by CONFIG_KERN_MINSTACKSIZE is rather safe to use in the first place. - * - * \note The function - * \code - * proc_new(entry, data, stacksize, stack) - * \endcode - * is a more convenient way to create a process, as you don't have to specify - * the name. - * - * \param name Name of the process (currently unused). - * \param entry Function that the process will execute. - * \param data Pointer to user data. - * \param stacksize Length of the stack. - * \param stack Pointer to the memory area to be used as a stack. - */ struct Process *proc_new_with_name(const char *name, void (*entry)(void), iptr_t data, size_t stacksize, cpu_stack_t *stack); #if !CONFIG_KERN_MONITOR + /** + * Create a new named process and schedules it for execution. + * + * When defining the stacksize take into account that you may want at least: + * \li save all the registers for each nested function call; + * \li have memory for the struct Process, which is positioned at the bottom + * of the stack; + * \li have some memory for temporary variables inside called functions. + * + * The value given by KERN_MINSTACKSIZE is rather safe to use in the first place. + * + * \param entry Function that the process will execute. + * \param data Pointer to user data. + * \param size Length of the stack. + * \param stack Pointer to the memory area to be used as a stack. + * + * \return Process structure of new created process + * if successful, NULL otherwise. + */ #define proc_new(entry,data,size,stack) proc_new_with_name(NULL,(entry),(data),(size),(stack)) #else #define proc_new(entry,data,size,stack) proc_new_with_name(#entry,(entry),(data),(size),(stack)) @@ -286,7 +281,7 @@ INLINE void proc_permit(void) * \note This accessor is needed because _preempt_forbid_cnt * must be absoultely private. */ -INLINE bool proc_allowed(void) +INLINE bool proc_preemptAllowed(void) { #if CONFIG_KERN_PREEMPT extern cpu_atomic_t _preempt_forbid_cnt; @@ -296,6 +291,9 @@ INLINE bool proc_allowed(void) #endif } +/** Deprecated, use the proc_preemptAllowed() macro. */ +#define proc_allowed() proc_preemptAllowed() + /** * Execute a block of \a CODE atomically with respect to task scheduling. */ @@ -353,7 +351,7 @@ INLINE bool proc_allowed(void) */ #define PROC_DEFINE_STACK(name, size) \ STATIC_ASSERT((size) >= KERN_MINSTACKSIZE); \ - cpu_stack_t name[(size) / sizeof(cpu_stack_t)]; + cpu_stack_t name[((size) + sizeof(cpu_stack_t) - 1) / sizeof(cpu_stack_t)]; /* Memory fill codes to help debugging */ #if CONFIG_KERN_MONITOR