Exclude doc directories from the codelite project file
[bertos.git] / bertos / kern / proc.h
index efbdf458fb6ed5c0db5ca50e829af970d7042512..45949e8e3ef166f0bebc3b62bb014a15c8444ba1 100644 (file)
 #include <cpu/types.h> // cpu_stack_t
 #include <cpu/frame.h> // CPU_SAVED_REGS_CNT
 
+/*
+ * Define stack for one process.
+ *
+ * This macro define a static stack for one process and do
+ * check if given stack size is enough to run process.
+ */
+#define PROC_DEFINE_STACK(name, size) \
+       STATIC_ASSERT(size >= CONFIG_KERN_MINSTACKSIZE); \
+       cpu_stack_t name[size / sizeof(cpu_stack_t)]; \
+
 /*
  * Forward declaration. The definition of struct Process is private to the
  * scheduler and hidden in proc_p.h.
@@ -71,6 +81,14 @@ 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)